use of com.hazelcast.query.SampleTestObjects.ObjectWithOptional in project hazelcast by hazelcast.
the class QueryBasicTest method testOptionalOrderedIndexQuerying.
@Test
public void testOptionalOrderedIndexQuerying() {
String name = randomMapName();
Config config = smallInstanceConfig();
config.getMapConfig(name).addIndexConfig(new IndexConfig(IndexType.SORTED, "attribute"));
HazelcastInstance instance = createHazelcastInstance(config);
IMap<Integer, ObjectWithOptional<Integer>> map = instance.getMap(name);
for (int i = 0; i < 10; ++i) {
map.put(i, new ObjectWithOptional<>(i % 2 == 0 ? i : null));
}
Set<Integer> result = map.keySet(Predicates.equal("attribute", null));
assertEqualSets(result, 1, 3, 5, 7, 9);
assertEquals(1, map.getLocalMapStats().getIndexedQueryCount());
result = map.keySet(Predicates.notEqual("attribute", null));
assertEqualSets(result, 0, 2, 4, 6, 8);
assertEquals(1, map.getLocalMapStats().getIndexedQueryCount());
result = map.keySet(Predicates.greaterThan("attribute", 4));
assertEqualSets(result, 6, 8);
assertEquals(2, map.getLocalMapStats().getIndexedQueryCount());
}
use of com.hazelcast.query.SampleTestObjects.ObjectWithOptional in project hazelcast by hazelcast.
the class QueryBasicTest method testOptionalUnorderedIndexQuerying.
@Test
public void testOptionalUnorderedIndexQuerying() {
String name = randomMapName();
Config config = smallInstanceConfig();
config.getMapConfig(name).addIndexConfig(new IndexConfig(IndexType.HASH, "attribute"));
HazelcastInstance instance = createHazelcastInstance(config);
IMap<Integer, ObjectWithOptional<Integer>> map = instance.getMap(name);
for (int i = 0; i < 10; ++i) {
map.put(i, new ObjectWithOptional<>(i % 2 == 0 ? i : null));
}
Set<Integer> result = map.keySet(Predicates.equal("attribute", null));
assertEqualSets(result, 1, 3, 5, 7, 9);
assertEquals(1, map.getLocalMapStats().getIndexedQueryCount());
result = map.keySet(Predicates.notEqual("attribute", null));
assertEqualSets(result, 0, 2, 4, 6, 8);
assertEquals(1, map.getLocalMapStats().getIndexedQueryCount());
result = map.keySet(Predicates.greaterThan("attribute", 4));
assertEqualSets(result, 6, 8);
assertEquals(2, map.getLocalMapStats().getIndexedQueryCount());
}
use of com.hazelcast.query.SampleTestObjects.ObjectWithOptional in project hazelcast by hazelcast.
the class QueryBasicTest method testOptionalFullScanQuerying.
@Test
public void testOptionalFullScanQuerying() {
String name = randomMapName();
Config config = smallInstanceConfig();
HazelcastInstance instance = createHazelcastInstance(config);
IMap<Integer, ObjectWithOptional<Integer>> map = instance.getMap(name);
for (int i = 0; i < 10; ++i) {
map.put(i, new ObjectWithOptional<>(i % 2 == 0 ? i : null));
}
Set<Integer> result = map.keySet(Predicates.equal("attribute", null));
assertEqualSets(result, 1, 3, 5, 7, 9);
result = map.keySet(Predicates.notEqual("attribute", null));
assertEqualSets(result, 0, 2, 4, 6, 8);
result = map.keySet(Predicates.greaterThan("attribute", 4));
assertEqualSets(result, 6, 8);
}
Aggregations