use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.
the class QueryIndexTest method testPredicateNotEqualWithIndex.
@Test(timeout = 1000 * 60)
public void testPredicateNotEqualWithIndex() {
HazelcastInstance instance = createTestHazelcastInstance();
IMap<Integer, Value> map1 = instance.getMap("testPredicateNotEqualWithIndex-ordered");
IMap<Integer, Value> map2 = instance.getMap("testPredicateNotEqualWithIndex-unordered");
testPredicateNotEqualWithIndex(map1, true);
testPredicateNotEqualWithIndex(map2, false);
}
use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.
the class QueryIndexTest method testQueryDoesNotMatchOldResults_whenEntriesAreUpdated.
@Test(timeout = 1000 * 60)
public void testQueryDoesNotMatchOldResults_whenEntriesAreUpdated() {
HazelcastInstance instance = createTestHazelcastInstance();
IMap<String, SampleTestObjects.Value> map = instance.getMap("default");
map.addIndex(IndexType.SORTED, "name");
map.put("0", new Value("name"));
map.put("0", new Value("newName"));
Collection<SampleTestObjects.Value> values = map.values(Predicates.sql("name='name'"));
assertEquals(0, values.size());
}
use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.
the class QueryIndexTest method issue685RemoveIndexesOnClear.
@Test(timeout = 1000 * 60)
public void issue685RemoveIndexesOnClear() {
HazelcastInstance instance = createTestHazelcastInstance();
IMap<String, SampleTestObjects.Value> map = instance.getMap("default");
map.addIndex(IndexType.SORTED, "name");
for (int i = 0; i < 4; i++) {
Value v = new Value("name" + i);
map.put("" + i, v);
}
map.clear();
Predicate predicate = Predicates.sql("name='name0'");
Collection<SampleTestObjects.Value> values = map.values(predicate);
assertEquals(0, values.size());
}
use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.
the class QueryIndexTest method testPredicateNotEqualWithIndex.
private void testPredicateNotEqualWithIndex(IMap<Integer, Value> map, boolean ordered) {
map.addIndex(ordered ? IndexType.SORTED : IndexType.HASH, "name");
map.put(1, new Value("abc", 1));
map.put(2, new Value("xyz", 2));
map.put(3, new Value("aaa", 3));
assertEquals(3, map.values(Predicates.sql("name != 'aac'")).size());
assertEquals(2, map.values(Predicates.sql("index != 2")).size());
assertEquals(3, map.values(Predicates.sql("name <> 'aac'")).size());
assertEquals(2, map.values(Predicates.sql("index <> 2")).size());
assertEquals(3, map.values(Predicates.newPredicateBuilder().getEntryObject().get("name").notEqual("aac")).size());
assertEquals(2, map.values(Predicates.newPredicateBuilder().getEntryObject().get("index").notEqual(2)).size());
}
use of com.hazelcast.query.SampleTestObjects.Value in project hazelcast by hazelcast.
the class QueryBasicTest method testPredicateStringAttribute.
private void testPredicateStringAttribute(IMap<Integer, Value> map) {
map.put(1, new Value("abc"));
map.put(2, new Value("xyz"));
map.put(3, new Value("aaa"));
map.put(4, new Value("zzz"));
map.put(5, new Value("klm"));
map.put(6, new Value("prs"));
map.put(7, new Value("prs"));
map.put(8, new Value("def"));
map.put(9, new Value("qwx"));
assertEquals(8, map.values(Predicates.sql("name > 'aac'")).size());
assertEquals(9, map.values(Predicates.sql("name between 'aaa' and 'zzz'")).size());
assertEquals(7, map.values(Predicates.sql("name < 't'")).size());
assertEquals(6, map.values(Predicates.sql("name >= 'gh'")).size());
assertEquals(8, map.values(Predicates.newPredicateBuilder().getEntryObject().get("name").greaterThan("aac")).size());
assertEquals(9, map.values(Predicates.newPredicateBuilder().getEntryObject().get("name").between("aaa", "zzz")).size());
assertEquals(7, map.values(Predicates.newPredicateBuilder().getEntryObject().get("name").lessThan("t")).size());
assertEquals(6, map.values(Predicates.newPredicateBuilder().getEntryObject().get("name").greaterEqual("gh")).size());
}
Aggregations