use of com.hazelcast.mapreduce.helpers.Employee in project hazelcast by hazelcast.
the class QueryCacheListenerTest method listenKey_withPredicate_afterQueryCacheCreation.
@Test
public void listenKey_withPredicate_afterQueryCacheCreation() {
int keyToListen = 109;
String cacheName = randomString();
CountDownLatch numberOfCaughtEvents = new CountDownLatch(1);
QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, true);
cache.addEntryListener(new QueryCacheAdditionListener(numberOfCaughtEvents), SQL_PREDICATE_GT, keyToListen, true);
int count = 111;
populateMap(map, count);
assertOpenEventually(numberOfCaughtEvents, 10);
}
use of com.hazelcast.mapreduce.helpers.Employee in project hazelcast by hazelcast.
the class QueryCacheMethodsWithPredicateTest method testEntrySet_withIndexedKeys_whenIncludeValueFalse.
@Test
public void testEntrySet_withIndexedKeys_whenIncludeValueFalse() {
int count = 111;
String cacheName = randomString();
populateMap(map, count);
QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, false);
// here adding key index. (key --> integer; value --> Employee)
cache.addIndex("__key", true);
removeEntriesFromMap(map, 17, count);
// just choose arbitrary numbers to prove whether #entrySet with predicate is working
int smallerThan = 17;
int expectedSize = 17;
assertEntrySetSizeEventually(expectedSize, new SqlPredicate("__key < " + smallerThan), cache);
}
use of com.hazelcast.mapreduce.helpers.Employee in project hazelcast by hazelcast.
the class QueryCacheMethodsWithPredicateTest method testKeySet_onIndexedField_whenIncludeValueFalse.
@Test
public void testKeySet_onIndexedField_whenIncludeValueFalse() {
int count = 111;
String cacheName = randomString();
populateMap(map, count);
QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, false);
cache.addIndex("__key", true);
populateMap(map, count, 2 * count);
// 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, new SqlPredicate("__key >= " + equalsOrBiggerThan), cache);
}
use of com.hazelcast.mapreduce.helpers.Employee in project hazelcast by hazelcast.
the class QueryCacheMethodsWithPredicateTest method testValues_withoutIndex.
@Test
public void testValues_withoutIndex() {
int count = 111;
String cacheName = randomString();
populateMap(map, count);
QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, true);
removeEntriesFromMap(map, 17, count);
// just choose arbitrary numbers to prove whether #entrySet with predicate is working
int smallerThan = 17;
int expectedSize = 17;
assertValuesSizeEventually(expectedSize, new SqlPredicate("__key < " + smallerThan), cache);
}
use of com.hazelcast.mapreduce.helpers.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, new SqlPredicate("__key < " + smallerThan), cache);
}
Aggregations