/** * @return Value object context. */ public CacheObjectValueContext objectContext() { return ctx.query().objectContext(); }
/** * @param cctx Cache context. * @param tableName Target table name. */ TableCacheFilter(GridCacheContext cctx, String tableName) { this.cctx = cctx; this.tableName = tableName; cacheName = cctx.name(); query = cctx.kernalContext().query(); }
/** {@inheritDoc} */ @Override protected UpdateSourceIterator<?> createIterator() throws IgniteCheckedException { checkPartitions(parts); return cctx.kernalContext().query().prepareDistributedUpdate(cctx, cacheIds, parts, schema, qry, params, flags, pageSize, 0, tx.topologyVersionSnapshot(), mvccSnapshot, new GridQueryCancel()); }
/** * @return Cached two-step query, or {@code null} if none occurred. */ private GridCacheTwoStepQuery cachedTwoStepQuery() { GridQueryIndexing idx = grid(0).context().query().getIndexing(); Map<?, H2TwoStepCachedQuery> m = U.field(idx, "twoStepCache"); if (m.isEmpty()) return null; H2TwoStepCachedQuery q = m.values().iterator().next(); return q.query(); }
@Override public boolean apply() { Collection<GridRunningQueryInfo> qCol = grid(NODE_CLIENT).context().query().runningQueries(0); if (qCol.isEmpty()) return false; for (GridRunningQueryInfo queryInfo : qCol) queryInfo.cancel(); return true; } }, 5000);
/** * @param nodeIdx Node index. * @param sql Sql query. */ private void userSql(int nodeIdx, String sql) { List<List<?>> res = grid(nodeIdx).context().query().querySqlFields( new SqlFieldsQuery(sql), false).getAll(); assertEquals(1, res.size()); assertEquals(1, res.get(0).size()); assertEquals(0L, res.get(0).get(0)); } }
/** * @param qry SQL query. * @return Results. */ private FieldsQueryCursor<List<?>> sql(SqlFieldsQuery qry) { GridQueryProcessor qryProc = grid(0).context().query(); return qryProc.querySqlFields(qry, true); } }
/** * @param ig Ignite node. * @param grpId Cache group ID. * @return H2RowCache for checks. */ private H2RowCache rowCache(IgniteEx ig, int grpId) { return (H2RowCache)ig.context().query().getIndexing().rowCacheCleaner(grpId); }
@Override public Void call() throws Exception { ig.context().query().querySqlFields(new SqlFieldsQuery("SELECT 1"), false); return null; } }, IgniteException.class, "Can not perform the operation because the cluster is inactive.");
/** * Uses SQL to retrieve data from cache. * * @param cache Cache. * @param tbl Table. */ private void testQueryEntity(IgniteCache<Long, Person> cache, String tbl) { cache.put(1L, new Person("Vasya", 2)); assertEquals(1, node.context().query().querySqlFields( new SqlFieldsQuery(String.format("SELECT id, name, orgId FROM TEST.%s where (id = %d)", tbl, 1)), false ).getAll().size()); }
/** * @param sql SQL query. * @return Results. */ private List<FieldsQueryCursor<List<?>>> sql(String sql) { GridQueryProcessor qryProc = node.context().query(); SqlFieldsQuery qry = new SqlFieldsQuery(sql).setSchema("PUBLIC"); return qryProc.querySqlFields(qry, true, false); } }
/** * Run query. * * @param node Node. * @param sqlText Query. * @return Results. */ private List<List<?>> runSql(Ignite node, String sqlText) { GridQueryProcessor qryProc = ((IgniteEx)node).context().query(); return qryProc.querySqlFields(new SqlFieldsQuery(sqlText), false).getAll(); }
/** * Execute prepared SQL fields query. * * @param qry Query. * @return Result. */ private List<List<?>> executeSqlFieldsQuery(SqlFieldsQuery qry) { return client().context().query().querySqlFields(qry, false).getAll(); }
/** */ private IgniteEx startGridWithLogCapture() throws Exception { IgniteEx ignite = startGrid(0); this.capture = new GridStringLogger(false, this.log); GridTestUtils.setFieldValue(ignite.context().query(), GridProcessorAdapter.class,"log", capture); return ignite; }
/** * @param sql SQL query. * @return Results. */ private List<List<?>> sql(String sql) { GridQueryProcessor qryProc = node.context().query(); SqlFieldsQuery qry = new SqlFieldsQuery(sql).setSchema("PUBLIC"); return qryProc.querySqlFields(qry, true).getAll(); } }
/** * Run SQL statement on specified node. * * @param node node to execute query. * @param stmt Statement to run. * @param args arguments of statements * @return Run result. */ private List<List<?>> executeSql(IgniteEx node, String stmt, Object... args) { return node.context().query().querySqlFields(new SqlFieldsQuery(stmt).setArgs(args), true).getAll(); }
/** * Run SQL statement on specified node. * @param stmt Statement to run. * @return Run result. */ private List<List<?>> executeSql(IgniteEx node, String stmt, Object... args) { return node.context().query().querySqlFields(new SqlFieldsQuery(stmt).setArgs(args), true).getAll(); }
/** */ private List<List<?>> executeSql(String sqlText) throws Exception { GridQueryProcessor qryProc = grid(NODE_CLIENT).context().query(); return qryProc.querySqlFields(new SqlFieldsQuery(sqlText), true).getAll(); }
/** * @param sql SQL query * @param args Query parameters. * @return Results set. */ private List<List<?>> sql(String sql, Object ... args) { return grid(NODE_CLIENT).context().query().querySqlFields( new SqlFieldsQuery(sql).setArgs(args), false).getAll(); } }
/** */ private List<List<?>> executeSql(IgniteEx grid, String qry, Object...args) { return grid.context().query().querySqlFields( new SqlFieldsQuery(qry).setSchema("PUBLIC").setArgs(args), true).getAll(); }