use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.
the class QueryEventFilterTest method mockEntryWithKeyData.
private QueryableEntry mockEntryWithKeyData(Data key) {
QueryableEntry entry = mock(QueryableEntry.class);
when(entry.getKeyData()).thenReturn(key);
return entry;
}
use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.
the class NotEqualPredicateTest method apply_givenAttributeValueIsNull_whenEntryHasTheAttributeIsNotNull_thenReturnTrue.
@Test
public void apply_givenAttributeValueIsNull_whenEntryHasTheAttributeIsNotNull_thenReturnTrue() {
NotEqualPredicate name = new NotEqualPredicate("name", null);
QueryableEntry mockEntry = newMockEntry("foo");
boolean result = name.apply(mockEntry);
assertTrue(result);
}
use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.
the class NotEqualPredicateTest method newMockEntry.
private QueryableEntry newMockEntry(Object attributeValue) {
QueryableEntry mockEntry = mock(QueryableEntry.class);
when(mockEntry.getAttributeValue(anyString())).thenReturn(attributeValue);
return mockEntry;
}
use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.
the class QueryRunner method runIndexOrPartitionScanQueryOnOwnedPartitions.
// full query = index query (if possible), then partition-scan query
public Result runIndexOrPartitionScanQueryOnOwnedPartitions(Query query) throws ExecutionException, InterruptedException {
int migrationStamp = getMigrationStamp();
Collection<Integer> initialPartitions = mapServiceContext.getOwnedPartitions();
MapContainer mapContainer = mapServiceContext.getMapContainer(query.getMapName());
// first we optimize the query
Predicate predicate = queryOptimizer.optimize(query.getPredicate(), mapContainer.getIndexes());
// then we try to run using an index, but if that doesn't work, we'll try a full table scan
// This would be the point where a query-plan should be added. It should determine f a full table scan
// or an index should be used.
Collection<QueryableEntry> entries = runUsingIndexSafely(predicate, mapContainer, migrationStamp);
if (entries == null) {
entries = runUsingPartitionScanSafely(query.getMapName(), predicate, initialPartitions, migrationStamp);
}
updateStatistics(mapContainer);
if (entries != null) {
// so that caller is aware of partitions from which results were obtained.
return populateTheResult(query, entries, initialPartitions);
} else {
// then return empty result set without any partition IDs set (so that it is ignored by callers).
return resultProcessorRegistry.get(query.getResultType()).populateResult(query, queryResultSizeLimiter.getNodeResultLimit(initialPartitions.size()));
}
}
use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.
the class CallerRunsAccumulationExecutor method execute.
@Override
@SuppressWarnings("unchecked")
public AggregationResult execute(Aggregator aggregator, Collection<QueryableEntry> entries, Collection<Integer> partitionIds) {
Aggregator resultAggregator = serializationService.toObject(serializationService.toData(aggregator));
try {
for (QueryableEntry entry : entries) {
resultAggregator.accumulate(entry);
}
} finally {
resultAggregator.onAccumulationFinished();
}
AggregationResult result = new AggregationResult(resultAggregator);
result.setPartitionIds(partitionIds);
return result;
}
Aggregations