Search in sources :

Example 1 with ObjectWithOptional

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());
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) IndexConfig(com.hazelcast.config.IndexConfig) ObjectWithOptional(com.hazelcast.query.SampleTestObjects.ObjectWithOptional) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with ObjectWithOptional

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());
}
Also used : IndexConfig(com.hazelcast.config.IndexConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) IndexConfig(com.hazelcast.config.IndexConfig) ObjectWithOptional(com.hazelcast.query.SampleTestObjects.ObjectWithOptional) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with ObjectWithOptional

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) IndexConfig(com.hazelcast.config.IndexConfig) ObjectWithOptional(com.hazelcast.query.SampleTestObjects.ObjectWithOptional) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

Config (com.hazelcast.config.Config)3 IndexConfig (com.hazelcast.config.IndexConfig)3 MapConfig (com.hazelcast.config.MapConfig)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 ObjectWithOptional (com.hazelcast.query.SampleTestObjects.ObjectWithOptional)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3