use of com.hazelcast.query.impl.Indexes in project hazelcast by hazelcast.
the class MapSplitBrainHandlerService method prepareMergeRunnable.
@Override
public Runnable prepareMergeRunnable() {
final long now = getNow();
final Map<String, MapContainer> mapContainers = getMapContainers();
final Map<MapContainer, Collection<Record>> recordMap = new HashMap<MapContainer, Collection<Record>>(mapContainers.size());
final IPartitionService partitionService = nodeEngine.getPartitionService();
final int partitionCount = partitionService.getPartitionCount();
final Address thisAddress = nodeEngine.getClusterService().getThisAddress();
for (MapContainer mapContainer : mapContainers.values()) {
for (int i = 0; i < partitionCount; i++) {
RecordStore recordStore = mapServiceContext.getPartitionContainer(i).getRecordStore(mapContainer.getName());
// add your owned entries to the map so they will be merged
if (thisAddress.equals(partitionService.getPartitionOwner(i))) {
Collection<Record> records = recordMap.get(mapContainer);
if (records == null) {
records = new ArrayList<Record>();
recordMap.put(mapContainer, records);
}
final Iterator<Record> iterator = recordStore.iterator(now, false);
while (iterator.hasNext()) {
final Record record = iterator.next();
records.add(record);
}
}
// clear all records either owned or backup
recordStore.reset();
}
Indexes indexes = mapContainer.getIndexes();
indexes.clearIndexes();
}
return new Merger(recordMap);
}
use of com.hazelcast.query.impl.Indexes in project hazelcast by hazelcast.
the class PostJoinMapOperation method addMapIndex.
public void addMapIndex(MapContainer mapContainer) {
final Indexes indexes = mapContainer.getIndexes();
if (indexes.hasIndex()) {
MapIndexInfo mapIndexInfo = new MapIndexInfo(mapContainer.getName());
for (Index index : indexes.getIndexes()) {
mapIndexInfo.addIndexInfo(index.getAttributeName(), index.isOrdered());
}
indexInfoList.add(mapIndexInfo);
}
}
use of com.hazelcast.query.impl.Indexes in project hazelcast by hazelcast.
the class RecordStoreTest method testRecordStoreResetWithClearingIndexes.
@Test
public void testRecordStoreResetWithClearingIndexes() {
IMap<Object, Object> map = testRecordStoreReset();
Indexes indexes = getIndexService(map);
indexes.clearIndexes();
Collection<Object> values = map.values(Predicates.equal("name", "tom"));
assertTrue(values.isEmpty());
}
use of com.hazelcast.query.impl.Indexes in project hazelcast by hazelcast.
the class MapIndexJsonTest method getIndexOfAttributeForMap.
protected static List<Index> getIndexOfAttributeForMap(HazelcastInstance instance, String mapName, String attribute) {
Node node = getNode(instance);
MapService service = node.nodeEngine.getService(MapService.SERVICE_NAME);
MapServiceContext mapServiceContext = service.getMapServiceContext();
MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
List<Index> result = new ArrayList<>();
for (int partitionId : mapServiceContext.getOrInitCachedMemberPartitions()) {
Indexes indexes = mapContainer.getIndexes(partitionId);
result.add(indexes.getIndex(attribute));
}
return result;
}
use of com.hazelcast.query.impl.Indexes in project hazelcast by hazelcast.
the class IndexStatsChangingNumberOfMembersTest method calculateOverallSelectivity.
protected double calculateOverallSelectivity(long initialHits, double initialTotalSelectivityCount, IMap<?, ?>... maps) {
List<Indexes> allIndexes = new ArrayList<>();
for (IMap<?, ?> map : maps) {
allIndexes.addAll(getAllIndexes(map));
}
long totalHitCount = 0;
double totalNormalizedHitCardinality = 0.0;
for (Indexes indexes : allIndexes) {
PerIndexStats perIndexStats = indexes.getIndex("this").getPerIndexStats();
totalHitCount += perIndexStats.getHitCount();
totalNormalizedHitCardinality += perIndexStats.getTotalNormalizedHitCardinality();
}
double averageHitSelectivity = totalHitCount == 0 ? 0.0 : 1.0 - totalNormalizedHitCardinality / totalHitCount;
if (totalHitCount + initialHits == 0) {
return 0.0;
} else {
return (averageHitSelectivity * totalHitCount + initialTotalSelectivityCount) / (totalHitCount + initialHits);
}
}
Aggregations