HashIndex plug-in attributes
You can use the following attributes to configure the HashIndex plug-in.
Attributes
- Name
- Specifies the name of the index. The name must be unique for each map. The name is used to retrieve the index object from the object map instance for the backing map.
- AttributeName
- Specifies the comma-delimited names of the attributes to index. For field-access indexes, the attribute names are equivalent to the field names. For property-access indexes, the attribute names are the JavaBean compatible property names. If only one attribute name exists, the HashIndex is a single attribute index. If this attribute is a relationship, it is also a relationship index. If multiple attribute names are included in the attribute names, the HashIndex is a composite index.
- FieldAccessAttribute
- Used for non-entity maps. If
true
, the object is accessed using the fields directly. If not specified orfalse
, the getter method for the attribute is used to access the data. - GlobalIndexEnabled
- If set to true, global index is enabled and the application can
cast the retrieved index object to the MapGlobalIndex interface.
When the GlobalIndexEnabled property of HashIndex is set to true, the global index function of HashIndex is enabled to support the MapGlobalIndex interface on top of any HashIndex configuration. It provides an efficient way to find data in large partitioned environment.
The following example shows that global index is enabled on a single-attribute HashIndex:<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="AttributeName" type="java.lang.String" value="employeeCode" description="attribute name" /> <property name="GlobalIndexEnabled" type="boolean" value="true" description="true for global index" /> </bean>
- GlobalIndexSyncUpdate
- The GlobalIndexSyncUpdate property setting takes effect when GlobalIndexEnabled property is set to true. If GlobalIndexSyncUpdate property is set to true, the global index update process is synchronous to HashIndex update that is part of user transaction and has impact on the performance of write transactions that cause index structure change. Application should only consider to set GlobalIndexSyncUpdate property to true when it expects global index look ups always returns up-to-date committed data.
- POJOKeyIndex
- Used for non-entity maps. If
true
, the index introspects the object in the key part of the map. This setting is useful when the key is a composite key and the value does not have the key embedded within it. If not specified orfalse
, then the index introspects the object in the value part of the map. - RangeIndex
- If
true
, range indexing is enabled and the application can cast the retrieved index object to the MapRangeIndex interface. If the RangeIndex property is configured asfalse
, the application can cast the retrieved index object to the MapIndex interface only.
Single-attribute HashIndex versus composite HashIndex
When
the AttributeName property of HashIndex includes
multiple attribute names, the HashIndex is a composite index. Otherwise,
if it includes only one attribute name, it is a single-attribute index.
For example, the AttributeName property value of a composite HashIndex
might be city,state,zipcode
. It includes three attributes
delimited by commas. If the AttributeName property
value is only zipcode
that only has one attribute,
it is a single-attribute HashIndex.
Composite HashIndex provides an efficient way to look up cached objects when search criteria involve many attributes. However, it does not support range index and its RangeIndex property must set to false.
For more information, see Using a composite index.
Relationship HashIndex
If the indexed attribute of single-attribute HashIndex is a relationship, either single- or multi-valued, the HashIndex is a relationship HashIndex. For relationship HashIndex, the RangeIndex property of HashIndex must set to “false”.
Relationship HashIndex can speed up queries that use cyclical references or use the IS NULL, IS EMPTY, SIZE, and MEMBER OF query filters. For more information, see Query optimization using indexes.
Key HashIndex
For non-entity maps, when
the POJOKeyIndex property of HashIndex is
set to true
, the HashIndex is a key HashIndex and
the key part of entry are used for indexing. When the AttributeName
property of HashIndex is not specified, the whole key is indexed;
otherwise, the key HashIndex can only be a single-attribute HashIndex.
For example, adding the following property into
the preceding sample causes the HashIndex to become key HashIndex
because the POJOKeyIndex property value is true
.
<property name="POJOKeyIndex" type="boolean" value="true"
description="indicates if POJO key HashIndex" />
In the preceding key index example, because the AttributeName property
value is specified as employeeCode
, the indexed attribute
is the employeeCode field of the key part of
map entry. If you want to build key index on the whole key part of
map entry, remove the AttributeName property.
Range HashIndex
When the RangeIndex property
of HashIndex is set to true
, the HashIndex is a range
index and can support the MapRangeIndex interface.
A MapRangeIndex implementation supports functions
to find data using
range functions, such as greater than, less than, or both, while a
MapIndex supports equals functions only. For a single-attribute index,
the RangeIndex property can be set to true
only
if the indexed attribute is of type Comparable. If the single-attribute
index will be used by query, the RangeIndex property must set to true
and
the indexed attribute must be of type Comparable. For relationship
HashIndex and composite HashIndex, the RangeIndex property must set
to false
.
The preceding sample is a range HashIndex
because the RangeIndex property value is true
.
The following table provides a summary for using range index.
HashIndex type | Supports range index |
---|---|
Single-attribute HashIndex: indexed key or attribute is of type Comparable | Yes |
Single-attribute HashIndex: indexed key or attribute is not of type Comparable | No |
Composite HashIndex | No |
Relationship HashIndex | No |
Query optimization with HashIndex plug-ins
Defining indexes can significantly improve query performance.WebSphere® eXtreme Scale queries can use built-in HashIndex plug-ins to improve performance of queries. Although using indexes can significantly improve query performance, it might have a performance impact on transactional map operations.