use of com.hazelcast.query.SqlPredicate 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.query.SqlPredicate 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.query.SqlPredicate in project hazelcast by hazelcast.
the class NestedPredicateWithExtractorTest method singleAttributeQuery_distributedSql.
@Test
public void singleAttributeQuery_distributedSql() throws Exception {
// GIVEN
map.put(1, new Body("body1", new Limb("hand")));
map.put(2, new Body("body2", new Limb("leg")));
// WHEN
Collection<Body> values = map.values(new SqlPredicate("name == 'body1'"));
// THEN
assertEquals(1, values.size());
assertEquals("body1", values.toArray(new Body[values.size()])[0].getName());
assertEquals(2 + 1, bodyExtractorExecutions);
assertEquals(0, limbExtractorExecutions);
}
use of com.hazelcast.query.SqlPredicate in project hazelcast by hazelcast.
the class NestedPredicateTest method singleAttributeQuery_distributedSql.
@Test
public void singleAttributeQuery_distributedSql() throws Exception {
// GIVEN
map.put(1, new Body("body1", new Limb("hand")));
map.put(2, new Body("body2", new Limb("leg")));
// WHEN
Collection<Body> values = map.values(new SqlPredicate("name == 'body1'"));
// THEN
assertEquals(1, values.size());
assertEquals("body1", values.toArray(new Body[values.size()])[0].getName());
}
use of com.hazelcast.query.SqlPredicate in project ddf by codice.
the class HazelcastNotificationStore method getNotifications.
@Override
public List<Map<String, String>> getNotifications(String userId) {
List<Map<String, String>> notificationsList = new ArrayList<Map<String, String>>();
if (StringUtils.isNotBlank(userId)) {
Collection<Object> notifications = notificationsCache.values(new SqlPredicate("userId = '" + userId + "'"));
for (Object notificationObj : notifications) {
@SuppressWarnings("unchecked") Map<String, String> notificationMap = (Map<String, String>) notificationObj;
notificationsList.add(notificationMap);
}
}
return notificationsList;
}
Aggregations