Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-286 9373e43da -> 83f972149


#ignite-286: refactoring.


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

Branch: refs/heads/ignite-286
Commit: 027da921cacfe51c1668e666daead8319aea86c4
Parents: 9373e43
Author: ivasilinets <[email protected]>
Authored: Mon Apr 27 17:48:29 2015 +0300
Committer: ivasilinets <[email protected]>
Committed: Mon Apr 27 17:48:29 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheSwapManager.java  | 95 +++++++-------------
 1 file changed, 30 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/027da921/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 8b33c19..208f1a8 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
@@ -1321,8 +1321,7 @@ public class GridCacheSwapManager extends 
GridCacheManagerAdapter {
             return F.emptyIterator();
 
         if (primary && backup)
-            return keyIterator(offheap.iterator(spaceName,
-                
cctx.grid().affinity(cctx.name()).allPartitions(cctx.grid().localNode())));
+            return keyIterator(offheap.iterator(spaceName, partitions(primary, 
backup)));
 
         Set<Integer> parts = primary ? 
cctx.affinity().primaryPartitions(cctx.localNodeId(), topVer) :
             cctx.affinity().backupPartitions(cctx.localNodeId(), topVer);
@@ -1368,8 +1367,7 @@ public class GridCacheSwapManager extends 
GridCacheManagerAdapter {
         if (!offheapEnabled)
             return new GridEmptyCloseableIterator<>();
 
-        return lazyIterator(offheap.iterator(spaceName,
-            
cctx.grid().affinity(cctx.name()).allPartitions(cctx.grid().localNode())));
+        return lazyIterator(offheap.iterator(spaceName, partitions(true, 
true)));
     }
 
     /**
@@ -1574,7 +1572,7 @@ public class GridCacheSwapManager extends 
GridCacheManagerAdapter {
      * @return Off-heap iterator.
      */
     public <T> GridCloseableIterator<T> rawOffHeapIterator(CX2<T2<Long, 
Integer>, T2<Long, Integer>, T> c,
-                                                           boolean primary, 
boolean backup) {
+        boolean primary, boolean backup) {
         assert c != null;
 
         if (!offheapEnabled || (!primary && !backup))
@@ -1590,11 +1588,36 @@ public class GridCacheSwapManager extends 
GridCacheManagerAdapter {
      * @param backup Include backups.
      * @return Raw off-heap iterator.
      */
-    public GridCloseableIterator<Map.Entry<byte[], byte[]>> 
rawOffHeapIterator(boolean primary, boolean backup) {
+    public GridCloseableIterator<Map.Entry<byte[], byte[]>> 
rawOffHeapIterator(final boolean primary, final boolean backup) {
         if (!offheapEnabled || (!primary && !backup))
             return new GridEmptyCloseableIterator<>();
 
-        return new 
OffHeapIterator(offheap.iterator(spaceName,partitions(primary, backup)));
+        return new GridCloseableIteratorAdapter<Map.Entry<byte[], byte[]>>() {
+            private GridCloseableIterator<IgniteBiTuple<byte[], byte[]>> it =
+                offheap.iterator(spaceName, partitions(primary, backup));
+
+            private Map.Entry<byte[], byte[]> cur;
+
+            @Override protected Map.Entry<byte[], byte[]> onNext() {
+                return cur = it.next();
+            }
+
+            @Override protected boolean onHasNext() {
+                return it.hasNext();
+            }
+
+            @Override protected void onRemove() throws IgniteCheckedException {
+                KeyCacheObject key = cctx.toCacheKeyObject(cur.getKey());
+
+                int part = cctx.affinity().partition(key);
+
+                offheap.removex(spaceName, part, key, 
key.valueBytes(cctx.cacheObjectContext()));
+            }
+
+            @Override protected void onClose() throws IgniteCheckedException {
+                it.close();
+            }
+        };
     }
 
     /**
@@ -1659,20 +1682,6 @@ public class GridCacheSwapManager extends 
GridCacheManagerAdapter {
     }
 
     /**
-     * @param part Partition.
-     * @return Raw off-heap iterator.
-     * @throws IgniteCheckedException If failed.
-     */
-    public GridCloseableIterator<Map.Entry<byte[], byte[]>> 
rawSwapIterator(int part) throws IgniteCheckedException {
-        if (!swapEnabled)
-            return new GridEmptyCloseableIterator<>();
-
-        checkIteratorQueue();
-
-        return swapMgr.rawIterator(spaceName, part);
-    }
-
-    /**
      * @param primary If {@code true} includes primary entries.
      * @param backup If {@code true} includes backup entries.
      * @param topVer Topology version.
@@ -2093,48 +2102,4 @@ public class GridCacheSwapManager extends 
GridCacheManagerAdapter {
         abstract protected Iterator<KeyCacheObject> partitionIterator(int part)
             throws IgniteCheckedException;
     }
-
-    /**
-     * Raw off-heap iterator.
-     */
-    private class OffHeapIterator extends 
GridCloseableIteratorAdapter<Map.Entry<byte[], byte[]>> {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** Internal off-heap iterator. */
-        private final GridCloseableIterator<IgniteBiTuple<byte[], byte[]>> it;
-
-        /** Current entry. */
-        private Map.Entry<byte[], byte[]> cur;
-
-        /**
-         * @param it Internal off-heap iterator.
-         */
-        public OffHeapIterator(GridCloseableIterator<IgniteBiTuple<byte[], 
byte[]>> it) {
-            this.it = it;
-        }
-
-        /** {@inheritDoc} */
-        @Override protected Map.Entry<byte[], byte[]> onNext() {
-            return cur = it.next();
-        }
-
-        /** {@inheritDoc} */
-        @Override protected boolean onHasNext() {
-            return it.hasNext();
-        }
-
-        /** {@inheritDoc} */
-        @Override protected void onRemove() throws IgniteCheckedException {
-            KeyCacheObject key = cctx.toCacheKeyObject(cur.getKey());
-            int part = cctx.affinity().partition(key);
-
-            offheap.removex(spaceName, part, key, 
key.valueBytes(cctx.cacheObjectContext()));
-        }
-
-        /** {@inheritDoc} */
-        @Override protected void onClose() throws IgniteCheckedException {
-            it.close();
-        }
-    }
 }

Reply via email to