Class IndexConfig

java.lang.Object
com.hazelcast.config.IndexConfig
All Implemented Interfaces:
DataSerializable, IdentifiedDataSerializable

public class IndexConfig
extends Object
implements IdentifiedDataSerializable
Configuration of an index. Hazelcast support two types of indexes: sorted index and hash 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.

Index could be created on one or more attributes.

See Also:
IndexType, MapConfig.setIndexConfigs(List)
  • Field Details

    • DEFAULT_TYPE

      public static final IndexType DEFAULT_TYPE
      Default index type.
  • Constructor Details

    • 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, 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 Details

    • getName

      public 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​(String name)
      Sets name of the index.
      Parameters:
      name - Name of the index or null 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 List<String> getAttributes()
      Gets index attributes.
      Returns:
      Index attributes.
    • addAttribute

      public IndexConfig addAttribute​(String attribute)
      Adds an index attribute with the given.
      Parameters:
      attribute - Attribute name.
      Returns:
      This instance for chaining.
    • addAttributeInternal

      public void addAttributeInternal​(String attribute)
    • setAttributes

      public IndexConfig setAttributes​(List<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.
    • getFactoryId

      public int getFactoryId()
      Description copied from interface: IdentifiedDataSerializable
      Returns DataSerializableFactory factory ID for this class.
      Specified by:
      getFactoryId in interface IdentifiedDataSerializable
      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 interface IdentifiedDataSerializable
      Returns:
      type ID
    • writeData

      public void writeData​(ObjectDataOutput out) throws IOException
      Description copied from interface: DataSerializable
      Writes object fields to output stream
      Specified by:
      writeData in interface DataSerializable
      Parameters:
      out - output
      Throws:
      IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
    • readData

      public void readData​(ObjectDataInput in) throws IOException
      Description copied from interface: DataSerializable
      Reads fields from the input stream
      Specified by:
      readData in interface DataSerializable
      Parameters:
      in - input
      Throws:
      IOException - if an I/O error occurs. In particular, an IOException may be thrown if the input stream has been closed.
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object