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:17 UTC
[20/31] ignite git commit: Minors.
Minors.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/850cd7e2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/850cd7e2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/850cd7e2
Branch: refs/heads/ignite-6022-proto
Commit: 850cd7e2ba077132a8127f373b4c97e51d092685
Parents: 7a9cd6a
Author: devozerov <vo...@gridgain.com>
Authored: Mon Dec 18 11:53:00 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Dec 18 11:53:00 2017 +0300
----------------------------------------------------------------------
.../query/h2/DmlStatementsProcessor.java | 17 +++------
.../processors/query/h2/dml/UpdatePlan.java | 22 +++++++----
.../query/h2/dml/UpdatePlanBuilder.java | 40 ++++++++++----------
3 files changed, 41 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/850cd7e2/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 4ca034e..7f1f5d5 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
@@ -52,7 +52,6 @@ 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.FastUpdate;
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;
@@ -169,7 +168,7 @@ public class DmlStatementsProcessor {
UpdateResult r;
try {
- r = executeUpdateStatement(schemaName, cctx, conn, prepared, fieldsQry, loc, filters, cancel, errKeys);
+ r = executeUpdateStatement(schemaName, cctx, conn, prepared, fieldsQry, loc, filters, cancel);
}
finally {
cctx.operationContextPerCall(opCtx);
@@ -337,27 +336,23 @@ public class DmlStatementsProcessor {
* @param loc Local query flag.
* @param filters Cache name and key filter.
* @param cancel Query cancel state holder.
- * @param failedKeys Keys to restrict UPDATE and DELETE operations with. Null or empty array means no restriction.
* @return Pair [number of successfully processed items; keys that have failed to be processed]
* @throws IgniteCheckedException if failed.
*/
@SuppressWarnings({"ConstantConditions", "unchecked"})
private UpdateResult executeUpdateStatement(String schemaName, final GridCacheContext cctx, Connection c,
- Prepared prepared, SqlFieldsQuery fieldsQry, boolean loc, IndexingQueryFilter filters,
- GridQueryCancel cancel, Object[] failedKeys) throws IgniteCheckedException {
+ Prepared prepared, SqlFieldsQuery fieldsQry, boolean loc, IndexingQueryFilter filters, GridQueryCancel cancel)
+ throws IgniteCheckedException {
int mainCacheId = cctx.cacheId();
Integer errKeysPos = null;
UpdatePlan plan = getPlanForStatement(schemaName, c, prepared, fieldsQry, loc, errKeysPos);
- FastUpdate fastUpdate = plan.fastUpdate();
-
- if (fastUpdate != null) {
- assert F.isEmpty(failedKeys) && errKeysPos == null;
+ UpdateResult fastUpdateRes = plan.processFast(fieldsQry.getArgs());
- return fastUpdate.execute(plan.cacheContext().cache(), fieldsQry.getArgs());
- }
+ if (fastUpdateRes != null)
+ return fastUpdateRes;
if (plan.distributedPlan() != null) {
UpdateResult result = doDistributedUpdate(schemaName, fieldsQry, plan, cancel);
http://git-wip-us.apache.org/repos/asf/ignite/blob/850cd7e2/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 f33331a..10e7519 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
@@ -29,6 +29,7 @@ import org.apache.ignite.internal.processors.query.GridQueryProperty;
import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
import org.apache.ignite.internal.processors.query.IgniteSQLException;
import org.apache.ignite.internal.processors.query.QueryUtils;
+import org.apache.ignite.internal.processors.query.h2.UpdateResult;
import org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor;
import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table;
import org.apache.ignite.internal.util.typedef.F;
@@ -345,6 +346,20 @@ public final class UpdatePlan {
}
/**
+ * Process fast DML operation if possible.
+ *
+ * @param args QUery arguments.
+ * @return Update result or {@code null} if fast update is not applicable for plan.
+ * @throws IgniteCheckedException If failed.
+ */
+ public UpdateResult processFast(Object[] args) throws IgniteCheckedException {
+ if (fastUpdate != null)
+ return fastUpdate.execute(cacheContext().cache(), args);
+
+ return null;
+ }
+
+ /**
* @return Update mode.
*/
public UpdateMode mode() {
@@ -387,13 +402,6 @@ public final class UpdatePlan {
}
/**
- * @return Fast update.
- */
- @Nullable public FastUpdate fastUpdate() {
- return fastUpdate;
- }
-
- /**
* @return Names of affected columns.
*/
public String[] columnNames() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/850cd7e2/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java
index bbbff17..563456b 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java
@@ -130,8 +130,6 @@ public final class UpdatePlanBuilder {
List<GridSqlElement[]> elRows = null;
- List<List<DmlArgument>> rows = null;
-
if (stmt instanceof GridSqlInsert) {
GridSqlInsert ins = (GridSqlInsert) stmt;
target = ins.into();
@@ -170,24 +168,6 @@ public final class UpdatePlanBuilder {
IgniteQueryErrorCode.UNEXPECTED_OPERATION);
}
- if (elRows != null) {
- assert sel == null;
-
- rows = new ArrayList<>(elRows.size());
-
- for (GridSqlElement[] elRow : elRows) {
- List<DmlArgument> row = new ArrayList<>(cols.length);
-
- for (GridSqlElement e : elRow) {
- DmlArgument arg = DmlArguments.create(e);
-
- row.add(arg);
- }
-
- rows.add(row);
- }
- }
-
// Let's set the flag only for subqueries that have their FROM specified.
isTwoStepSubqry &= (sel != null && (sel instanceof GridSqlUnion ||
(sel instanceof GridSqlSelect && ((GridSqlSelect) sel).from() != null)));
@@ -248,6 +228,26 @@ public final class UpdatePlanBuilder {
UpdateMode mode = stmt instanceof GridSqlMerge ? UpdateMode.MERGE : UpdateMode.INSERT;
+ List<List<DmlArgument>> rows = null;
+
+ if (elRows != null) {
+ assert sel == null;
+
+ rows = new ArrayList<>(elRows.size());
+
+ for (GridSqlElement[] elRow : elRows) {
+ List<DmlArgument> row = new ArrayList<>(cols.length);
+
+ for (GridSqlElement el : elRow) {
+ DmlArgument arg = DmlArguments.create(el);
+
+ row.add(arg);
+ }
+
+ rows.add(row);
+ }
+ }
+
return new UpdatePlan(
mode,
tbl.dataTable(),