use of com.hazelcast.query.impl.Indexes in project hazelcast by hazelcast.
the class Accessors method getAllIndexes.
/**
* Obtains a list of {@link Indexes} for the given map local to the node
* associated with it.
* <p>
* There may be more than one indexes instance associated with a map if its
* indexes are partitioned.
*
* @param map the map to obtain the indexes for.
* @return the obtained indexes list.
*/
public static List<Indexes> getAllIndexes(IMap map) {
MapProxyImpl mapProxy = (MapProxyImpl) map;
String mapName = mapProxy.getName();
NodeEngine nodeEngine = mapProxy.getNodeEngine();
IPartitionService partitionService = nodeEngine.getPartitionService();
MapService mapService = nodeEngine.getService(MapService.SERVICE_NAME);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
Indexes maybeGlobalIndexes = mapContainer.getIndexes();
if (maybeGlobalIndexes != null) {
return Collections.singletonList(maybeGlobalIndexes);
}
PartitionContainer[] partitionContainers = mapServiceContext.getPartitionContainers();
List<Indexes> allIndexes = new ArrayList<>();
for (PartitionContainer partitionContainer : partitionContainers) {
IPartition partition = partitionService.getPartition(partitionContainer.getPartitionId());
if (!partition.isLocal()) {
continue;
}
Indexes partitionIndexes = partitionContainer.getIndexes().get(mapName);
if (partitionIndexes == null) {
continue;
}
assert !partitionIndexes.isGlobal();
allIndexes.add(partitionIndexes);
}
return allIndexes;
}
Aggregations