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);
}
}
use of com.hazelcast.query.impl.Indexes in project hazelcast by hazelcast.
the class ClientBitmapIndexTest method before.
@Before
public void before() {
HazelcastInstance member = factory.newHazelcastInstance(getConfig());
personsOnMember = member.getMap("persons");
HazelcastInstance client = factory.newHazelcastClient();
persons = client.getMap("persons");
// add the index dynamically to verify client protocol support
persons.addIndex(indexConfig);
List<Indexes> allIndexes = getAllIndexes(personsOnMember);
assertEquals(1, allIndexes.size());
InternalIndex[] indexes = allIndexes.get(0).getIndexes();
assertEquals(1, indexes.length);
assertEquals(IndexUtils.validateAndNormalize("persons", indexConfig), indexes[0].getConfig());
}
use of com.hazelcast.query.impl.Indexes in project hazelcast by hazelcast.
the class DefaultRecordStore method clearPartition.
@Override
public void clearPartition(boolean onShutdown) {
NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
if (lockService != null) {
final DefaultObjectNamespace namespace = new DefaultObjectNamespace(MapService.SERVICE_NAME, name);
lockService.clearLockStore(partitionId, namespace);
}
Indexes indexes = mapContainer.getIndexes();
if (indexes.hasIndex()) {
for (Record record : storage.values()) {
Data key = record.getKey();
Object value = Records.getValueOrCachedValue(record, serializationService);
indexes.removeEntryIndex(key, value);
}
}
mapDataStore.reset();
if (onShutdown) {
NativeMemoryConfig nativeMemoryConfig = nodeEngine.getConfig().getNativeMemoryConfig();
boolean shouldClear = (nativeMemoryConfig != null && nativeMemoryConfig.getAllocatorType() != POOLED);
if (shouldClear) {
storage.clear(true);
}
storage.destroy(true);
} else {
storage.clear(false);
}
}
use of com.hazelcast.query.impl.Indexes in project hazelcast by hazelcast.
the class AbstractRecordStore method saveIndex.
protected void saveIndex(Record record, Object oldValue) {
Data dataKey = record.getKey();
final Indexes indexes = mapContainer.getIndexes();
if (indexes.hasIndex()) {
Object value = Records.getValueOrCachedValue(record, serializationService);
// When using format InMemoryFormat.NATIVE, just copy key & value to heap.
if (NATIVE == inMemoryFormat) {
dataKey = (Data) copyToHeap(dataKey);
value = copyToHeap(value);
oldValue = copyToHeap(oldValue);
}
QueryableEntry queryableEntry = mapContainer.newQueryEntry(dataKey, value);
indexes.saveEntryIndex(queryableEntry, oldValue);
}
}
Aggregations