Java Code Examples for org.apache.ignite.cache.query.SqlFieldsQuery#setCollocated()
The following examples show how to use
org.apache.ignite.cache.query.SqlFieldsQuery#setCollocated() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JdbcStatement.java From ignite with Apache License 2.0 | 5 votes |
/** * Sets parameters to query object. Logic should be consistent with {@link JdbcQueryTask#call()} and {@link * JdbcQueryMultipleStatementsTask#call()}. Parameters are determined from context: connection state and this * statement state. * * @param qry query which parameters to set up */ protected void setupQuery(SqlFieldsQuery qry) { qry.setPageSize(fetchSize); qry.setLocal(conn.nodeId() == null); qry.setCollocated(conn.isCollocatedQuery()); qry.setDistributedJoins(conn.isDistributedJoins()); qry.setEnforceJoinOrder(conn.isEnforceJoinOrder()); qry.setLazy(conn.isLazy()); qry.setSchema(conn.schemaName()); }
Example 2
Source File: JdbcBatchUpdateTask.java From ignite with Apache License 2.0 | 4 votes |
/** * Performs update. * * @param cache Cache. * @param sqlText SQL text. * @param args Parameters. * @return Update counter. * @throws SQLException If failed. */ private Integer doSingleUpdate(IgniteCache<?, ?> cache, String sqlText, List<Object> args) throws SQLException { SqlFieldsQuery qry = new SqlFieldsQueryEx(sqlText, false); qry.setPageSize(fetchSize); qry.setLocal(locQry); qry.setCollocated(collocatedQry); qry.setDistributedJoins(distributedJoins); qry.setSchema(schemaName); qry.setArgs(args == null ? null : args.toArray()); QueryCursorImpl<List<?>> qryCursor = (QueryCursorImpl<List<?>>)cache.withKeepBinary().query(qry); if (qryCursor.isQuery()) { throw createJdbcSqlException(getError("Query produced result set", qry), IgniteQueryErrorCode.STMT_TYPE_MISMATCH); } List<List<?>> rows = qryCursor.getAll(); if (F.isEmpty(rows)) return SUCCESS_NO_INFO; if (rows.size() != 1) throw new SQLException(getError("Expected single row for update operation result", qry)); List<?> row = rows.get(0); if (F.isEmpty(row) || row.size() != 1) throw new SQLException(getError("Expected row size of 1 for update operation", qry)); Object objRes = row.get(0); if (!(objRes instanceof Long)) throw new SQLException(getError("Unexpected update result type", qry)); Long longRes = (Long)objRes; if (longRes > Integer.MAX_VALUE) { IgniteLogger log = ignite.log(); if (log != null) log.warning(getError("Query updated row counter (" + longRes + ") exceeds integer range", qry)); return Integer.MAX_VALUE; } return longRes.intValue(); }