use of com.hazelcast.query.PredicateBuilder.EntryObject in project hazelcast by hazelcast.
the class QueryIndexingTest method setUp.
@Before
public void setUp() {
employees = newEmployees(count);
nodeFactory = createHazelcastInstanceFactory(2);
Config config = newConfig();
h1 = nodeFactory.newHazelcastInstance(config);
h2 = nodeFactory.newHazelcastInstance(config);
EntryObject entryObject = Predicates.newPredicateBuilder().getEntryObject();
predicate = entryObject.get("name").equal(null).and(entryObject.get("city").isNull());
assertClusterSizeEventually(2, h1);
}
use of com.hazelcast.query.PredicateBuilder.EntryObject in project hazelcast by hazelcast.
the class QueryIndexTest method testResultsReturned_whenCustomAttributeIndexed.
@Test
public void testResultsReturned_whenCustomAttributeIndexed() {
HazelcastInstance h1 = createTestHazelcastInstance();
IMap<String, CustomObject> imap = h1.getMap("objects");
imap.addIndex(IndexType.SORTED, "attribute");
for (int i = 0; i < 10; i++) {
CustomAttribute attr = new CustomAttribute(i, 200);
CustomObject object = new CustomObject("o" + i, randomUUID(), attr);
imap.put(object.getName(), object);
}
EntryObject entry = Predicates.newPredicateBuilder().getEntryObject();
Predicate predicate = entry.get("attribute").greaterEqual(new CustomAttribute(5, 200));
Collection<CustomObject> values = imap.values(predicate);
assertEquals(5, values.size());
}
use of com.hazelcast.query.PredicateBuilder.EntryObject in project hazelcast by hazelcast.
the class EntryProcessorBouncingNodesTest method testEntryProcessorWhileTwoNodesAreBouncing.
@Test
public void testEntryProcessorWhileTwoNodesAreBouncing() {
// now, with nodes joining and leaving the cluster concurrently, start adding numbers to the lists
final ListHolder expected = new ListHolder();
int iteration = 0;
HazelcastInstance steadyMember = bounceMemberRule.getSteadyMember();
final IMap<Integer, ListHolder> map = steadyMember.getMap(MAP_NAME);
while (iteration < ITERATIONS) {
IncrementProcessor processor = new IncrementProcessor(iteration);
expected.add(iteration);
for (int i = 0; i < ENTRIES; ++i) {
if (withPredicate) {
EntryObject eo = Predicates.newPredicateBuilder().getEntryObject();
Predicate keyPredicate = eo.key().equal(i);
map.executeOnEntries(processor, keyPredicate);
} else {
map.executeOnKey(i, processor);
}
}
++iteration;
}
for (int i = 0; i < ENTRIES; i++) {
final int index = i;
assertTrueEventually(() -> {
ListHolder holder = map.get(index);
String errorText = String.format("Each ListHolder should contain %d entries.\nInvalid list holder content:\n%s\n", ITERATIONS, holder.toString());
assertEquals(errorText, ITERATIONS, holder.size());
for (int it = 0; it < ITERATIONS; it++) {
assertEquals(it, holder.get(it));
}
});
}
}
use of com.hazelcast.query.PredicateBuilder.EntryObject in project hazelcast by hazelcast.
the class NestedPredicateWithExtractorTest method singleAttributeQuery_predicates.
@Test
public void singleAttributeQuery_predicates() {
// GIVEN
map.put(1, new Body("body1", new Limb("hand")));
map.put(2, new Body("body2", new Limb("leg")));
// WHEN
EntryObject e = Predicates.newPredicateBuilder().getEntryObject();
Predicate predicate = e.get("name").equal("body1");
Collection<Body> values = map.values(predicate);
// THEN
assertEquals(1, values.size());
assertEquals("body1", values.toArray(new Body[0])[0].getName());
assertEquals(2, bodyExtractorExecutions);
assertEquals(0, limbExtractorExecutions);
}
use of com.hazelcast.query.PredicateBuilder.EntryObject in project hazelcast by hazelcast.
the class NestedPredicateTest method singleAttributeQuery_predicates.
@Test
public void singleAttributeQuery_predicates() {
// GIVEN
map.put(1, new Body("body1", new Limb("hand")));
map.put(2, new Body("body2", new Limb("leg")));
// WHEN
EntryObject e = Predicates.newPredicateBuilder().getEntryObject();
Predicate predicate = e.get("name").equal("body1");
Collection<Body> values = map.values(predicate);
// THEN
assertEquals(1, values.size());
assertEquals("body1", values.toArray(new Body[0])[0].getName());
}
Aggregations