/** * Queries the specified cache using the specified filter. * * @param upstreamCache Ignite cache with {@code upstream} data. * @return Query cursor. */ private QueryCursor<Cache.Entry<K, V>> query(IgniteCache<K, V> upstreamCache) { ScanQuery<K, V> qry = new ScanQuery<>(); return upstreamCache.query(qry); }
/** * Queries the specified cache using the specified filter. * * @param upstreamCache Ignite cache with {@code upstream} data. * @param filter Filter for {@code upstream} data. If {@code null} then all entries will be returned. * @return Query cursor. */ private QueryCursor<Cache.Entry<K, V>> query(IgniteCache<K, V> upstreamCache, IgniteBiPredicate<K, V> filter) { ScanQuery<K, V> qry = new ScanQuery<>(); if (filter != null) // This section was added to keep code correct of qry.setFilter(null) behaviour will changed. qry.setFilter(filter); return upstreamCache.query(qry); }
/** * Returns list of maintained TensorFlow clusters. * * @return List of maintained TensorFlow clusters. */ public Map<UUID, TensorFlowCluster> getAllClusters() { Map<UUID, TensorFlowCluster> res = new HashMap<>(); ScanQuery<UUID, TensorFlowCluster> qry = new ScanQuery<>(); QueryCursor<Cache.Entry<UUID, TensorFlowCluster>> cursor = cache.query(qry); for (Cache.Entry<UUID, TensorFlowCluster> e : cursor) res.put(e.getKey(), e.getValue()); return res; }
/** * Test metrics for Scan queries. */ @Test public void testScanQueryHistory() { ScanQuery<Integer, String> qry = new ScanQuery<>(); checkNoQueryMetrics(qry); }
/** {@inheritDoc} */ @Override public void doRead() { int idx = random.nextInt(entriesCount()); cache().query(new ScanQuery<>((k, v) -> Objects.equals(k, idx))).getAll(); } };
/** * @param ignite Ignite. * @param orgId Organization id. * @return Count of found Person object with specified orgId */ private static int getPersonsCountByScanLocalQuery(final IgniteEx ignite, final int orgId) { List res = ignite.cache(Person.class.getSimpleName()) .query(new ScanQuery<>(new IgniteBiPredicate<Person.Key, Person>() { @Override public boolean apply(Person.Key key, Person person) { return person.getOrgId() == orgId; } }).setLocal(true)).getAll(); return res.size(); }
@Override public void applyx() throws IgniteCheckedException { int iter = 0; while (!done.get() && !Thread.currentThread().isInterrupted()) { iter++; // Scan query. Collection<Cache.Entry<Integer, Integer>> entries = c.query(new ScanQuery<Integer, Integer>()).getAll(); assert entries != null; assertEquals("Entries count is not as expected on iteration: " + iter, keyCnt, entries.size()); if (cnt.incrementAndGet() % logMod == 0) { GridCacheQueryManager<Object, Object> qryMgr = ((IgniteKernal)g).internalCache(c.getName()).context().queries(); assert qryMgr != null; qryMgr.printMemoryStats(); } } } }, threadCnt);
@Override public Object call() throws Exception { int nodeId = nodeIdx.getAndIncrement(); IgniteCache<Integer, Integer> cache = grid(nodeId).cache(DEFAULT_CACHE_NAME); int cntr = 0; while (!done.get()) { int part = ThreadLocalRandom.current().nextInt(ignite(nodeId).affinity(DEFAULT_CACHE_NAME).partitions()); if (cntr++ % 100 == 0) info("Running query [node=" + nodeId + ", part=" + part + ']'); try (QueryCursor<Cache.Entry<Integer, Integer>> cur = cache.query(new ScanQuery<Integer, Integer>(part).setPageSize(5))) { doTestScanQueryCursor(cur, part); } } return null; } }, GRID_CNT);
/** * @throws IgniteCheckedException If failed. */ @Test public void testScanQuery() throws IgniteCheckedException { jcache().query(new ScanQuery<>(null)).getAll(); } }
/** * @param total Expected total entries. */ private void checkScan(int total) { for (int i = 0; i < gridCount(); i++) { Set<DbKey> allKeys = new HashSet<>(); Ignite ignite0 = grid(i); IgniteCache<DbKey, DbValue> cache0 = ignite0.cache("non-primitive"); ScanQuery<DbKey, DbValue> qry = new ScanQuery<>(); QueryCursor<Cache.Entry<DbKey, DbValue>> cur = cache0.query(qry); for (Cache.Entry<DbKey, DbValue> e : cur) { allKeys.add(e.getKey()); assertEquals(e.getKey().val, e.getValue().iVal); } assertEquals(total, allKeys.size()); } }
private void doTestScanQuery(IgniteCache<Long,TestData> cache, int keysCnt) { // Scan query (data page scan must be disabled by default). TestPredicate.callsCnt.set(0); int callsCnt = 0; assertTrue(cache.query(new ScanQuery<>(new TestPredicate())).getAll().isEmpty()); assertFalse(CacheDataTree.isLastFindWithDataPageScan()); assertEquals(callsCnt += keysCnt, TestPredicate.callsCnt.get()); checkScanQuery(cache, true, true); assertEquals(callsCnt += keysCnt, TestPredicate.callsCnt.get()); checkScanQuery(cache, false, false); assertEquals(callsCnt += keysCnt, TestPredicate.callsCnt.get()); checkScanQuery(cache, true, true); assertEquals(callsCnt += keysCnt, TestPredicate.callsCnt.get()); checkScanQuery(cache, null, false); assertEquals(callsCnt += keysCnt, TestPredicate.callsCnt.get()); }
/** * @throws Exception If failed. */ @Test public void testScanQuery() throws Exception { IgniteCache<Integer, String> cache = grid().getOrCreateCache(String.class.getSimpleName()); try { cache.query(new ScanQuery<>(new IgniteBiPredicate<Integer, String>() { @Override public boolean apply(Integer id, String s) { return s.equals(""); } })).getAll(); } catch (IgniteException ignored) { assertTrue("Scan query should work with disabled query indexing.", false); } }
private void checkScanQuery(IgniteCache<Long,TestData> cache, Boolean dataPageScanEnabled, Boolean expLastDataPageScan) { assertTrue(cache.query(new ScanQuery<>(new TestPredicate()) .setDataPageScanEnabled(dataPageScanEnabled)).getAll().isEmpty()); assertEquals(expLastDataPageScan, CacheDataTree.isLastFindWithDataPageScan()); }
/** * Test metrics for Scan queries. * * @throws Exception In case of error. */ @Test public void testScanQueryMetrics() throws Exception { IgniteCache<Integer, String> cache = grid(0).context().cache().jcache("A"); ScanQuery<Integer, String> qry = new ScanQuery<>(); checkQueryMetrics(cache, qry); }
/** * Test metrics for failed Scan queries. * * @throws Exception In case of error. */ @Test public void testScanQueryFailedMetrics() throws Exception { IgniteCache<Integer, String> cache = grid(0).context().cache().jcache("A"); ScanQuery<Integer, String> qry = new ScanQuery<>(Integer.MAX_VALUE); checkQueryFailedMetrics(cache, qry); }
/** * @param client ignite instance. * @param predCls loaded predicate class. * @throws Exception if failed. */ private void invokeScanQueryAndStopClient(Ignite client, Class predCls) throws Exception { IgniteCache<Integer, String> cache = client.getOrCreateCache(CACHE_NAME); assertEquals("Invalid number of sent grid deployment requests", 0, MessageCountingCommunicationSpi.deploymentRequestCount()); assertFalse(PREDICATE_CLASSNAME + " mustn't be cached! ", igniteUtilsCachedClasses().contains(PREDICATE_CLASSNAME)); cache.query(new ScanQuery<>((IgniteBiPredicate<Integer, String>)predCls.newInstance())).getAll(); // first request is GridDeployment.java 716 and second is GridDeployment.java 501 assertEquals("Invalid number of sent grid deployment requests", 2, MessageCountingCommunicationSpi.deploymentRequestCount()); assertTrue(PREDICATE_CLASSNAME + " must be cached! ", igniteUtilsCachedClasses().contains(PREDICATE_CLASSNAME)); client.close(); assertFalse(PREDICATE_CLASSNAME + " mustn't be cached! ", igniteUtilsCachedClasses().contains(PREDICATE_CLASSNAME)); }
/** * Test metrics for Scan queries. * * @throws Exception In case of error. */ @Test public void testScanQueryMetrics() throws Exception { IgniteCache<Integer, String> cache = grid(0).context().cache().jcache("A"); ScanQuery<Integer, String> qry = new ScanQuery<>(); checkQueryMetrics(cache, qry); }
/** * Test metrics for failed Scan queries. * * @throws Exception In case of error. */ @Test public void testScanQueryFailedMetrics() throws Exception { IgniteCache<Integer, String> cache = grid(0).context().cache().jcache("A"); ScanQuery<Integer, String> qry = new ScanQuery<>(Integer.MAX_VALUE); checkQueryFailedMetrics(cache, qry); }
/** * Test metrics for Scan queries. * * @throws Exception In case of error. */ @Test public void testScanQueryNotFullyFetchedMetrics() throws Exception { IgniteCache<Integer, String> cache = grid(0).context().cache().jcache("A"); ScanQuery<Integer, String> qry = new ScanQuery<>(); qry.setPageSize(10); checkQueryNotFullyFetchedMetrics(cache, qry, true); }
/** * Test metrics for Scan queries. * * @throws Exception In case of error. */ @Test public void testScanQueryNotFullyFetchedMetrics() throws Exception { IgniteCache<Integer, String> cache = grid(0).context().cache().jcache("A"); ScanQuery<Integer, String> qry = new ScanQuery<>(); qry.setPageSize(10); checkQueryNotFullyFetchedMetrics(cache, qry, true); }