use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.
the class CallerRunsPartitionScanExecutor method execute.
@Override
public Collection<QueryableEntry> execute(String mapName, Predicate predicate, Collection<Integer> partitions) {
RetryableHazelcastException storedException = null;
Collection<QueryableEntry> result = new ArrayList<QueryableEntry>();
for (Integer partitionId : partitions) {
try {
result.addAll(partitionScanRunner.run(mapName, predicate, partitionId));
} catch (RetryableHazelcastException e) {
// see discussion at https://github.com/hazelcast/hazelcast/pull/5049#discussion_r28773099 for details.
if (storedException == null) {
storedException = e;
}
}
}
if (storedException != null) {
throw storedException;
}
return result;
}
use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.
the class NodeQueryCacheEventService method canPassFilter.
private boolean canPassFilter(LocalEntryEventData localEntryEventData, EventFilter filter) {
if (filter == null || filter instanceof TrueEventFilter) {
return true;
}
NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
SerializationService serializationService = nodeEngine.getSerializationService();
Data keyData = localEntryEventData.getKeyData();
Object value = getValueOrOldValue(localEntryEventData);
QueryableEntry entry = new QueryEntry((InternalSerializationService) serializationService, keyData, value, Extractors.empty());
return filter.eval(entry);
}
use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.
the class ParallelAccumulationExecutor method split.
private Collection<QueryableEntry>[] split(Collection<QueryableEntry> entries, int chunkCount) {
if (entries.size() < chunkCount * 2) {
return null;
}
int counter = 0;
Collection<QueryableEntry>[] entriesSplit = new Collection[chunkCount];
int entriesPerChunk = entries.size() / chunkCount;
for (int i = 0; i < chunkCount; i++) {
entriesSplit[i] = new ArrayList<QueryableEntry>(entriesPerChunk);
}
for (QueryableEntry entry : entries) {
entriesSplit[counter++ % THREAD_SPLIT_COUNT].add(entry);
}
return entriesSplit;
}
use of com.hazelcast.query.impl.QueryableEntry 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);
}
use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.
the class DefaultQueryCache method keySet.
@Override
public Set<K> keySet(Predicate predicate) {
checkNotNull(predicate, "Predicate cannot be null!");
Set<K> resultingSet = new HashSet<K>();
Set<QueryableEntry> query = indexes.query(predicate);
if (query != null) {
for (QueryableEntry entry : query) {
K key = (K) entry.getKey();
resultingSet.add(key);
}
} else {
doFullKeyScan(predicate, resultingSet);
}
return resultingSet;
}
Aggregations