use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class MapMBean method entrySet.
@ManagedAnnotation(value = "entrySet", operation = true)
public String entrySet(String query) {
Set<Map.Entry> entrySet;
if (query != null && !query.isEmpty()) {
Predicate predicate = new SqlPredicate(query);
entrySet = managedObject.entrySet(predicate);
} else {
entrySet = managedObject.entrySet();
}
StringBuilder buf = new StringBuilder();
if (entrySet.size() == 0) {
buf.append("Empty");
} else {
buf.append("[");
for (Map.Entry entry : entrySet) {
buf.append("{key:");
buf.append(entry.getKey());
buf.append(", value:");
buf.append(entry.getValue());
buf.append("}, ");
}
buf.replace(buf.length() - 1, buf.length(), "]");
}
return buf.toString();
}
use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class MapQueryEngineImplTest method runQueryOnAllPartitions_key.
@Test
public void runQueryOnAllPartitions_key() throws ExecutionException, InterruptedException {
Predicate predicate = Predicates.equal("this", value);
Query query = Query.of().mapName(map.getName()).predicate(predicate).iterationType(KEY).build();
QueryResult result = queryEngine.execute(query, Target.ALL_NODES);
assertEquals(1, result.size());
assertEquals(key, toObject(result.iterator().next().getKey()));
}
use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class MapQueryEngineImplTest method runQueryOnAllPartitions.
@Test
public void runQueryOnAllPartitions() throws ExecutionException, InterruptedException {
Predicate predicate = Predicates.equal("this", value);
Query query = Query.of().mapName(map.getName()).predicate(predicate).iterationType(KEY).build();
QueryResult result = queryEngine.execute(query, Target.ALL_NODES);
assertEquals(1, result.size());
assertEquals(key, toObject(result.iterator().next().getKey()));
}
use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class QueryRunner method runPartitionScanQueryOnGivenOwnedPartition.
Result runPartitionScanQueryOnGivenOwnedPartition(Query query, int partitionId) throws ExecutionException, InterruptedException {
MapContainer mapContainer = mapServiceContext.getMapContainer(query.getMapName());
Predicate predicate = queryOptimizer.optimize(query.getPredicate(), mapContainer.getIndexes());
Collection<QueryableEntry> entries = partitionScanExecutor.execute(query.getMapName(), predicate, Collections.singletonList(partitionId));
return populateTheResult(query, entries, Collections.singletonList(partitionId));
}
use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class BetweenVisitor method findCandidatesAndGroupByAttribute.
/**
* Find GreaterLessPredicates with equal flag set to true and group them by attribute name
*/
private InternalListMultiMap<String, GreaterLessPredicate> findCandidatesAndGroupByAttribute(Predicate[] predicates, Indexes indexService) {
InternalListMultiMap<String, GreaterLessPredicate> candidates = null;
for (Predicate predicate : predicates) {
if (!(predicate instanceof GreaterLessPredicate)) {
continue;
}
GreaterLessPredicate greaterLessPredicate = (GreaterLessPredicate) predicate;
if (!(greaterLessPredicate.equal)) {
continue;
}
String attributeName = greaterLessPredicate.attributeName;
Index index = indexService.getIndex(attributeName);
if (index == null || index.getConverter() == null) {
continue;
}
candidates = addIntoCandidates(greaterLessPredicate, candidates);
}
return candidates;
}
Aggregations