use of com.hazelcast.query.SqlPredicate in project hazelcast-simulator by hazelcast.
the class PagingPredicateTest method setUp.
@Setup
public void setUp() {
map = targetInstance.getMap(name);
innerPredicate = new SqlPredicate(innerPredicateQuery);
}
use of com.hazelcast.query.SqlPredicate in project hazelcast-simulator by hazelcast.
the class MapGetVsQueryTest method sqlString.
@TimeStep(prob = 0)
public void sqlString(ThreadState state) {
int id = state.randomInt(itemCount);
SqlPredicate predicate = new SqlPredicate("id=" + id);
map.values(predicate);
}
use of com.hazelcast.query.SqlPredicate in project jnosql-diana-driver by eclipse.
the class DefaultHazelcastBucketManager method query.
@Override
public Collection<Value> query(String query, Map<String, Object> params) throws NullPointerException {
requireNonNull(query, "query is required");
requireNonNull(params, "params is required");
final StringBuilder finalQuery = new StringBuilder(query);
final Consumer<Map.Entry<String, Object>> consumer = e -> {
String key = ":" + e.getKey();
int indexOf = query.indexOf(key);
finalQuery.replace(indexOf, indexOf + key.length(), e.getValue().toString());
};
params.entrySet().forEach(consumer);
return query(new SqlPredicate(finalQuery.toString()));
}
use of com.hazelcast.query.SqlPredicate in project hazelcast by hazelcast.
the class ClientQueryCacheRecoveryUponEventLossTest method testForceConsistency.
@Test
public void testForceConsistency() {
String mapName = randomMapName("map");
String queryCacheName = randomMapName("cache");
Config config = new Config();
config.setProperty(PARTITION_COUNT.getName(), "1");
factory.newHazelcastInstance(config);
QueryCacheConfig queryCacheConfig = new QueryCacheConfig(queryCacheName);
queryCacheConfig.setBatchSize(1111);
queryCacheConfig.setDelaySeconds(3);
ClientConfig clientConfig = new ClientConfig();
clientConfig.addQueryCacheConfig(mapName, queryCacheConfig);
HazelcastInstance client = factory.newHazelcastClient(clientConfig);
IMap<Integer, Integer> map = client.getMap(mapName);
// set test sequencer to subscriber
int count = 30;
setTestSequencer(map, 9);
final QueryCache queryCache = map.getQueryCache(queryCacheName, new SqlPredicate("this > 20"), true);
queryCache.addEntryListener(new EventLostListener() {
@Override
public void eventLost(EventLostEvent event) {
queryCache.tryRecover();
}
}, false);
for (int i = 0; i < count; i++) {
map.put(i, i);
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(9, queryCache.size());
}
});
}
use of com.hazelcast.query.SqlPredicate in project hazelcast by hazelcast.
the class ClientQueryCacheTest method testQueryCache.
private void testQueryCache(boolean includeValue) {
String mapName = randomString();
String queryCacheName = randomString();
HazelcastInstance client = factory.newHazelcastClient();
IMap<Integer, Integer> map = client.getMap(mapName);
for (int i = 0; i < 50; i++) {
map.put(i, i);
}
Predicate<Integer, Integer> predicate = new SqlPredicate("this > 5 AND this < 100");
QueryCache<Integer, Integer> cache = map.getQueryCache(queryCacheName, predicate, includeValue);
for (int i = 50; i < 100; i++) {
map.put(i, i);
}
int expected = 94;
assertQueryCacheSize(expected, cache);
}
Aggregations