ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [04/50] ignite git commit: KeyValueDirtyTrackedCollection applyChanges done
Date Thu, 08 Sep 2016 14:45:46 GMT
KeyValueDirtyTrackedCollection applyChanges done


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

Branch: refs/heads/ignite-3199-1
Commit: ae4a4a1235dc8408cd6052065522a7998a949a9c
Parents: 31e36f3
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Mon Sep 5 16:36:19 2016 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Mon Sep 5 16:36:19 2016 +0300

----------------------------------------------------------------------
 .../KeyValueDirtyTrackedCollection.java         | 50 +++++++++-----------
 .../platform/websession/SessionStateData.java   | 13 +++--
 2 files changed, 30 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ae4a4a12/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/KeyValueDirtyTrackedCollection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/KeyValueDirtyTrackedCollection.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/KeyValueDirtyTrackedCollection.java
index e963d723..3027868 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/KeyValueDirtyTrackedCollection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/KeyValueDirtyTrackedCollection.java
@@ -25,14 +25,16 @@ import org.apache.ignite.binary.BinaryWriter;
 import org.apache.ignite.binary.Binarylizable;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Web session lock info.
  */
 public class KeyValueDirtyTrackedCollection implements Binarylizable {
     /** */
-    private List<Entry> list;
+    private HashMap<String, byte[]> entries;
 
     /** */
     private List<String> removedKeys;
@@ -45,11 +47,11 @@ public class KeyValueDirtyTrackedCollection implements Binarylizable {
 
         raw.writeBoolean(true);  // Always full mode.
 
-        raw.writeInt(list.size());
+        raw.writeInt(entries.size());
 
-        for (Entry e : list) {
-            raw.writeString(e.key);
-            raw.writeByteArray(e.value);
+        for (Map.Entry<String, byte[]> e : entries.entrySet()) {
+            raw.writeString(e.getKey());
+            raw.writeByteArray(e.getValue());
         }
     }
 
@@ -61,10 +63,10 @@ public class KeyValueDirtyTrackedCollection implements Binarylizable {
 
         int count = raw.readInt();
 
-        list = new ArrayList<>(count);
+        entries = new HashMap<>(count);
 
         for (int i = 0; i < count; i++)
-            list.add(new Entry(raw.readString(), raw.readByteArray()));
+            entries.put(raw.readString(), raw.readByteArray());
 
         if (isDiff) {
             count = raw.readInt();
@@ -79,29 +81,21 @@ public class KeyValueDirtyTrackedCollection implements Binarylizable {
     /**
      * Apply changes from another instance.
      *
-     * @param items Items.
+     * @param other Items.
      */
-    public void applyChanges(KeyValueDirtyTrackedCollection items) {
+    public void applyChanges(KeyValueDirtyTrackedCollection other) {
+        assert other != null;
 
-    }
-
-    /** Entry. */
-    private static class Entry {
-        /** */
-        private String key;
-
-        /** */
-        private byte[] value;
-
-        /**
-         * Ctor.
-         *
-         * @param key Key
-         * @param value Value.
-         */
-        private Entry(String key, byte[] value) {
-            this.key = key;
-            this.value = value;
+        if (other.removedKeys != null) {
+            for (String key : other.removedKeys)
+                entries.remove(key);
         }
+        else {
+            // Not a diff: remove all
+            entries.clear();
+        }
+
+        for (Map.Entry<String, byte[]> e : other.entries.entrySet())
+            entries.put(e.getKey(), e.getValue());
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ae4a4a12/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateData.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateData.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateData.java
index 509bbb3..bd37d75 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateData.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/websession/SessionStateData.java
@@ -103,11 +103,14 @@ public class SessionStateData implements Binarylizable {
     /**
      * Apply changes from another instance.
      *
-     * @param data Data.
+     * @param other Data.
      */
-    public void applyChanges(SessionStateData data) {
-        timeout = data.timeout;
-        staticObjects = data.staticObjects;
-        items.applyChanges(data.items);
+    public void applyChanges(SessionStateData other) {
+        assert other != null;
+        assert items != null;
+
+        timeout = other.timeout;
+        staticObjects = other.staticObjects;
+        items.applyChanges(other.items);
     }
 }


Mime
View raw message