use of com.hazelcast.map.impl.querycache.utils.Employee in project hazelcast by hazelcast.
the class ClientQueryCacheIndexTest method test_values_withoutIndex_whenValuesCached.
@Test
public void test_values_withoutIndex_whenValuesCached() {
String mapName = randomString();
String cacheName = randomString();
HazelcastInstance client = factory.newHazelcastClient();
IMap<Integer, Employee> map = client.getMap(mapName);
int putCount = 111;
for (int i = 0; i < putCount; i++) {
map.put(i, new Employee(i));
}
QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, true);
for (int i = 17; i < putCount; i++) {
map.remove(i);
}
// just choose arbitrary numbers to prove whether #entrySet with predicate is working
int smallerThan = 17;
int expectedSize = 17;
assertValuesSizeEventually(expectedSize, Predicates.sql("__key < " + smallerThan), cache);
}
use of com.hazelcast.map.impl.querycache.utils.Employee in project hazelcast by hazelcast.
the class ClientQueryCacheIndexTest method test_keySet_withPredicate.
@Test
public void test_keySet_withPredicate() {
String mapName = randomString();
String cacheName = randomString();
HazelcastInstance client = factory.newHazelcastClient();
IMap<Integer, Employee> map = client.getMap(mapName);
// populate map before construction of query cache.
final int putCount = 111;
for (int i = 0; i < putCount; i++) {
map.put(i, new Employee(i));
}
final QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, true);
cache.addIndex(IndexType.SORTED, "id");
// populate map after construction of query cache
for (int i = putCount; i < 2 * putCount; i++) {
map.put(i, new Employee(i));
}
// just choose arbitrary numbers for querying in order to prove whether #keySet with predicate is correctly working
int equalsOrBiggerThan = 27;
int expectedSize = 2 * putCount - equalsOrBiggerThan;
assertKeySetSizeEventually(expectedSize, Predicates.sql("id >= " + equalsOrBiggerThan), cache);
}
use of com.hazelcast.map.impl.querycache.utils.Employee in project hazelcast by hazelcast.
the class ClientQueryCacheMethodsWithPredicateTest method test_values_withoutIndex_whenIncludeValueFalse.
@Test
public void test_values_withoutIndex_whenIncludeValueFalse() {
String mapName = randomString();
String cacheName = randomString();
HazelcastInstance instance = getInstance();
IMap<Integer, Employee> map = instance.getMap(mapName);
int count = 111;
for (int i = 0; i < count; i++) {
map.put(i, new Employee(i));
}
QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, false);
for (int i = 17; i < count; i++) {
map.remove(i);
}
// just choose arbitrary numbers to prove whether #entrySet with predicate is working
int smallerThan = 17;
int expectedSize = 0;
assertValuesSizeEventually(expectedSize, Predicates.sql("__key < " + smallerThan), cache);
}
use of com.hazelcast.map.impl.querycache.utils.Employee in project hazelcast by hazelcast.
the class ClientQueryCacheMethodsWithPredicateTest method test_keySet_onRemovedIndexes.
@Test
public void test_keySet_onRemovedIndexes() {
String mapName = randomString();
String cacheName = randomString();
HazelcastInstance instance = getInstance();
IMap<Integer, Employee> map = instance.getMap(mapName);
int count = 111;
for (int i = 0; i < count; i++) {
map.put(i, new Employee(i));
}
QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, true);
cache.addIndex(IndexType.SORTED, "id");
for (int i = 17; i < count; i++) {
map.remove(i);
}
// just choose arbitrary numbers to prove whether #keySet with predicate is working
int smallerThan = 17;
int expectedSize = 17;
assertKeySetSizeEventually(expectedSize, Predicates.sql("id < " + smallerThan), cache);
}
use of com.hazelcast.map.impl.querycache.utils.Employee in project hazelcast by hazelcast.
the class ClientQueryCacheMethodsWithPredicateTest method test_keySet_whenIncludeValueFalse.
@Test
public void test_keySet_whenIncludeValueFalse() {
String mapName = randomString();
String cacheName = randomString();
HazelcastInstance instance = getInstance();
IMap<Integer, Employee> map = instance.getMap(mapName);
// populate map before construction of query cache
int count = 111;
for (int i = 0; i < count; i++) {
map.put(i, new Employee(i));
}
QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, false);
cache.addIndex(IndexType.SORTED, "__key");
// populate map after construction of query cache
for (int i = count; i < 2 * count; i++) {
map.put(i, new Employee(i));
}
// just choose arbitrary numbers for querying in order to prove whether #keySet with predicate is correctly working
int equalsOrBiggerThan = 27;
int expectedSize = 2 * count - equalsOrBiggerThan;
assertKeySetSizeEventually(expectedSize, Predicates.sql("__key >= " + equalsOrBiggerThan), cache);
}
Aggregations