You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/12/19 12:18:19 UTC

[22/31] ignite git commit: Done.

Done.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/dd70a846
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/dd70a846
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/dd70a846

Branch: refs/heads/ignite-6022-proto
Commit: dd70a84606185d575a1a9339d2a51cfd1993648a
Parents: 5d99beb
Author: devozerov <vo...@gridgain.com>
Authored: Mon Dec 18 12:11:18 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Dec 18 12:11:18 2017 +0300

----------------------------------------------------------------------
 .../query/h2/DmlStatementsProcessor.java        | 44 +---------
 .../processors/query/h2/dml/UpdatePlan.java     | 84 ++++++++++----------
 2 files changed, 46 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/dd70a846/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
index 7f1f5d5..9a6b0af 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
@@ -48,14 +48,11 @@ import org.apache.ignite.internal.processors.query.GridQueryCancel;
 import org.apache.ignite.internal.processors.query.GridQueryFieldsResult;
 import org.apache.ignite.internal.processors.query.GridQueryFieldsResultAdapter;
 import org.apache.ignite.internal.processors.query.IgniteSQLException;
-import org.apache.ignite.internal.processors.query.h2.dml.DmlArgument;
 import org.apache.ignite.internal.processors.query.h2.dml.DmlBatchSender;
 import org.apache.ignite.internal.processors.query.h2.dml.DmlDistributedPlanInfo;
-import org.apache.ignite.internal.processors.query.h2.dml.DmlUtils;
 import org.apache.ignite.internal.processors.query.h2.dml.UpdateMode;
 import org.apache.ignite.internal.processors.query.h2.dml.UpdatePlan;
 import org.apache.ignite.internal.processors.query.h2.dml.UpdatePlanBuilder;
-import org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor;
 import org.apache.ignite.internal.processors.query.h2.sql.GridSqlQueryParser;
 import org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashMap;
 import org.apache.ignite.internal.util.lang.IgniteSingletonIterator;
@@ -282,7 +279,7 @@ public class DmlStatementsProcessor {
                             it = res.iterator();
                         }
                         else
-                            it = planToRows(plan, U.firstNotNull(args, X.EMPTY_OBJECT_ARRAY)).iterator();
+                            it = plan.createRows(U.firstNotNull(args, X.EMPTY_OBJECT_ARRAY)).iterator();
 
                         return new GridQueryCacheObjectsIterator(it, idx.objectContext(), cctx.keepBinary());
                     }
@@ -379,7 +376,9 @@ public class DmlStatementsProcessor {
 
             cur = idx.queryDistributedSqlFields(schemaName, newFieldsQry, true, cancel, mainCacheId, true).get(0);
         }
-        else if (F.isEmpty(plan.rows())) {
+        else if (plan.hasRows())
+            cur = plan.createRows(fieldsQry.getArgs());
+        else {
             final GridQueryFieldsResult res = idx.queryLocalSqlFields(schemaName, plan.selectQuery(),
                 F.asList(fieldsQry.getArgs()), filters, fieldsQry.isEnforceJoinOrder(), fieldsQry.getTimeout(), cancel);
 
@@ -394,8 +393,6 @@ public class DmlStatementsProcessor {
                 }
             }, cancel);
         }
-        else
-            cur = planToRows(plan, fieldsQry.getArgs());
 
         int pageSize = loc ? 0 : fieldsQry.getPageSize();
 
@@ -403,39 +400,6 @@ public class DmlStatementsProcessor {
     }
 
     /**
-     * Extract rows from plan without performing any query.
-     * @param plan Plan.
-     * @param args Original query arguments.
-     * @return Rows from plan.
-     * @throws IgniteCheckedException if failed.
-     */
-    private List<List<?>> planToRows(UpdatePlan plan, Object[] args) throws IgniteCheckedException {
-        assert plan.rowCount() > 0 && !F.isEmpty(plan.columnNames());
-
-        List<List<?>> rows = new ArrayList<>(plan.rowCount());
-
-        GridH2RowDescriptor desc = plan.table().rowDescriptor();
-
-        for (List<DmlArgument> argRow : plan.rows()) {
-            List<Object> row = new ArrayList<>();
-
-            for (int j = 0; j < plan.columnNames().length; j++) {
-                Object colVal = argRow.get(j).get(args);
-
-                if (j == plan.keyColumnIndex() || j == plan.valueColumnIndex())
-                    colVal = DmlUtils.convert(colVal, desc, j == plan.keyColumnIndex() ? desc.type().keyClass() :
-                        desc.type().valueClass(), plan.columnTypes()[j]);
-
-                row.add(colVal);
-            }
-
-            rows.add(row);
-        }
-
-        return rows;
-    }
-
-    /**
      * @param cctx Cache context.
      * @param plan Update plan.
      * @param cursor Cursor over select results.

http://git-wip-us.apache.org/repos/asf/ignite/blob/dd70a846/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlan.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlan.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlan.java
index 10e7519..6a45c3c 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlan.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlan.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.processors.query.h2.dml;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -360,6 +361,47 @@ public final class UpdatePlan {
     }
 
     /**
+     * @return {@code True} if predefined rows exist.
+     */
+    public boolean hasRows() {
+        return !F.isEmpty(rows);
+    }
+
+    /**
+     * Extract rows from plan without performing any query.
+     * @param args Original query arguments.
+     * @return Rows from plan.
+     * @throws IgniteCheckedException if failed.
+     */
+    public List<List<?>> createRows(Object[] args) throws IgniteCheckedException {
+        assert rowsNum > 0 && !F.isEmpty(colNames);
+
+        List<List<?>> res = new ArrayList<>(rowsNum);
+
+        GridH2RowDescriptor desc = tbl.rowDescriptor();
+
+        for (List<DmlArgument> row : rows) {
+            List<Object> resRow = new ArrayList<>();
+
+            for (int j = 0; j < colNames.length; j++) {
+                Object colVal = row.get(j).get(args);
+
+                if (j == keyColIdx || j == valColIdx) {
+                    Class<?> colCls = j == keyColIdx ? desc.type().keyClass() : desc.type().valueClass();
+
+                    colVal = DmlUtils.convert(colVal, desc, colCls, colTypes[j]);
+                }
+
+                resRow.add(colVal);
+            }
+
+            res.add(resRow);
+        }
+
+        return res;
+    }
+
+    /**
      * @return Update mode.
      */
     public UpdateMode mode() {
@@ -400,46 +442,4 @@ public final class UpdatePlan {
     @Nullable public boolean isLocalSubquery() {
         return isLocSubqry;
     }
-
-    /**
-     * @return Names of affected columns.
-     */
-    public String[] columnNames() {
-        return colNames;
-    }
-
-    /**
-     * @return Types of affected columns.
-     */
-    public int[] columnTypes() {
-        return colTypes;
-    }
-
-    /**
-     * @return Rows for query-less MERGE or INSERT.
-     */
-    public List<List<DmlArgument>> rows() {
-        return rows;
-    }
-
-    /**
-     * @return Key column index.
-     */
-    public int keyColumnIndex() {
-        return keyColIdx;
-    }
-
-    /**
-     * @return Value column index.
-     */
-    public int valueColumnIndex() {
-        return valColIdx;
-    }
-
-    /**
-     * @return Target table.
-     */
-    public GridH2Table table() {
-        return tbl;
-    }
 }