use of com.hazelcast.query.EntryObject in project hazelcast by hazelcast.
the class QueryIndexTest method testResultsReturned_whenCustomAttributeIndexed.
@Test
public void testResultsReturned_whenCustomAttributeIndexed() {
HazelcastInstance h1 = createHazelcastInstance();
IMap<String, CustomObject> imap = h1.getMap("objects");
imap.addIndex("attribute", true);
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 = new PredicateBuilder().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.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 = new PredicateBuilder().getEntryObject();
predicate = entryObject.get("name").equal(null).and(entryObject.get("city").isNull());
assertClusterSizeEventually(2, h1);
}
use of com.hazelcast.query.EntryObject in project hazelcast by hazelcast.
the class NestedPredicateTest method nestedAttributeQuery_predicates.
@Test
public void nestedAttributeQuery_predicates() throws Exception {
// GIVEN
map.put(1, new Body("body1", new Limb("hand")));
map.put(2, new Body("body2", new Limb("leg")));
// WHEN
EntryObject e = new PredicateBuilder().getEntryObject();
Predicate predicate = e.get("limb.name").equal("leg");
Collection<Body> values = map.values(predicate);
// THEN
assertEquals(1, values.size());
assertEquals("body2", values.toArray(new Body[values.size()])[0].getName());
}
use of com.hazelcast.query.EntryObject in project hazelcast by hazelcast.
the class NestedPredicateTest method singleAttributeQuery_predicates.
@Test
public void singleAttributeQuery_predicates() throws Exception {
// GIVEN
map.put(1, new Body("body1", new Limb("hand")));
map.put(2, new Body("body2", new Limb("leg")));
// WHEN
EntryObject e = new PredicateBuilder().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[values.size()])[0].getName());
}
use of com.hazelcast.query.EntryObject in project hazelcast by hazelcast.
the class NestedPredicateWithExtractorTest method singleAttributeQuery_predicates.
@Test
public void singleAttributeQuery_predicates() throws Exception {
// GIVEN
map.put(1, new Body("body1", new Limb("hand")));
map.put(2, new Body("body2", new Limb("leg")));
// WHEN
EntryObject e = new PredicateBuilder().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[values.size()])[0].getName());
assertEquals(2 + 1, bodyExtractorExecutions);
assertEquals(0, limbExtractorExecutions);
}
Aggregations