I am trying to improve performance of Hazelcast lookup by using composite key. I have a class entity
Class Entity {
private Long id;
private String field1;
private String field2;
private String field3;
// getter and setters
}
I have added a composite index comprising of above 3 fields in hazelcast-server.xml
...
<map name="Entity">
<max-idle-seconds>2678400</max-idle-seconds>
<time-to-live-seconds>2678400</time-to-live-seconds>
<backup-count>3</backup-count>
<async-backup-count>3</async-backup-count>
<read-backup-data>true</read-backup-data>
<indexes>
<index ordered="false">field1, field2, field3</index>
</indexes>
</map>
...
Querying Hazelcast map
EntryObject entryObject = new PredicateBuilder().getEntryObject();
PredicateBuilder predicate = entryObject.get("field1").equal("value1")
.and(entryObject.get("field2").equal("value2"))
.and(entryObject.get("field3").equal("value3"));
IMap<Long, Entity> entityCache = hazelcastInstance.getMap("Entity")
List<Entity> routings = new ArrayList<>(entityCache.values(predicate));
The code is working fine with and without the index.
Questions
I have scanned a lot hazelcast documentation and internet forums but could not find concrete answers. Hazelcast version: 3.12; Java version: 8
The only way I've found is IMap.getLocalMapStats().getIndexStats()
as described here: https://docs.hazelcast.org/docs/3.12.1/manual/html-single/index.html#map-index-statistics