ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [37/50] ignite git commit: ignite-db - reuse tests
Date Thu, 28 Apr 2016 08:53:07 GMT
ignite-db - reuse tests


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

Branch: refs/heads/ignite-db-x-10884
Commit: bbcf8fe4024dfec42cb33e3ff61bc6ba94d072df
Parents: c523c6f
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Wed Apr 27 02:58:12 2016 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Wed Apr 27 02:58:12 2016 +0300

----------------------------------------------------------------------
 .../cache/database/tree/BPlusTree.java          | 10 ++++
 .../cache/database/tree/reuse/ReuseList.java    | 17 +++++--
 .../cache/database/tree/reuse/ReuseTree.java    |  2 +-
 .../database/tree/reuse/io/ReuseInnerIO.java    |  2 +-
 .../database/tree/reuse/io/ReuseLeafIO.java     |  2 +-
 .../database/BPlusTreeReuseSelfTest.java        | 34 +++++++++++++
 .../processors/database/BPlusTreeSelfTest.java  | 52 +++++++++++++++-----
 7 files changed, 101 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/bbcf8fe4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
index e712a41..df853c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
@@ -1001,6 +1001,16 @@ public abstract class BPlusTree<L, T extends L> {
      }
 
     /**
+     * @return Root level.
+     * @throws IgniteCheckedException If failed.
+     */
+    public final int rootLevel() throws IgniteCheckedException {
+        try (Page meta = page(metaPageId)) {
+            return getRootLevel(meta);
+        }
+    }
+
+    /**
      * TODO may produce wrong results on concurrent access
      *
      * @return Size.

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbcf8fe4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseList.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseList.java
index a40fa18..f494dad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseList.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseList.java
@@ -28,7 +28,7 @@ import org.apache.ignite.lang.IgniteBiTuple;
 /**
  * Reuse list for index pages.
  */
-public class ReuseList {
+public final class ReuseList {
     /** */
     private static final FullPageId MIN = new FullPageId(0,0);
 
@@ -60,12 +60,23 @@ public class ReuseList {
     }
 
     /**
+     * @return Size.
+     * @throws IgniteCheckedException If failed.
+     */
+    public long size() throws IgniteCheckedException {
+        long size = 0;
+
+        for (ReuseTree tree : trees)
+            size += tree.size();
+
+        return size;
+    }
+
+    /**
      * @param client Client.
      * @return Reuse tree.
      */
     private ReuseTree tree(BPlusTree<?,?> client) {
-        assert trees.length > 1;
-
         int treeIdx = client.randomInt(trees.length);
 
         ReuseTree tree = trees[treeIdx];

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbcf8fe4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseTree.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseTree.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseTree.java
index 6206465..e7e6a1b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseTree.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseTree.java
@@ -33,7 +33,7 @@ import org.apache.ignite.internal.processors.cache.database.tree.reuse.io.ReuseL
 /**
  * Reuse tree for index pages.
  */
-public class ReuseTree extends BPlusTree<FullPageId, FullPageId> {
+public final class ReuseTree extends BPlusTree<FullPageId, FullPageId> {
     /**
      * @param reuseList Reuse list.
      * @param cacheId Cache ID.

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbcf8fe4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseInnerIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseInnerIO.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseInnerIO.java
index 18313e7..522efba 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseInnerIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseInnerIO.java
@@ -29,7 +29,7 @@ import org.apache.ignite.internal.processors.cache.database.tree.io.IOVersions;
 /**
  * Reuse list inner page IO routines.
  */
-public class ReuseInnerIO extends BPlusInnerIO<FullPageId> {
+public final class ReuseInnerIO extends BPlusInnerIO<FullPageId> {
     /** */
     public static final IOVersions<ReuseInnerIO> VERSIONS = new IOVersions<>(
         new ReuseInnerIO(1)

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbcf8fe4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseLeafIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseLeafIO.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseLeafIO.java
index bf46024..3d2d37a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseLeafIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseLeafIO.java
@@ -28,7 +28,7 @@ import org.apache.ignite.internal.processors.cache.database.tree.io.IOVersions;
 /**
  * Reuse list leaf page IO routines.
  */
-public class ReuseLeafIO extends BPlusLeafIO<FullPageId> {
+public final class ReuseLeafIO extends BPlusLeafIO<FullPageId> {
     /** */
     public static final IOVersions<ReuseLeafIO> VERSIONS = new IOVersions<>(
         new ReuseLeafIO(1)

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbcf8fe4/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeReuseSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeReuseSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeReuseSelfTest.java
new file mode 100644
index 0000000..a70bb1d
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeReuseSelfTest.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.database;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.pagemem.PageMemory;
+import org.apache.ignite.internal.processors.cache.database.MetaStore;
+import org.apache.ignite.internal.processors.cache.database.tree.reuse.ReuseList;
+
+/**
+ * Test with reuse.
+ */
+public class BPlusTreeReuseSelfTest extends BPlusTreeSelfTest {
+    /** {@inheritDoc} */
+    @Override protected ReuseList createReuseList(int cacheId, PageMemory pageMem, int segments,
MetaStore metaStore)
+        throws IgniteCheckedException {
+        return new ReuseList(cacheId, pageMem, segments, metaStore);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbcf8fe4/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
index 813fdc3..7258f36 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
@@ -27,13 +27,16 @@ import org.apache.ignite.internal.pagemem.FullPageId;
 import org.apache.ignite.internal.pagemem.PageIdAllocator;
 import org.apache.ignite.internal.pagemem.PageMemory;
 import org.apache.ignite.internal.pagemem.impl.PageMemoryImpl;
+import org.apache.ignite.internal.processors.cache.database.MetaStore;
 import org.apache.ignite.internal.processors.cache.database.tree.BPlusTree;
 import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusInnerIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusLeafIO;
 import org.apache.ignite.internal.processors.cache.database.tree.reuse.ReuseList;
 import org.apache.ignite.internal.util.lang.GridCursor;
+import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
 /**
@@ -75,10 +78,10 @@ public class BPlusTreeSelfTest extends GridCommonAbstractTest {
     /** */
     private ReuseList reuseList;
 
-    @Override
-    protected long getTestTimeout() {
-        return 25 * 60 * 1000;
-    }
+//    /** {@inheritDoc} */
+//    @Override protected long getTestTimeout() {
+//        return 25 * 60 * 1000;
+//    }
 
     /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
@@ -92,17 +95,35 @@ public class BPlusTreeSelfTest extends GridCommonAbstractTest {
 
         pageMem.start();
 
-        reuseList = null;
-//            new ReuseList(CACHE_ID, pageMem, 2, new MetaStore() {
-//            @Override public IgniteBiTuple<FullPageId,Boolean> getOrAllocateForIndex(int
cacheId, String idxName)
-//                throws IgniteCheckedException {
-//                return new T2<>(allocatePage(), true);
-//            }
-//        });
+        reuseList = createReuseList(CACHE_ID, pageMem, 2, new MetaStore() {
+            @Override public IgniteBiTuple<FullPageId,Boolean> getOrAllocateForIndex(int
cacheId, String idxName)
+                throws IgniteCheckedException {
+                return new T2<>(allocatePage(), true);
+            }
+        });
+    }
+
+    /**
+     * @param cacheId Cache ID.
+     * @param pageMem Page memory.
+     * @param segments Segments.
+     * @param metaStore Store.
+     * @return Reuse list.
+     * @throws IgniteCheckedException If failed.
+     */
+    protected ReuseList createReuseList(int cacheId, PageMemory pageMem, int segments, MetaStore
metaStore)
+        throws IgniteCheckedException {
+        return null;
     }
 
     /** {@inheritDoc} */
     @Override protected void afterTest() throws Exception {
+        if (reuseList != null) {
+            long size = reuseList.size();
+
+            assertTrue("Reuse size: " + size, size < CNT);
+        }
+
         pageMem.stop();
 
         MAX_PER_PAGE = 0;
@@ -438,6 +459,8 @@ public class BPlusTreeSelfTest extends GridCommonAbstractTest {
         }
 
         assertFalse(tree.find(null, null).next());
+        assertEquals(0, tree.size());
+        assertEquals(0, tree.rootLevel());
     }
 
     /**
@@ -505,7 +528,12 @@ public class BPlusTreeSelfTest extends GridCommonAbstractTest {
      * @throws IgniteCheckedException If failed.
      */
     private TestTree createTestTree(boolean canGetRow) throws IgniteCheckedException {
-        return new TestTree(reuseList, canGetRow, CACHE_ID, pageMem, allocatePage());
+        TestTree tree = new TestTree(reuseList, canGetRow, CACHE_ID, pageMem, allocatePage());
+
+        assertEquals(0, tree.size());
+        assertEquals(0, tree.rootLevel());
+
+        return tree;
     }
 
     /**


Mime
View raw message