@Override public Object call() throws Exception { try { cur1.getAll(); } catch (CacheException e) { checkAndWait(e); return true; } return false; } });
/** {@inheritDoc} */ @Override public void run() { cache.query(qry).getAll(); } }
/** * Fails if result size not equals to resSize. * * @param qryStr to execute. * @param cache cache. * @param resSize size of the result. */ private void assertAnyResTypeEnumQry(String qryStr, IgniteCache<Long, EnumObject> cache, int resSize) { final SqlQuery<Long, EnumObject> qry = new SqlQuery<>(EnumObject.class, qryStr); final List<Cache.Entry<Long, EnumObject>> res = cache.query(qry).getAll(); assert resSize == res.size(); }
/** {@inheritDoc} */ @Nullable @Override public Object execute() { IgniteCache<Integer, PlatformComputeBinarizable> cache = ignite.cache("default"); SqlQuery<Integer, PlatformComputeBinarizable> qry = new SqlQuery<>("PlatformComputeBinarizable", arg); List<Cache.Entry<Integer, PlatformComputeBinarizable>> qryRes = cache.query(qry).getAll(); Collection<PlatformComputeBinarizable> res = new ArrayList<>(qryRes.size()); for (Cache.Entry<Integer, PlatformComputeBinarizable> e : qryRes) res.add(e.getValue()); return res; }
@Override public void applyx() throws IgniteCheckedException { while (!done.get()) { QueryCursor<Cache.Entry<UUID, PersonObj>> bachelors = cache0.query(new SqlQuery(PersonObj.class, "degree = 'Bachelor'")); Collection<Cache.Entry<UUID, PersonObj>> entries = bachelors.getAll(); checkResult(entries, p3, p4); long cnt = sqlCnt.incrementAndGet(); if (cnt % logMod == 0) info("Executed SQL queries: " + cnt); } } }, sqlThreads, "SQL-THREAD");
/** */ private void checkSelect(IgniteCache<?, ?> cache, String selectQry, Object ... expected) { QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(selectQry)); List<List<?>> results = cursor.getAll(); assertEquals(1, results.size()); List<?> row0 = results.get(0); for(int col = 0; col < expected.length; ++col) assertEquals(expected[col], row0.get(col)); }
/** {@inheritDoc} */ @Override public void doRead() { int idx = random.nextInt(entriesCount()); cache().query(new ScanQuery<>((k, v) -> Objects.equals(k, idx))).getAll(); } };
/** * Clear cache with check. */ private static void clearCache(IgniteEx ignite) { IgniteCache<Integer, Person> cache = ignite.cache(PERSON_CACHE); cache.clear(); List all = cache.query(new TextQuery<>(Person.class, "1*")).getAll(); assertTrue(all.isEmpty()); }
/** * Test from client node to get cache elements through cache API. */ @Test public void testClientSqlQuery() { SqlQuery<Integer, Person> qry = new SqlQuery<>(PERSON_CACHE, "FROM " + PERSON_CACHE); Assert.assertEquals(CACHE_ELEMENT_COUNT, clientNode.getOrCreateCache(PERSON_CACHE).query(qry).getAll().size()); }
/** {@inheritDoc} */ @Override public void doRead() { int idx = random.nextInt(entriesCount()); cache().query( new SqlQuery<>(TestingEntity.class, "val >= ? and val < ?") .setArgs(idx, idx + 500) ).getAll(); } };
/** * @param name Cache name. */ @SuppressWarnings("unchecked") private void fillRowCache(String name) { for (int i = 0; i < ENTRIES; ++i) grid().cache(name).query(new SqlQuery(Value.class, "_key = " + i)).getAll(); }
private void checkSqlQuery(IgniteCache<Long,TestData> cache, Boolean dataPageScanEnabled) { DirectPageScanIndexing.expectedDataPageScanEnabled = dataPageScanEnabled; assertTrue(cache.query(new SqlQuery<>(TestData.class, "from TestData use index() where check_scan_flag(?,false)") // Force full scan with USE INDEX() .setArgs(DirectPageScanIndexing.expectedDataPageScanEnabled) .setDataPageScanEnabled(DirectPageScanIndexing.expectedDataPageScanEnabled)) .getAll().isEmpty()); checkSqlLastFindDataPageScan(dataPageScanEnabled); }
protected void checkCacheOperations(IgniteCache<Integer, Value> cache) throws Exception { super.checkCacheOperations(cache); // Check SQL API. String sql = "fieldVal >= ? and fieldVal <= ?"; List<Cache.Entry<Integer, Value>> res = cache.query( new SqlQuery<Integer, Value>(Value.class, sql).setArgs(1, 100)).getAll(); assertNotNull(res); assertEquals(100, res.size()); } }
/** * @throws Exception If failed. */ @Test public void testIllegalBounds() throws Exception { IgniteCache<Integer, Integer> cache = jcache(Integer.class, Integer.class); cache.put(1, 1); cache.put(2, 2); QueryCursor<Cache.Entry<Integer,Integer>> qry = cache.query(new SqlQuery<Integer, Integer>(Integer.class, "_key between 2 and 1")); assertTrue(qry.getAll().isEmpty()); }
/** {@inheritDoc} */ @Override public List<Cache.Entry<Integer, GridCacheQueryTestValue>> call() throws Exception { IgniteCache<Integer, GridCacheQueryTestValue> c = ignite.cache(CACHE_NAME); String sqlStr = "FROM GridCacheQueryTestValue WHERE fieldname = ?"; SqlQuery<Integer, GridCacheQueryTestValue> sql = new SqlQuery<>(GridCacheQueryTestValue.class, sqlStr); sql.setArgs("C"); return c.query(sql.setSql(sqlStr)).getAll(); } }
/** * Tests correct query execution with disabled re-balancing. */ @Test public void testQueryNoRebalance() { IgniteCache<Object, Object> cache = grid().cache(DEFAULT_CACHE_NAME); cache.put(1, 1); QueryCursor<Cache.Entry<Integer, Integer>> qry = cache.query(new SqlQuery<Integer, Integer>(Integer.class, "_key >= 0")); assertEquals("Bad results count", 1, qry.getAll().size()); } }
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()); }
/** * Non local SQL Fields check nullification after complete */ @Test public void testSqlFieldsQueryComplete() { SqlFieldsQuery qry = new SqlFieldsQuery(SELECT_MAX_SAL_SQLF); QueryCursor<List<?>> qryCurs = cache().query(qry); qryCurs.getAll(); H2ResultSetIterator h2It = extractGridIteratorInnerH2ResultSetIterator(qryCurs); checkIterator(h2It); }
/** * Local SQL Fields check nullification after complete */ @Test public void testSqlFieldsQueryLocalComplete() { SqlFieldsQuery qry = new SqlFieldsQuery(SELECT_MAX_SAL_SQLF); qry.setLocal(true); QueryCursor<List<?>> qryCurs = cache().query(qry); qryCurs.getAll(); H2ResultSetIterator h2It = extractGridIteratorInnerH2ResultSetIterator(qryCurs); checkIterator(h2It); }