本文整理汇总了Java中org.apache.ignite.cache.query.ScanQuery.setFilter方法的典型用法代码示例。如果您正苦于以下问题:Java ScanQuery.setFilter方法的具体用法?Java ScanQuery.setFilter怎么用?Java ScanQuery.setFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.cache.query.ScanQuery
的用法示例。
在下文中一共展示了ScanQuery.setFilter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.apache.ignite.cache.query.ScanQuery; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void run() {
IgniteCache cache = node.cache(cacheName);
// Getting a list of the partitions owned by this node.
List<Integer> myPartitions = cachePart.get(node.cluster().localNode().id());
for (Integer part : myPartitions) {
ScanQuery scanQry = new ScanQuery();
scanQry.setPartition(part);
scanQry.setFilter(igniteBiPred);
try (QueryCursor cursor = cache.query(scanQry)) {
for (Object obj : cursor) {
// No-op.
}
}
}
}
示例2: scanQueryReconnectInProgress
import org.apache.ignite.cache.query.ScanQuery; //导入方法依赖的package包/类
/**
* @param setPart If {@code true} sets partition for scan query.
* @throws Exception If failed.
*/
private void scanQueryReconnectInProgress(boolean setPart) throws Exception {
Ignite cln = grid(serverCount());
assertTrue(cln.cluster().localNode().isClient());
final Ignite srv = clientRouter(cln);
final IgniteCache<Integer, Person> clnCache = cln.getOrCreateCache(QUERY_CACHE);
clnCache.put(1, new Person(1, "name1", "surname1"));
clnCache.put(2, new Person(2, "name2", "surname2"));
clnCache.put(3, new Person(3, "name3", "surname3"));
final ScanQuery<Integer, Person> scanQry = new ScanQuery<>();
scanQry.setPageSize(1);
scanQry.setFilter(new IgniteBiPredicate<Integer, Person>() {
@Override public boolean apply(Integer integer, Person person) {
return true;
}
});
if (setPart)
scanQry.setPartition(1);
blockMessage(GridCacheQueryResponse.class);
final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
@Override public Object call() throws Exception {
try {
QueryCursor<Cache.Entry<Integer, Person>> qryCursor = clnCache.query(scanQry);
qryCursor.getAll();
}
catch (CacheException e) {
checkAndWait(e);
return true;
}
return false;
}
});
// Check that client waiting operation.
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override public Object call() throws Exception {
return fut.get(200);
}
}, IgniteFutureTimeoutCheckedException.class, null);
assertNotDone(fut);
unblockMessage();
reconnectClientNode(cln, srv, null);
assertTrue((Boolean)fut.get(2, SECONDS));
QueryCursor<Cache.Entry<Integer, Person>> qryCursor2 = clnCache.query(scanQry);
List<Cache.Entry<Integer, Person>> entries = qryCursor2.getAll();
assertEquals(setPart ? 1 : 3, entries.size());
for (Cache.Entry<Integer, Person> entry : entries) {
assertEquals(Integer.class, entry.getKey().getClass());
assertEquals(Person.class, entry.getValue().getClass());
}
}
示例3: test
import org.apache.ignite.cache.query.ScanQuery; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
ScanQuery<Integer, Object> qry = new ScanQuery<>();
qry.setFilter(new KeyFilter(key));
IgniteCache<Integer, Object> cache = cacheForOperation().withKeepBinary();
List<IgniteCache.Entry<Integer, Object>> res = cache.query(qry).getAll();
if (res.size() != 1)
throw new Exception("Invalid result size: " + res.size());
if (res.get(0).getKey() != key)
throw new Exception("Invalid entry found [key=" + key + ", entryKey=" + res.get(0).getKey() + ']');
return true;
}
示例4: readScanQuery
import org.apache.ignite.cache.query.ScanQuery; //导入方法依赖的package包/类
/**
* Reads scan query.
*
* @param reader Binary reader.
* @return Query.
*/
private Query readScanQuery(BinaryRawReaderEx reader) {
boolean loc = reader.readBoolean();
final int pageSize = reader.readInt();
boolean hasPart = reader.readBoolean();
Integer part = hasPart ? reader.readInt() : null;
ScanQuery qry = new ScanQuery().setPageSize(pageSize);
qry.setPartition(part);
Object pred = reader.readObjectDetached();
if (pred != null)
qry.setFilter(platformCtx.createCacheEntryFilter(pred, 0));
qry.setLocal(loc);
return qry;
}