use of com.hazelcast.query.PredicateBuilder.EntryObject in project hazelcast by hazelcast.
the class IndexesTest method testAndWithSingleEntry.
@Test
public void testAndWithSingleEntry() {
Indexes indexes = Indexes.newBuilder(serializationService, copyBehavior, DEFAULT_IN_MEMORY_FORMAT).build();
indexes.addOrGetIndex(IndexUtils.createTestIndexConfig(IndexType.HASH, "name"));
indexes.addOrGetIndex(IndexUtils.createTestIndexConfig(IndexType.SORTED, "age"));
indexes.addOrGetIndex(IndexUtils.createTestIndexConfig(IndexType.SORTED, "salary"));
for (int i = 0; i < 100; i++) {
Employee employee = new Employee(i + "Name", i % 80, (i % 2 == 0), 100 + (i % 1000));
indexes.putEntry(new QueryEntry(serializationService, toData(i), employee, newExtractor()), null, Index.OperationSource.USER);
}
int count = 10;
Set<String> ages = new HashSet<>(count);
for (int i = 0; i < count; i++) {
ages.add(String.valueOf(i));
}
EntryObject entryObject = Predicates.newPredicateBuilder().getEntryObject();
PredicateBuilder predicate = entryObject.get("name").equal("0Name").and(entryObject.get("age").in(ages.toArray(new String[0])));
assertEquals(1, size(indexes.query(predicate, SKIP_PARTITIONS_COUNT_CHECK)));
}
use of com.hazelcast.query.PredicateBuilder.EntryObject in project hazelcast by hazelcast.
the class PredicateBuilderTest method get_key.
@Test
public void get_key() {
HazelcastInstance hz = createHazelcastInstance();
EntryObject entryObject = Predicates.newPredicateBuilder().getEntryObject();
Predicate predicate = entryObject.key().equal(10L);
IMap<Integer, Integer> hazelcastLookupMap = hz.getMap("someMap");
hazelcastLookupMap.put(10, 1);
hazelcastLookupMap.put(30, 2);
Collection<Integer> result = hazelcastLookupMap.values(predicate);
assertEquals(1, result.size());
assertContains(result, 1);
}
use of com.hazelcast.query.PredicateBuilder.EntryObject in project hazelcast by hazelcast.
the class PredicateBuilderTest method get_keyAttribute.
@Test
public void get_keyAttribute() {
HazelcastInstance hz = createHazelcastInstance();
EntryObject entryObject = Predicates.newPredicateBuilder().getEntryObject();
Predicate predicate = entryObject.key().get("id").equal("10").and(entryObject.get("name").equal("value1"));
IMap<Id, Value> hazelcastLookupMap = hz.getMap("someMap");
hazelcastLookupMap.put(new Id("10"), new Value("value1"));
hazelcastLookupMap.put(new Id("20"), new Value("value2"));
hazelcastLookupMap.put(new Id("30"), new Value("value3"));
Collection<Value> result = hazelcastLookupMap.values(predicate);
assertEquals(1, result.size());
assertContains(result, new Value("value1"));
}
use of com.hazelcast.query.PredicateBuilder.EntryObject in project hazelcast by hazelcast.
the class PredicateBuilderTest method get_this.
@Test
public void get_this() {
HazelcastInstance hz = createHazelcastInstance();
EntryObject entryObject = Predicates.newPredicateBuilder().getEntryObject();
Predicate predicate = entryObject.get("this").equal(1L);
IMap<Integer, Integer> hazelcastLookupMap = hz.getMap("someMap");
hazelcastLookupMap.put(10, 1);
hazelcastLookupMap.put(30, 2);
Collection<Integer> result = hazelcastLookupMap.values(predicate);
assertEquals(1, result.size());
assertContains(result, 1);
}
Aggregations