Configuring the HashIndex plug-in

You can configure the built-in HashIndex, the com.ibm.websphere.objectgrid.plugins.index.HashIndex class, with an XML file, programmatically or with an entity annotation on an entity map.

About this task

Configuring a composite index is the same as configuring a regular index with XML, except for the attributeName property value. In a composite index, the value of attributeName property is a comma-delimited list of attributes. For example, the value class Address has three attributes: city, state, and zipcode. A composite index can be defined with the attributeName property value as "city,state,zipcode" indicating that city, state, and zipcode are included in the composite index.

The composite HashIndexes do not support range lookups and therefore cannot have the RangeIndex property set to true.

Procedure

Example: Adding a HashIndex class into a BackingMap instance

In the following example, you configure the HashIndex plug-in by adding static index plug-ins to the XML file:

<backingMapPluginCollection id="person">
   <bean id="MapIndexPlugin" 
      className="com.ibm.websphere.objectgrid.plugins.index.HashIndex">
         <property name="Name" type="java.lang.String" value="CODE" 
            description="index name" />
         <property name="RangeIndex" type="boolean" value="true" 
            description="true for MapRangeIndex" />
         <property name="AttributeName" type="java.lang.String" value="employeeCode" 
            description="attribute name" />
   </bean>
</backingMapPluginCollection>

In this XML configuration example, the built-in HashIndex class is used as the index plug-in. The HashIndex supports properties that users can configure, such as Name, RangeIndex, and AttributeName.

In summary, the previous example defines a single-attribute range HashIndex. It is a single-attribute HashIndex because the AttributeName property value is employeeCode that includes only one attribute name. It also is a range HashIndex.