ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [19/50] [abbrv] incubator-ignite git commit: ignite-223 review
Date Thu, 19 Feb 2015 12:59:05 GMT
ignite-223 review


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

Branch: refs/heads/ignite-283
Commit: c73220712f9f044758b00b39fb57c40a8846b243
Parents: 7e0c9ca
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Wed Feb 18 18:54:18 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Wed Feb 18 18:54:18 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheSwapManager.java  | 43 ++++++++++----------
 1 file changed, 21 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c7322071/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
index 940b346..0a7b768 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
@@ -724,7 +724,8 @@ public class GridCacheSwapManager<K, V> extends GridCacheManagerAdapter<K,
V> {
      * @return Collection of swap entries.
      * @throws IgniteCheckedException If failed,
      */
-    public Collection<GridCacheBatchSwapEntry<K, V>> readAndRemove(Collection<?
extends K> keys) throws IgniteCheckedException {
+    public Collection<GridCacheBatchSwapEntry<K, V>> readAndRemove(Collection<?
extends K> keys)
+        throws IgniteCheckedException {
         if (!offheapEnabled && !swapEnabled)
             return Collections.emptyList();
 
@@ -732,13 +733,11 @@ public class GridCacheSwapManager<K, V> extends GridCacheManagerAdapter<K,
V> {
 
         final GridCacheQueryManager<K, V> qryMgr = cctx.queries();
 
-        Collection<? extends K> unprocessedKeys;
+        Collection<SwapKey> unprocessedKeys = null;
         final Collection<GridCacheBatchSwapEntry<K, V>> res = new ArrayList<>(keys.size());
 
         // First try removing from offheap.
         if (offheapEnabled) {
-            Collection<K> unprocessedKeysList = new ArrayList<>(keys.size());
-
             for (K key : keys) {
                 int part = cctx.affinity().partition(key);
 
@@ -778,33 +777,33 @@ public class GridCacheSwapManager<K, V> extends GridCacheManagerAdapter<K,
V> {
                     }
                 }
 
-                unprocessedKeysList.add(key);
-            }
+                if (swapEnabled) {
+                    if (unprocessedKeys == null)
+                        unprocessedKeys = new ArrayList<>(keys.size());
 
-            unprocessedKeys = unprocessedKeysList;
+                    unprocessedKeys.add(
+                        new SwapKey(key, cctx.affinity().partition(key), CU.marshal(cctx.shared(),
key)));
+                }
+            }
 
-            if (!swapEnabled || unprocessedKeys.isEmpty())
+            if (unprocessedKeys == null)
                 return res;
         }
-        else
-            unprocessedKeys = keys;
+        else {
+            unprocessedKeys = new ArrayList<>(keys.size());
+
+            for (K key : keys)
+                unprocessedKeys.add(new SwapKey(key, cctx.affinity().partition(key), CU.marshal(cctx.shared(),
key)));
+        }
+
+        assert swapEnabled;
+        assert unprocessedKeys != null;
 
         // Swap is enabled.
         final GridTuple<IgniteCheckedException> err = F.t1();
 
-        Collection<SwapKey> converted = new ArrayList<>(F.viewReadOnly(unprocessedKeys,
new C1<K, SwapKey>() {
-            @Override public SwapKey apply(K key) {
-                try {
-                    return new SwapKey(key, cctx.affinity().partition(key), CU.marshal(cctx.shared(),
key));
-                }
-                catch (IgniteCheckedException e) {
-                    throw new IgniteException(e);
-                }
-            }
-        }));
-
         swapMgr.removeAll(spaceName,
-            converted,
+            unprocessedKeys,
             new IgniteBiInClosure<SwapKey, byte[]>() {
                 @Override public void apply(SwapKey swapKey, byte[] rmv) {
                     if (rmv != null) {


Mime
View raw message