use of com.hazelcast.query.impl.CachedQueryEntry in project hazelcast by hazelcast.
the class AbstractInternalQueryCache method doFullKeyScan.
protected void doFullKeyScan(Predicate predicate, Set<K> resultingSet) {
InternalSerializationService serializationService = this.serializationService;
CachedQueryEntry queryEntry = new CachedQueryEntry();
Set<Map.Entry<Data, QueryCacheRecord>> entries = recordStore.entrySet();
for (Map.Entry<Data, QueryCacheRecord> entry : entries) {
Data keyData = entry.getKey();
QueryCacheRecord record = entry.getValue();
Object value = record.getValue();
queryEntry.init(serializationService, keyData, value, Extractors.empty());
boolean valid = predicate.apply(queryEntry);
if (valid) {
resultingSet.add((K) queryEntry.getKey());
}
}
}
use of com.hazelcast.query.impl.CachedQueryEntry in project hazelcast by hazelcast.
the class PartitionScanRunner method run.
@SuppressWarnings("unchecked")
public Collection<QueryableEntry> run(String mapName, Predicate predicate, int partitionId) {
PagingPredicate pagingPredicate = predicate instanceof PagingPredicate ? (PagingPredicate) predicate : null;
List<QueryableEntry> resultList = new LinkedList<QueryableEntry>();
PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(partitionId);
MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
Iterator<Record> iterator = partitionContainer.getRecordStore(mapName).loadAwareIterator(getNow(), false);
Map.Entry<Integer, Map.Entry> nearestAnchorEntry = getNearestAnchorEntry(pagingPredicate);
boolean useCachedValues = isUseCachedDeserializedValuesEnabled(mapContainer);
Extractors extractors = mapServiceContext.getExtractors(mapName);
while (iterator.hasNext()) {
Record record = iterator.next();
Data key = (Data) toData(record.getKey());
Object value = toData(useCachedValues ? Records.getValueOrCachedValue(record, serializationService) : record.getValue());
if (value == null) {
continue;
}
//we want to always use CachedQueryEntry as these are short-living objects anyway
QueryableEntry queryEntry = new CachedQueryEntry(serializationService, key, value, extractors);
if (predicate.apply(queryEntry) && compareAnchor(pagingPredicate, queryEntry, nearestAnchorEntry)) {
resultList.add(queryEntry);
}
}
return getSortedSubList(resultList, pagingPredicate, nearestAnchorEntry);
}
Aggregations