use of com.hazelcast.query.PartitionPredicate in project hazelcast by hazelcast.
the class PredicateDataSerializerHook method createFactory.
@Override
public DataSerializableFactory createFactory() {
ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
constructors[SQL_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new SqlPredicate();
}
};
constructors[AND_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new AndPredicate();
}
};
constructors[BETWEEN_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new BetweenPredicate();
}
};
constructors[EQUAL_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new EqualPredicate();
}
};
constructors[GREATERLESS_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new GreaterLessPredicate();
}
};
constructors[LIKE_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new LikePredicate();
}
};
constructors[ILIKE_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new ILikePredicate();
}
};
constructors[IN_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new InPredicate();
}
};
constructors[INSTANCEOF_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new InstanceOfPredicate();
}
};
constructors[NOTEQUAL_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new NotEqualPredicate();
}
};
constructors[NOT_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new NotPredicate();
}
};
constructors[OR_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new OrPredicate();
}
};
constructors[REGEX_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new RegexPredicate();
}
};
constructors[FALSE_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return FalsePredicate.INSTANCE;
}
};
constructors[TRUE_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return TruePredicate.INSTANCE;
}
};
constructors[PAGING_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new PagingPredicate();
}
};
constructors[PARTITION_PREDICATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new PartitionPredicate();
}
};
constructors[NULL_OBJECT] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new IndexImpl.NullObject();
}
};
return new ArrayDataSerializableFactory(constructors);
}
use of com.hazelcast.query.PartitionPredicate in project hazelcast by hazelcast.
the class PartitionPredicateTest method testSerialization.
@Test
public void testSerialization() {
SerializationService serializationService = getSerializationService(local);
Data serialized = serializationService.toData(predicate);
PartitionPredicate deserialized = serializationService.toObject(serialized);
assertEquals(partitionKey, deserialized.getPartitionKey());
assertEquals(TruePredicate.INSTANCE, deserialized.getTarget());
}
use of com.hazelcast.query.PartitionPredicate in project hazelcast by hazelcast.
the class MapProxyImpl method executePredicate.
private Set executePredicate(Predicate predicate, IterationType iterationType, boolean uniqueResult) {
checkNotNull(predicate, NULL_PREDICATE_IS_NOT_ALLOWED);
MapQueryEngine queryEngine = getMapQueryEngine();
QueryResult result;
if (predicate instanceof PartitionPredicate) {
PartitionPredicate partitionPredicate = (PartitionPredicate) predicate;
Data key = toData(partitionPredicate.getPartitionKey());
int partitionId = getNodeEngine().getPartitionService().getPartitionId(key);
Query query = Query.of().mapName(getName()).predicate(partitionPredicate.getTarget()).iterationType(iterationType).build();
result = queryEngine.execute(query, Target.of().partitionOwner(partitionId).build());
} else {
Query query = Query.of().mapName(getName()).predicate(predicate).iterationType(iterationType).build();
result = queryEngine.execute(query, Target.ALL_NODES);
}
return QueryResultUtils.transformToSet(serializationService, result, predicate, iterationType, uniqueResult);
}
Aggregations