ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [4/6] incubator-ignite git commit: #ignite-286: GridCacheSwapManager rawOffHeapIterator takes primary and backup flags.
Date Mon, 27 Apr 2015 14:38:59 GMT
#ignite-286: GridCacheSwapManager rawOffHeapIterator takes primary and backup flags.


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

Branch: refs/heads/ignite-286
Commit: 9b5f9b55d2a94e3820043726dda17c81c0a4fd66
Parents: 5df5725
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Mon Apr 27 16:59:53 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Mon Apr 27 16:59:53 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheSwapManager.java  | 39 +++++++++++++++-----
 .../cache/query/GridCacheQueryManager.java      | 15 +-------
 2 files changed, 32 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b5f9b55/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 3edad54..cd8a0c7 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
@@ -1224,7 +1224,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
         checkIteratorQueue();
 
         if (offHeapEnabled() && !swapEnabled())
-            return rawOffHeapIterator();
+            return rawOffHeapIterator(true, true);
 
         if (swapEnabled() && !offHeapEnabled())
             return rawSwapIterator();
@@ -1240,7 +1240,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
             private Map.Entry<byte[], byte[]> cur;
 
             {
-                it = rawOffHeapIterator();
+                it = rawOffHeapIterator(true, true);
 
                 advance();
             }
@@ -1569,31 +1569,52 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter
{
 
     /**
      * @param c Key/value closure.
+     * @param primary Include primaries.
+     * @param backup Include backups.
      * @return Off-heap iterator.
      */
-    public <T> GridCloseableIterator<T> rawOffHeapIterator(CX2<T2<Long,
Integer>, T2<Long, Integer>, T> c) {
+    public <T> GridCloseableIterator<T> rawOffHeapIterator(CX2<T2<Long,
Integer>, T2<Long, Integer>, T> c,
+                                                           boolean primary, boolean backup)
{
         assert c != null;
 
-        if (!offheapEnabled)
+        if (!offheapEnabled || (!primary && !backup))
             return new GridEmptyCloseableIterator<>();
 
         checkIteratorQueue();
 
-        return offheap.iterator(spaceName, c, cctx.grid().affinity(cctx.name()).allPartitions(cctx.grid().localNode()));
+        return offheap.iterator(spaceName, c, partitions(primary, backup));
     }
 
     /**
+     * @param primary Include primaries.
+     * @param backup Include backups.
      * @return Raw off-heap iterator.
      */
-    public GridCloseableIterator<Map.Entry<byte[], byte[]>> rawOffHeapIterator()
{
-        if (!offheapEnabled)
+    public GridCloseableIterator<Map.Entry<byte[], byte[]>> rawOffHeapIterator(boolean
primary, boolean backup) {
+        if (!offheapEnabled || (!primary && !backup))
             return new GridEmptyCloseableIterator<>();
 
-        return new OffHeapIterator(offheap.iterator(spaceName,
-            cctx.grid().affinity(cctx.name()).allPartitions(cctx.grid().localNode())));
+        return new OffHeapIterator(offheap.iterator(spaceName,partitions(primary, backup)));
     }
 
     /**
+     * @param primary Include primaries.
+     * @param backup Include backups.
+     * @return Partitions.
+     */
+    private int[] partitions(boolean primary, boolean backup) {
+        if (primary && backup)
+            return cctx.grid().affinity(cctx.name()).allPartitions(cctx.grid().localNode());
+
+        if (primary)
+            return cctx.grid().affinity(cctx.name()).primaryPartitions(cctx.grid().localNode());
+
+        if (backup)
+            return cctx.grid().affinity(cctx.name()).backupPartitions(cctx.grid().localNode());
+
+        return new int[0];
+    }
+    /**
      * @param part Partition.
      * @return Raw off-heap iterator.
      */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9b5f9b55/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 2ed429b..172a451 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -953,21 +953,10 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
         if (cctx.offheapTiered() && filter != null) {
             OffheapIteratorClosure c = new OffheapIteratorClosure(filter, qry.keepPortable());
 
-            return cctx.swap().rawOffHeapIterator(c);
+            return cctx.swap().rawOffHeapIterator(c, true, parts == null);
         }
         else {
-            Iterator<Map.Entry<byte[], byte[]>> it;
-
-            if (parts == null)
-                it = cctx.swap().rawOffHeapIterator();
-            else {
-                List<GridIterator<Map.Entry<byte[], byte[]>>> partIts =
new ArrayList<>();
-
-                for (Integer part : parts)
-                    partIts.add(cctx.swap().rawOffHeapIterator(part));
-
-                it = new CompoundIterator(partIts);
-            }
+            Iterator<Map.Entry<byte[], byte[]>> it = cctx.swap().rawOffHeapIterator(true,
parts == null);
 
             return scanIterator(it, filter, qry.keepPortable());
         }


Mime
View raw message