Package com.hazelcast.config
Class IndexConfig
- java.lang.Object
-
- com.hazelcast.config.IndexConfig
-
- All Implemented Interfaces:
DataSerializable
,IdentifiedDataSerializable
,com.hazelcast.nio.serialization.impl.Versioned
public class IndexConfig extends java.lang.Object implements IdentifiedDataSerializable, com.hazelcast.nio.serialization.impl.Versioned
Configuration of an index. Hazelcast support three types of indexes: sorted index, hash index and bitmap index. Sorted indexes could be used with equality and range predicates and have logarithmic search time. Hash indexes could be used with equality predicates and have constant search time assuming the hash function of the indexed field disperses the elements properly. Bitmap indexes are similar to hash index. They are able to achieve a much higher memory efficiency for low cardinality attributes at the cost of reduced query performance.Index could be created on one or more attributes.
- See Also:
IndexType
,MapConfig.setIndexConfigs(List)
-
-
Field Summary
Fields Modifier and Type Field Description static IndexType
DEFAULT_TYPE
Default index type.
-
Constructor Summary
Constructors Constructor Description IndexConfig()
IndexConfig(IndexConfig other)
IndexConfig(IndexType type)
Creates an index configuration of the given type.IndexConfig(IndexType type, java.lang.String... attributes)
Creates an index configuration of the given type with provided attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IndexConfig
addAttribute(java.lang.String attribute)
Adds an index attribute with the given.void
addAttributeInternal(java.lang.String attribute)
boolean
equals(java.lang.Object o)
java.util.List<java.lang.String>
getAttributes()
Gets index attributes.BitmapIndexOptions
getBitmapIndexOptions()
Provides access to index options specific to bitmap indexes.BTreeIndexConfig
getBTreeIndexConfig()
Provides access to index options specific to B-Tree indexes.int
getClassId()
Returns type identifier for this class.int
getFactoryId()
Returns DataSerializableFactory factory ID for this class.java.lang.String
getName()
Gets name of the index.IndexType
getType()
Gets type of the index.int
hashCode()
void
readData(ObjectDataInput in)
Reads fields from the input streamIndexConfig
setAttributes(java.util.List<java.lang.String> attributes)
Sets index attributes.IndexConfig
setBitmapIndexOptions(BitmapIndexOptions bitmapIndexOptions)
Sets bitmap index options of this index config to the given ones.IndexConfig
setBTreeIndexConfig(BTreeIndexConfig bTreeIndexConfig)
Sets B-Tree config of this index to the specified configuration.IndexConfig
setName(java.lang.String name)
Sets name of the index.IndexConfig
setType(IndexType type)
Sets type of the index.java.lang.String
toString()
void
writeData(ObjectDataOutput out)
Writes object fields to output stream
-
-
-
Field Detail
-
DEFAULT_TYPE
public static final IndexType DEFAULT_TYPE
Default index type.
-
-
Constructor Detail
-
IndexConfig
public IndexConfig()
-
IndexConfig
public IndexConfig(IndexType type)
Creates an index configuration of the given type.- Parameters:
type
- Index type.
-
IndexConfig
public IndexConfig(IndexType type, java.lang.String... attributes)
Creates an index configuration of the given type with provided attributes.- Parameters:
type
- Index type.attributes
- Attributes to be indexed.
-
IndexConfig
public IndexConfig(IndexConfig other)
-
-
Method Detail
-
getName
public java.lang.String getName()
Gets name of the index.- Returns:
- Name of the index or
null
if index name should be generated automatically.
-
setName
public IndexConfig setName(java.lang.String name)
Sets name of the index.- Parameters:
name
- Name of the index ornull
if index name should be generated automatically.- Returns:
- This instance for chaining.
-
getType
public IndexType getType()
Gets type of the index.Defaults to
IndexType.SORTED
.- Returns:
- Type of the index.
-
setType
public IndexConfig setType(IndexType type)
Sets type of the index.Defaults to
IndexType.SORTED
.- Parameters:
type
- Type of the index.- Returns:
- This instance for chaining.
-
getAttributes
public java.util.List<java.lang.String> getAttributes()
Gets index attributes.- Returns:
- Index attributes.
-
addAttribute
public IndexConfig addAttribute(java.lang.String attribute)
Adds an index attribute with the given.- Parameters:
attribute
- Attribute name.- Returns:
- This instance for chaining.
-
addAttributeInternal
public void addAttributeInternal(java.lang.String attribute)
-
setAttributes
public IndexConfig setAttributes(java.util.List<java.lang.String> attributes)
Sets index attributes.- Parameters:
attributes
- Index attributes.- Returns:
- This instance for chaining.
-
getBitmapIndexOptions
public BitmapIndexOptions getBitmapIndexOptions()
Provides access to index options specific to bitmap indexes.- Returns:
- the bitmap index options associated with this index config.
-
setBitmapIndexOptions
public IndexConfig setBitmapIndexOptions(BitmapIndexOptions bitmapIndexOptions)
Sets bitmap index options of this index config to the given ones.- Parameters:
bitmapIndexOptions
- the bitmap index options to set.- Returns:
- this index config instance.
-
getBTreeIndexConfig
public BTreeIndexConfig getBTreeIndexConfig()
Provides access to index options specific to B-Tree indexes.- Returns:
- the b-tree index configuration associated with this config.
-
setBTreeIndexConfig
public IndexConfig setBTreeIndexConfig(BTreeIndexConfig bTreeIndexConfig)
Sets B-Tree config of this index to the specified configuration.- Parameters:
bTreeIndexConfig
- new b-tree index configuration to set.
-
getFactoryId
public int getFactoryId()
Description copied from interface:IdentifiedDataSerializable
Returns DataSerializableFactory factory ID for this class.- Specified by:
getFactoryId
in interfaceIdentifiedDataSerializable
- Returns:
- factory ID
-
getClassId
public int getClassId()
Description copied from interface:IdentifiedDataSerializable
Returns type identifier for this class. It should be unique per DataSerializableFactory.- Specified by:
getClassId
in interfaceIdentifiedDataSerializable
- Returns:
- type ID
-
writeData
public void writeData(ObjectDataOutput out) throws java.io.IOException
Description copied from interface:DataSerializable
Writes object fields to output stream- Specified by:
writeData
in interfaceDataSerializable
- Parameters:
out
- output- Throws:
java.io.IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the output stream has been closed.
-
readData
public void readData(ObjectDataInput in) throws java.io.IOException
Description copied from interface:DataSerializable
Reads fields from the input stream- Specified by:
readData
in interfaceDataSerializable
- Parameters:
in
- input- Throws:
java.io.IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the input stream has been closed.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-