use of com.hazelcast.config.CacheDeserializedValues in project hazelcast by hazelcast.
the class MapMigrationAwareService method populateIndexes.
@SuppressWarnings("checkstyle:NPathComplexity")
private void populateIndexes(PartitionMigrationEvent event, TargetIndexes targetIndexes, String stepName) {
assert event.getMigrationEndpoint() == DESTINATION;
assert targetIndexes != null;
if (event.getNewReplicaIndex() != 0) {
// backup partitions have no indexes to populate
return;
}
PartitionContainer container = mapServiceContext.getPartitionContainer(event.getPartitionId());
for (RecordStore<Record> recordStore : container.getMaps().values()) {
MapContainer mapContainer = mapServiceContext.getMapContainer(recordStore.getName());
Indexes indexes = mapContainer.getIndexes(event.getPartitionId());
indexes.createIndexesFromRecordedDefinitions();
if (!indexes.haveAtLeastOneIndex()) {
// no indexes to work with
continue;
}
if (indexes.isGlobal() && targetIndexes == TargetIndexes.NON_GLOBAL) {
continue;
}
if (!indexes.isGlobal() && targetIndexes == TargetIndexes.GLOBAL) {
continue;
}
InternalIndex[] indexesSnapshot = indexes.getIndexes();
Indexes.beginPartitionUpdate(indexesSnapshot);
CacheDeserializedValues cacheDeserializedValues = mapContainer.getMapConfig().getCacheDeserializedValues();
CachedQueryEntry<?, ?> cachedEntry = cacheDeserializedValues == NEVER ? new CachedQueryEntry<>(serializationService, mapContainer.getExtractors()) : null;
recordStore.forEach((key, record) -> {
Object value = Records.getValueOrCachedValue(record, serializationService);
if (value != null) {
QueryableEntry queryEntry = mapContainer.newQueryEntry(key, value);
queryEntry.setRecord(record);
CachedQueryEntry<?, ?> newEntry = cachedEntry == null ? (CachedQueryEntry<?, ?>) queryEntry : cachedEntry.init(key, value);
indexes.putEntry(newEntry, null, queryEntry, Index.OperationSource.SYSTEM);
}
}, false);
Indexes.markPartitionAsIndexed(event.getPartitionId(), indexesSnapshot);
}
if (logger.isFinestEnabled()) {
logger.finest(String.format("Populated indexes at step `%s`:[%s]", stepName, event));
}
}
use of com.hazelcast.config.CacheDeserializedValues in project hazelcast by hazelcast.
the class AddIndexOperation method runInternal.
@Override
public void runInternal() {
int partitionId = getPartitionId();
Indexes indexes = mapContainer.getIndexes(partitionId);
InternalIndex index = indexes.addOrGetIndex(config);
if (index.hasPartitionIndexed(partitionId)) {
return;
}
SerializationService serializationService = getNodeEngine().getSerializationService();
index.beginPartitionUpdate();
CacheDeserializedValues cacheDeserializedValues = mapContainer.getMapConfig().getCacheDeserializedValues();
CachedQueryEntry<?, ?> cachedEntry = cacheDeserializedValues == NEVER ? new CachedQueryEntry<>(serializationService, mapContainer.getExtractors()) : null;
recordStore.forEach((dataKey, record) -> {
Object value = Records.getValueOrCachedValue(record, serializationService);
QueryableEntry<?, ?> queryEntry = mapContainer.newQueryEntry(dataKey, value);
queryEntry.setRecord(record);
CachedQueryEntry<?, ?> newEntry = cachedEntry == null ? (CachedQueryEntry<?, ?>) queryEntry : cachedEntry.init(dataKey, value);
index.putEntry(newEntry, null, queryEntry, Index.OperationSource.USER);
}, false);
index.markPartitionAsIndexed(partitionId);
}
use of com.hazelcast.config.CacheDeserializedValues in project hazelcast by hazelcast.
the class DataRecordFactory method newRecord.
@Override
public Record<Data> newRecord(Data key, Object value) {
MapConfig mapConfig = mapContainer.getMapConfig();
boolean perEntryStatsEnabled = mapConfig.isPerEntryStatsEnabled();
CacheDeserializedValues cacheDeserializedValues = mapConfig.getCacheDeserializedValues();
boolean hasEviction = mapContainer.getEvictor() != NULL_EVICTOR;
Data valueData = ss.toData(value);
switch(cacheDeserializedValues) {
case NEVER:
return newSimpleRecord(valueData, mapConfig, perEntryStatsEnabled, hasEviction);
default:
return newCachedSimpleRecord(valueData, mapConfig, perEntryStatsEnabled, hasEviction);
}
}
Aggregations