This topic explains index storage, and how to maintain indexes, either synchronously or asynchronously, in VMware Tanzu GemFire.

Indexes are automatically kept current with the region data they reference. The region attribute IndexMaintenanceSynchronous specifies whether the region indexes are updated synchronously when a region is modified or asynchronously in a background thread.

Index Maintenance Behavior

Asynchronous index maintenance batches up multiple updates to the same region key. The default mode is synchronous, since this provides the greatest consistency with region data.

See RegionFactory.setIndexMaintenanceSynchronous in the Java API docs.

This declarative index creation sets the maintenance mode to asynchronous:

<region-attributes index-update-type="asynchronous"> 
</region-attributes>

Internal Index Structure and Storage

Indexes are stored either as compact or non-compact data structures based on the indexed expression (even if the index key type is the same.) For example, consider the following Passenger object:

Passenger {
   String name,
   Date travelDate,
   int age,
   Flight flt,
}
Flight {
   int flightId,
   String origin,
   String dest,
}

An index on the Passenger name field will have different memory space requirements in the cache than the Flight origin field even though they are both String field types. The internal data structure selected by Tanzu GemFire for index storage will depend on the field’s level in the object. In this example, name is a top-level field and an index on name can be stored as a compact index. Since origin is a second-level field, any index that uses origin as the indexed expression will be stored as a non-compact index.

Compact Index

A compact index has simple data structures to minimize its footprint, at the expense of doing extra work at index maintenance. This index does not support the storage of projection attributes.

Compact indexes only support the creation of an index on a region path. In addition, the following conditions must be met:

  • Index maintenance is synchronous.
  • The indexed expression is a path expression.
  • The FROM clause has only one iterator. This implies that there is only one value in the index for each region entry and it is directly on the region values (not supported with keys, entries).

Non-Compact Index

Used whenever a compact index cannot be used.

check-circle-line exclamation-circle-line close-line
Scroll to top icon