/** {@inheritDoc} */ @Override public void run() { cache.query(qry).getAll(); } }
/** * @return result of explain plan */ @NotNull private String doExplainPlan(IgniteCache<Object, Object> cache, String sql) { return cache.query(new SqlFieldsQuery(sql)).getAll().get(0).get(0).toString().toLowerCase(); }
/** {@inheritDoc} */ @Override protected void cacheRemove(IgniteCache cache, Integer key) { cache.query(new SqlFieldsQuery("DELETE FROM Integer WHERE _key=" + key)).getAll(); } }
@Override public Void call() throws Exception { clientCache.query(new SqlFieldsQuery("SELECT * FROM INTEGER")).getAll(); return null; } }, CacheServerNotFoundException.class, "Failed to find data nodes for cache");
@Override public Object call() { return cache.query(new SqlFieldsQueryEx("UPDATE Organization SET name = WAIT(name)", false) .setSkipReducerOnUpdate(true)); } });
/** * Tests that selection for a {@link LocalTime} field returns {@link Time}. * * @throws Exception If failed. */ @Test public void testSelectLocalTimeFieldReturnsTime() throws Exception { SqlFieldsQuery qry = new SqlFieldsQuery("select locTime from EntityWithDateTimeFields"); List<List<?>> qryResults = cache.query(qry).getAll(); assertEquals(1, qryResults.size()); assertEquals(Time.class, qryResults.get(0).get(0).getClass()); }
/** * @param q Query. * @return Row set. */ private Set<List<?>> query(String q) { return new HashSet<>(cache.query(new SqlFieldsQuery(q)).getAll()); }
/** {@inheritDoc} */ @Override public void doRead() { int idx = random.nextInt(entriesCount()); cache().query(new ScanQuery<>((k, v) -> Objects.equals(k, idx))).getAll(); } };
@Override public Void call() throws Exception { SqlFieldsQuery qry = new SqlFieldsQuery(sql); qry.setDistributedJoins(true); cache.query(qry).getAll(); return null; } }, CacheException.class, null);
/** * Execute native sql. * * @param sql query. * @param args arguments of SqlFieldsQuery. * @return {@link QueryCursor#getAll()} - result of the query. */ private List<List<?>> execute(String sql, Object... args) { return cache.query(new SqlFieldsQuery(sql).setArgs(args)).getAll(); }
/** * */ private void destroyIndex(IgniteEx ignite, T3<String, String, String> pair) { IgniteCache<?, ?> cache = ignite.getOrCreateCache(pair.get1()); String createIdxQryStr = String.format("DROP INDEX %s", pair.get3()); cache.query(new SqlFieldsQuery(createIdxQryStr)).getAll(); }
/** * Test DDL operation for not started cache on client node. */ @Test public void testCreateIdxOnClient() { getDefaultCacheOnClient().query(new SqlFieldsQuery("CREATE INDEX IDX_11 ON " + FULL_TABLE_NAME + " (name asc)")).getAll(); }
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(); } }
/** */ @SuppressWarnings("ConstantConditions") private void assertItemsNumber(long num) { assertEquals(num, grid().cachex(DEFAULT_CACHE_NAME).size()); assertEquals(num, grid().cache(DEFAULT_CACHE_NAME).query(new SqlFieldsQuery("select count(*) from TestObject")).getAll() .get(0).get(0)); }
/** * 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()); } }
/** * 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); }
/** * */ @Test public void testPrimitives() { IgniteCache<Integer, Integer> p = ignite(0).cache("I2I").withKeepBinary(); p.query(new SqlFieldsQuery("merge into Integer(_key, _val) values (1, ?), " + "(?, 4)").setArgs(2, 3)); assertEquals(2, (int)p.get(1)); assertEquals(4, (int)p.get(3)); } }
/** * */ @Test public void testFieldsCaseSensitivity() { IgniteCache<Key2, Person> p = ignite(0).cache("K22P").withKeepBinary(); p.query(new SqlFieldsQuery("insert into \"Person2\" (\"Id\", \"id\", \"firstName\", \"IntVal\") " + "values (1, ?, ?, 5), (2, 3, 'Alex', 6)").setArgs(4, "Sergi")); assertEquals(createPerson2(4, "Sergi", 5), p.get(new Key2(1))); assertEquals(createPerson2(3, "Alex", 6), p.get(new Key2(2))); }