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;
}
use of com.hazelcast.query.SqlPredicate 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.query.SqlPredicate 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.query.SqlPredicate in project hazelcast by hazelcast.
the class MapTransactionRegressionTest method test_Issue615_ValuesWithPredicate.
@Test
public void test_Issue615_ValuesWithPredicate() throws TransactionException {
Config config = getConfig();
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
final HazelcastInstance h1 = factory.newHazelcastInstance(config);
final HazelcastInstance h2 = factory.newHazelcastInstance(config);
final IMap map2 = h2.getMap("default");
final SampleObjects.Employee emp1 = new SampleObjects.Employee("abc-123-xvz", 34, true, 10D);
map2.put(1, emp1);
final SampleObjects.Employee emp2 = new SampleObjects.Employee("xvz", 4, true, 10D);
boolean b = h1.executeTransaction(options, new TransactionalTask<Boolean>() {
public Boolean execute(TransactionalTaskContext context) throws TransactionException {
final TransactionalMap<Object, Object> txMap = context.getMap("default");
assertEquals(0, txMap.values(new SqlPredicate("age <= 10")).size());
txMap.put(2, emp2);
Collection coll = txMap.values(new SqlPredicate("age <= 10"));
Iterator<Object> iterator = coll.iterator();
while (iterator.hasNext()) {
final SampleObjects.Employee e = (SampleObjects.Employee) iterator.next();
assertEquals(emp2, e);
}
coll = txMap.values(new SqlPredicate("age > 30 "));
iterator = coll.iterator();
while (iterator.hasNext()) {
final SampleObjects.Employee e = (SampleObjects.Employee) iterator.next();
assertEquals(emp1, e);
}
txMap.remove(2);
coll = txMap.values(new SqlPredicate("age <= 10 "));
assertEquals(0, coll.size());
return true;
}
});
assertEquals(0, map2.values(new SqlPredicate("age <= 10")).size());
assertEquals(1, map2.values(new SqlPredicate("age = 34")).size());
h1.shutdown();
h2.shutdown();
}
use of com.hazelcast.query.SqlPredicate in project hazelcast by hazelcast.
the class MapTransactionTest method testValuesWithPredicate_removingExistentEntry.
@Test
public void testValuesWithPredicate_removingExistentEntry() throws TransactionException {
final int nodeCount = 1;
final String mapName = randomMapName("_testValuesWithPredicate_removingExistentEntry_");
final Config config = getConfig();
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
final HazelcastInstance node = factory.newHazelcastInstance(config);
final IMap map = node.getMap(mapName);
final Employee emp = new Employee("name", 77, true, 10D);
map.put(1, emp);
node.executeTransaction(options, new TransactionalTask<Boolean>() {
public Boolean execute(TransactionalTaskContext context) throws TransactionException {
final TransactionalMap<Object, Object> txMap = context.getMap(mapName);
txMap.remove(1);
Collection<Object> coll = txMap.values(new SqlPredicate("age > 70 "));
assertEquals(0, coll.size());
return true;
}
});
node.shutdown();
}
Aggregations