You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/12/06 08:40:33 UTC

[36/50] ignite git commit: IGNITE-4343: Fixed update logic in DmlStatementsProcessor. This closes #1304.

IGNITE-4343: Fixed update logic in DmlStatementsProcessor. This closes #1304.


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

Branch: refs/heads/ignite-comm-balance-master
Commit: b2692adace32b7308ce53d5f93bd56c506eeed36
Parents: af24a9e
Author: Alexander Paschenko <al...@gmail.com>
Authored: Fri Dec 2 12:48:08 2016 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Fri Dec 2 12:48:08 2016 +0300

----------------------------------------------------------------------
 .../query/h2/DmlStatementsProcessor.java        | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b2692ada/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 d57f95f..c2c8726 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
@@ -492,6 +492,9 @@ public class DmlStatementsProcessor {
 
             newVal = plan.valSupplier.apply(e);
 
+            if (newVal == null)
+                throw new IgniteSQLException("New value for UPDATE must not be null", IgniteQueryErrorCode.NULL_VALUE);
+
             if (bin && !(val instanceof BinaryObject))
                 val = cctx.grid().binary().toBinary(val);
 
@@ -858,7 +861,7 @@ public class DmlStatementsProcessor {
 
         /** {@inheritDoc} */
         @Override public Boolean process(MutableEntry<Object, Object> entry, Object... arguments) throws EntryProcessorException {
-            if (entry.getValue() != null)
+            if (entry.exists())
                 return false;
 
             entry.setValue(val);
@@ -878,17 +881,28 @@ public class DmlStatementsProcessor {
 
         /** */
         private ModifyingEntryProcessor(Object val, IgniteInClosure<MutableEntry<Object, Object>> entryModifier) {
+            assert val != null;
+
             this.val = val;
             this.entryModifier = entryModifier;
         }
 
         /** {@inheritDoc} */
         @Override public Boolean process(MutableEntry<Object, Object> entry, Object... arguments) throws EntryProcessorException {
+            if (!entry.exists())
+                return null; // Someone got ahead of us and removed this entry, let's skip it.
+
+            Object entryVal = entry.getValue();
+
+            if (entryVal == null)
+                return null;
+
             // Something happened to the cache while we were performing map-reduce.
-            if (!F.eq(entry.getValue(), val))
+            if (!F.eq(entryVal, val))
                 return false;
 
             entryModifier.apply(entry);
+
             return null; // To leave out only erroneous keys - nulls are skipped on results' processing.
         }
     }
@@ -910,6 +924,8 @@ public class DmlStatementsProcessor {
 
         /** */
         private EntryValueUpdater(Object val) {
+            assert val != null;
+
             this.val = val;
         }