Search in sources :

Example 21 with QueryCursorImpl

use of org.apache.ignite.internal.processors.cache.QueryCursorImpl in project ignite by apache.

the class DmlStatementsProcessor method updateSqlFieldsDistributed.

/**
 * @param schemaName Schema.
 * @param c Connection.
 * @param p Prepared statement.
 * @param fieldsQry Initial query
 * @param cancel Query cancel.
 * @return Update result wrapped into {@link GridQueryFieldsResult}
 * @throws IgniteCheckedException if failed.
 */
@SuppressWarnings("unchecked")
List<QueryCursorImpl<List<?>>> updateSqlFieldsDistributed(String schemaName, Connection c, Prepared p, SqlFieldsQuery fieldsQry, GridQueryCancel cancel) throws IgniteCheckedException {
    if (DmlUtils.isBatched(fieldsQry)) {
        Collection<UpdateResult> ress = updateSqlFieldsBatched(schemaName, c, p, (SqlFieldsQueryEx) fieldsQry, false, null, cancel);
        ArrayList<QueryCursorImpl<List<?>>> resCurs = new ArrayList<>(ress.size());
        for (UpdateResult res : ress) {
            checkUpdateResult(res);
            QueryCursorImpl<List<?>> resCur = (QueryCursorImpl<List<?>>) new QueryCursorImpl(Collections.singletonList(Collections.singletonList(res.counter())), cancel, false);
            resCur.fieldsMeta(UPDATE_RESULT_META);
            resCurs.add(resCur);
        }
        return resCurs;
    } else {
        UpdateResult res = updateSqlFields(schemaName, c, p, fieldsQry, false, null, cancel);
        ArrayList<QueryCursorImpl<List<?>>> resCurs = new ArrayList<>(1);
        checkUpdateResult(res);
        QueryCursorImpl<List<?>> resCur = (QueryCursorImpl<List<?>>) new QueryCursorImpl(Collections.singletonList(Collections.singletonList(res.counter())), cancel, false);
        resCur.fieldsMeta(UPDATE_RESULT_META);
        resCurs.add(resCur);
        return resCurs;
    }
}
Also used : ArrayList(java.util.ArrayList) QueryCursorImpl(org.apache.ignite.internal.processors.cache.QueryCursorImpl) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

QueryCursorImpl (org.apache.ignite.internal.processors.cache.QueryCursorImpl)21 List (java.util.List)20 ArrayList (java.util.ArrayList)16 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)12 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)9 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)9 IgniteException (org.apache.ignite.IgniteException)8 GridQueryCacheObjectsIterator (org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator)8 Iterator (java.util.Iterator)7 IgniteSystemProperties.getString (org.apache.ignite.IgniteSystemProperties.getString)6 FieldsQueryCursor (org.apache.ignite.cache.query.FieldsQueryCursor)5 GridQueryFieldsResult (org.apache.ignite.internal.processors.query.GridQueryFieldsResult)5 SQLException (java.sql.SQLException)4 LinkedHashMap (java.util.LinkedHashMap)4 SqlFieldsQueryEx (org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx)4 GridEmptyCloseableIterator (org.apache.ignite.internal.util.GridEmptyCloseableIterator)4 GridCloseableIterator (org.apache.ignite.internal.util.lang.GridCloseableIterator)4 Cache (javax.cache.Cache)3 CacheException (javax.cache.CacheException)3 GridQueryCancel (org.apache.ignite.internal.processors.query.GridQueryCancel)3