use of com.hazelcast.mapreduce.helpers.Employee in project hazelcast by hazelcast.
the class QueryCacheMethodsWithPredicateTest method testKeySet_onIndexedField_afterRemovalOfSomeIndexes.
@Test
public void testKeySet_onIndexedField_afterRemovalOfSomeIndexes() {
int count = 111;
String cacheName = randomString();
populateMap(map, count);
QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, true);
cache.addIndex("id", true);
populateMap(map, 17, count);
// just choose arbitrary numbers to prove whether #keySet with predicate is working
int smallerThan = 17;
int expectedSize = 17;
assertKeySetSizeEventually(expectedSize, new SqlPredicate("id < " + smallerThan), cache);
}
use of com.hazelcast.mapreduce.helpers.Employee in project hazelcast by hazelcast.
the class QueryCacheMethodsWithPredicateTest method testValues_withoutIndex_whenIncludeValueFalse.
@Test
public void testValues_withoutIndex_whenIncludeValueFalse() {
int count = 111;
String cacheName = randomString();
populateMap(map, count);
QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, false);
removeEntriesFromMap(map, 17, count);
// just choose arbitrary numbers to prove whether #entrySet with predicate is working
int smallerThan = 17;
int expectedSize = 0;
assertValuesSizeEventually(expectedSize, new SqlPredicate("__key < " + smallerThan), cache);
}
use of com.hazelcast.mapreduce.helpers.Employee in project hazelcast by hazelcast.
the class QueryCacheListenerTest method listen_withPredicate_afterQueryCacheCreation.
@Test
public void listen_withPredicate_afterQueryCacheCreation() {
String cacheName = randomString();
CountDownLatch numberOfCaughtEvents = new CountDownLatch(10);
QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, true);
cache.addEntryListener(new QueryCacheAdditionListener(numberOfCaughtEvents), SQL_PREDICATE_GT, true);
int count = 111;
populateMap(map, count);
assertOpenEventually(numberOfCaughtEvents, 10);
}
use of com.hazelcast.mapreduce.helpers.Employee in project hazelcast by hazelcast.
the class QueryCacheListenerTest method listenKey_withMultipleListeners_afterQueryCacheCreation.
@Test
public void listenKey_withMultipleListeners_afterQueryCacheCreation() {
int keyToListen = 109;
String cacheName = randomString();
CountDownLatch additionCount = new CountDownLatch(2);
CountDownLatch removalCount = new CountDownLatch(2);
final QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, true);
cache.addEntryListener(new QueryCacheAdditionListener(additionCount), SQL_PREDICATE_GT, keyToListen, true);
cache.addEntryListener(new QueryCacheRemovalListener(removalCount), SQL_PREDICATE_GT, keyToListen, true);
int count = 111;
populateMap(map, count);
removeEntriesFromMap(map, 0, count);
populateMap(map, count);
removeEntriesFromMap(map, 0, count);
AssertTask task = new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(0, cache.size());
}
};
assertTrueEventually(task);
assertOpenEventually(cache.size() + "", additionCount, 10);
assertOpenEventually(cache.size() + "", removalCount, 10);
}
use of com.hazelcast.mapreduce.helpers.Employee in project hazelcast by hazelcast.
the class QueryCacheMethodsWithPredicateTest method testKeySet_onIndexedField.
@Test
public void testKeySet_onIndexedField() {
int count = 111;
populateMap(map, count);
String cacheName = randomString();
QueryCache<Integer, Employee> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, true);
cache.addIndex("id", 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("id >= " + equalsOrBiggerThan), cache);
}
Aggregations