You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/04/11 12:35:42 UTC

[09/17] ignite git commit: IGNITE-4826: Fix eviction to swap if segmented index is used. This closes #1628.

IGNITE-4826: Fix eviction to swap if segmented index is used. This closes #1628.


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

Branch: refs/heads/ignite-4932
Commit: a54b7c6d76974f833e451aff947456ea0013226b
Parents: 9b9c325
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Tue Mar 28 18:49:03 2017 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Tue Mar 28 18:49:03 2017 +0300

----------------------------------------------------------------------
 .../query/h2/opt/GridH2TreeIndex.java           |  4 +--
 .../query/IgniteSqlSegmentedIndexSelfTest.java  | 30 ++++++++++++++++++--
 2 files changed, 30 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a54b7c6d/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
index 2873211..663d863 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
@@ -286,8 +286,8 @@ public class GridH2TreeIndex extends GridH2IndexBase implements Comparator<GridS
      * @param row Search row.
      * @return Row.
      */
-    public GridH2Row findOne(GridSearchRowPointer row) {
-        int seg = threadLocalSegment();
+    GridH2Row findOne(GridSearchRowPointer row) {
+        int seg = segmentForRow(row);
 
         return segments[seg].get(row);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a54b7c6d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java
index f8c9dd5..800138c 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java
@@ -27,6 +27,7 @@ import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheKeyConfiguration;
 import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
 import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -34,6 +35,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
 /**
@@ -63,6 +65,8 @@ public class IgniteSqlSegmentedIndexSelfTest extends GridCommonAbstractTest {
 
         cfg.setDiscoverySpi(disco);
 
+        cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+
         return cfg;
     }
 
@@ -77,7 +81,7 @@ public class IgniteSqlSegmentedIndexSelfTest extends GridCommonAbstractTest {
      * @param idxTypes Indexed types.
      * @return Cache configuration.
      */
-    private static <K, V> CacheConfiguration<K, V> cacheConfig(String name, boolean partitioned, Class<?>... idxTypes) {
+    protected <K, V> CacheConfiguration<K, V> cacheConfig(String name, boolean partitioned, Class<?>... idxTypes) {
         return new CacheConfiguration<K, V>()
             .setName(name)
             .setCacheMode(partitioned ? CacheMode.PARTITIONED : CacheMode.REPLICATED)
@@ -104,6 +108,28 @@ public class IgniteSqlSegmentedIndexSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * Run tests on single-node grid
+     * @throws Exception If failed.
+     */
+    public void testSingleNodeIndexSegmentationWithSwapEnabled() throws Exception {
+        startGridsMultiThreaded(1, true);
+
+        final IgniteCache<Object, Object> cache = ignite(0).createCache(cacheConfig("org", true, Integer.class, Organization.class)
+            .setOffHeapMaxMemory(-1)
+            .setSwapEnabled(true)
+            .setEvictionPolicy(new FifoEvictionPolicy(10)));
+
+        for (int i = 0; i < 20; i++)
+            cache.put(i, new Organization("org-" + i));
+
+        String select0 = "select name from \"org\".Organization";
+
+        List<List<?>> result = cache.query(new SqlFieldsQuery(select0)).getAll();
+
+        assertEquals(20, result.size());
+    }
+
+    /**
      * Run tests on multi-node grid
      * @throws Exception If failed.
      */
@@ -170,7 +196,7 @@ public class IgniteSqlSegmentedIndexSelfTest extends GridCommonAbstractTest {
 
         Set<Integer> localOrgIds = new HashSet<>();
 
-        for(Cache.Entry<Integer, Organization> e : c2.localEntries())
+        for (Cache.Entry<Integer, Organization> e : c2.localEntries())
             localOrgIds.add(e.getKey());
 
         int expectedPersons = 0;