/** {@inheritDoc} */ @Override public ClientResponse process(ClientConnectionContext ctx) { IgniteCache cache = cache(ctx); ctx.incrementCursors(); try { QueryCursor cur = cache.query(qry); ClientCacheEntryQueryCursor cliCur = new ClientCacheEntryQueryCursor( cur, qry.getPageSize(), ctx); long cursorId = ctx.resources().put(cliCur); cliCur.id(cursorId); return new ClientCacheQueryResponse(requestId(), cliCur); } catch (Exception e) { ctx.decrementCursors(); throw e; } } }
/** Handle SQL query. */ private QueryCursor<Cache.Entry<K, V>> sqlQuery(SqlQuery qry) { Consumer<BinaryOutputStream> qryWriter = out -> { writeCacheInfo(out); serDes.writeObject(out, qry.getType()); serDes.writeObject(out, qry.getSql()); ClientUtils.collection(qry.getArgs(), out, serDes::writeObject); out.writeBoolean(qry.isDistributedJoins()); out.writeBoolean(qry.isLocal()); out.writeBoolean(qry.isReplicatedOnly()); out.writeInt(qry.getPageSize()); out.writeLong(qry.getTimeout()); }; return new ClientQueryCursor<>(new ClientQueryPager<>( ch, ClientOperation.QUERY_SQL, ClientOperation.QUERY_SQL_CURSOR_GET_PAGE, qryWriter, keepBinary, marsh )); }
/** {@inheritDoc} */ @SuppressWarnings("deprecation") @Override public SqlFieldsQuery generateFieldsQuery(String cacheName, SqlQuery qry) { String schemaName = schema(cacheName); String type = qry.getType(); H2TableDescriptor tblDesc = schemaMgr.tableForType(schemaName, cacheName, type); if (tblDesc == null) throw new IgniteSQLException("Failed to find SQL table for type: " + type, IgniteQueryErrorCode.TABLE_NOT_FOUND); String sql; try { sql = H2Utils.generateFieldsQueryString(qry.getSql(), qry.getAlias(), tblDesc); } catch (IgniteCheckedException e) { throw new IgniteException(e); } SqlFieldsQuery res = new SqlFieldsQuery(sql); res.setArgs(qry.getArgs()); res.setDistributedJoins(qry.isDistributedJoins()); res.setLocal(qry.isLocal()); res.setPageSize(qry.getPageSize()); res.setPartitions(qry.getPartitions()); res.setReplicatedOnly(qry.isReplicatedOnly()); res.setSchema(schemaName); res.setSql(sql); res.setDataPageScanEnabled(qry.isDataPageScanEnabled()); if (qry.getTimeout() > 0) res.setTimeout(qry.getTimeout(), TimeUnit.MILLISECONDS); return res; }
/** {@inheritDoc} */ @Override public ClientResponse process(ClientConnectionContext ctx) { IgniteCache cache = cache(ctx); ctx.incrementCursors(); try { QueryCursor cur = cache.query(qry); ClientCacheEntryQueryCursor cliCur = new ClientCacheEntryQueryCursor( cur, qry.getPageSize(), ctx); long cursorId = ctx.resources().put(cliCur); cliCur.id(cursorId); return new ClientCacheQueryResponse(requestId(), cliCur); } catch (Exception e) { ctx.decrementCursors(); throw e; } } }
fqry.setPageSize(qry.getPageSize()); fqry.setDistributedJoins(qry.isDistributedJoins()); fqry.setPartitions(qry.getPartitions());
/** Handle SQL query. */ private QueryCursor<Cache.Entry<K, V>> sqlQuery(SqlQuery qry) { Consumer<BinaryOutputStream> qryWriter = out -> { writeCacheInfo(out); serDes.writeObject(out, qry.getType()); serDes.writeObject(out, qry.getSql()); ClientUtils.collection(qry.getArgs(), out, serDes::writeObject); out.writeBoolean(qry.isDistributedJoins()); out.writeBoolean(qry.isLocal()); out.writeBoolean(qry.isReplicatedOnly()); out.writeInt(qry.getPageSize()); out.writeLong(qry.getTimeout()); }; return new ClientQueryCursor<>(new ClientQueryPager<>( ch, ClientOperation.QUERY_SQL, ClientOperation.QUERY_SQL_CURSOR_GET_PAGE, qryWriter, keepBinary, marsh )); }