ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-4354: Sorted fields sorting logc in BinaryObjectBuilder. This closes #1759.
Date Mon, 10 Apr 2017 13:34:42 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 62a3b4d71 -> 5c48260f3


IGNITE-4354: Sorted fields sorting logc in BinaryObjectBuilder. This closes #1759.


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

Branch: refs/heads/master
Commit: 5c48260f3d79bafd72af87e19077f150831d07e9
Parents: 62a3b4d
Author: Alexander Paschenko <alexander.a.paschenko@gmail.com>
Authored: Mon Apr 10 16:34:35 2017 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Mon Apr 10 16:34:35 2017 +0300

----------------------------------------------------------------------
 .../binary/builder/BinaryObjectBuilderImpl.java | 36 +++++++++++---------
 1 file changed, 19 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5c48260f/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
index 6827c96..02e06fd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
@@ -500,6 +500,21 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
         }
     }
 
+    /**
+     * If value of {@link #assignedVals} is null, set it according to
+     * {@link BinaryUtils#FIELDS_SORTED_ORDER}.
+     */
+    private Map<String, Object> assignedValues() {
+        if (assignedVals == null) {
+            if (BinaryUtils.FIELDS_SORTED_ORDER)
+                assignedVals = new TreeMap<>();
+            else
+                assignedVals = new LinkedHashMap<>();
+        }
+
+        return assignedVals;
+    }
+
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public <T> T getField(String name) {
@@ -526,19 +541,12 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder
{
     @Override public BinaryObjectBuilder setField(String name, Object val0) {
         Object val = val0 == null ? new BinaryValueWithType(BinaryUtils.typeByClass(Object.class),
null) : val0;
 
-        if (assignedVals == null) {
-            if (BinaryUtils.FIELDS_SORTED_ORDER)
-                assignedVals = new TreeMap<>();
-            else
-                assignedVals = new LinkedHashMap<>();
-        }
-
-        Object oldVal = assignedVals.put(name, val);
+        Object oldVal = assignedValues().put(name, val);
 
         if (oldVal instanceof BinaryValueWithType && val0 != null) {
             ((BinaryValueWithType)oldVal).value(val);
 
-            assignedVals.put(name, oldVal);
+            assignedValues().put(name, oldVal);
         }
 
         return this;
@@ -555,10 +563,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
         else
             typeId = BinaryUtils.typeByClass(type);
 
-        if (assignedVals == null)
-            assignedVals = new LinkedHashMap<>();
-
-        assignedVals.put(name, new BinaryValueWithType(typeId, val));
+        assignedValues().put(name, new BinaryValueWithType(typeId, val));
 
         return this;
     }
@@ -578,10 +583,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
      * @return {@code this} instance for chaining.
      */
     @Override public BinaryObjectBuilderImpl removeField(String name) {
-        if (assignedVals == null)
-            assignedVals = new LinkedHashMap<>();
-
-        assignedVals.put(name, REMOVED_FIELD_MARKER);
+        assignedValues().put(name, REMOVED_FIELD_MARKER);
 
         return this;
     }


Mime
View raw message