ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [23/50] [abbrv] ignite git commit: ignite-db - rename
Date Tue, 19 Apr 2016 12:58:40 GMT
ignite-db - rename


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

Branch: refs/heads/ignite-db-x-10884
Commit: 8218c2d02861df718d2313e3015c92cda53cdfba
Parents: e895804
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Wed Apr 13 00:29:44 2016 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Wed Apr 13 00:29:44 2016 +0300

----------------------------------------------------------------------
 .../cache/database/tree/BPlusTree.java          |  26 ++--
 .../cache/database/tree/io/BPlusIOInner.java    | 131 -------------------
 .../cache/database/tree/io/BPlusIOLeaf.java     |  84 ------------
 .../cache/database/tree/io/BPlusIOMeta.java     | 117 -----------------
 .../cache/database/tree/io/BPlusInnerIO.java    | 131 +++++++++++++++++++
 .../cache/database/tree/io/BPlusLeafIO.java     |  84 ++++++++++++
 .../cache/database/tree/io/BPlusMetaIO.java     | 117 +++++++++++++++++
 .../query/h2/database/BPlusTreeIndex.java       |   8 +-
 .../query/h2/database/io/H2InnerIO.java         |   4 +-
 .../query/h2/database/io/H2LeafIO.java          |   4 +-
 10 files changed, 353 insertions(+), 353 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8218c2d0/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 9a4dab5..2d54a0a 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
@@ -30,9 +30,9 @@ import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.pagemem.FullPageId;
 import org.apache.ignite.internal.pagemem.Page;
 import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIO;
-import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIOInner;
-import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIOLeaf;
-import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIOMeta;
+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.io.BPlusMetaIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.PageIO;
 import org.apache.ignite.internal.processors.cache.database.tree.util.PageHandler;
 import org.apache.ignite.internal.util.lang.GridCursor;
@@ -421,7 +421,7 @@ public abstract class BPlusTree<L, T extends L> {
         @Override public int run(Page page, ByteBuffer buf, Long pageId, int lvl) throws
IgniteCheckedException {
             assert pageId != null;
 
-            BPlusIOMeta io = BPlusIOMeta.VERSIONS.forPage(buf);
+            BPlusMetaIO io = BPlusMetaIO.VERSIONS.forPage(buf);
 
             assert io.getLevelsCount(buf) > lvl;
 
@@ -440,7 +440,7 @@ public abstract class BPlusTree<L, T extends L> {
     /** */
     private final PageHandler<Long> updateRoot = new PageHandler<Long>() {
         @Override public int run(Page page, ByteBuffer buf, Long rootPageId, int lvl) throws
IgniteCheckedException {
-            BPlusIOMeta io = BPlusIOMeta.VERSIONS.forPage(buf);
+            BPlusMetaIO io = BPlusMetaIO.VERSIONS.forPage(buf);
 
             int cnt = io.getLevelsCount(buf);
 
@@ -471,7 +471,7 @@ public abstract class BPlusTree<L, T extends L> {
             try (Page meta = page(this.metaPageId)) {
                 ByteBuffer buf = meta.getForInitialWrite();
 
-                BPlusIOMeta io = BPlusIOMeta.VERSIONS.latest();
+                BPlusMetaIO io = BPlusMetaIO.VERSIONS.latest();
 
                 io.initNewPage(buf, metaPageId.pageId());
 
@@ -492,7 +492,7 @@ public abstract class BPlusTree<L, T extends L> {
         ByteBuffer buf = meta.getForRead();
 
         try {
-            return BPlusIOMeta.VERSIONS.forPage(buf).getRootLevel(buf);
+            return BPlusMetaIO.VERSIONS.forPage(buf).getRootLevel(buf);
         }
         finally {
             meta.releaseRead();
@@ -508,7 +508,7 @@ public abstract class BPlusTree<L, T extends L> {
         ByteBuffer buf = meta.getForRead();
 
         try {
-            BPlusIOMeta io = BPlusIOMeta.VERSIONS.forPage(buf);
+            BPlusMetaIO io = BPlusMetaIO.VERSIONS.forPage(buf);
 
             if (lvl == Integer.MIN_VALUE)
                 lvl = io.getRootLevel(buf);
@@ -597,7 +597,7 @@ public abstract class BPlusTree<L, T extends L> {
         ByteBuffer buf = g.meta.getForRead();
 
         try {
-            BPlusIOMeta io = BPlusIOMeta.VERSIONS.forPage(buf);
+            BPlusMetaIO io = BPlusMetaIO.VERSIONS.forPage(buf);
 
             rootLvl = io.getRootLevel(buf);
             rootId = io.getLeftmostPageId(buf, rootLvl);
@@ -2191,8 +2191,8 @@ public abstract class BPlusTree<L, T extends L> {
      * @param io IO.
      * @return Inner page IO.
      */
-    private static BPlusIOInner inner(BPlusIO io) {
-        return (BPlusIOInner)io;
+    private static BPlusInnerIO inner(BPlusIO io) {
+        return (BPlusInnerIO)io;
     }
 
     /**
@@ -2205,12 +2205,12 @@ public abstract class BPlusTree<L, T extends L> {
     /**
      * @return Latest version of inner page IO.
      */
-    protected abstract BPlusIOInner<L> latestInnerIO();
+    protected abstract BPlusInnerIO<L> latestInnerIO();
 
     /**
      * @return Latest version of leaf page IO.
      */
-    protected abstract BPlusIOLeaf<L> latestLeafIO();
+    protected abstract BPlusLeafIO<L> latestLeafIO();
 
     /**
      * @param buf Buffer.

http://git-wip-us.apache.org/repos/asf/ignite/blob/8218c2d0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIOInner.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIOInner.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIOInner.java
deleted file mode 100644
index c9c527f..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIOInner.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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.cache.database.tree.io;
-
-import java.nio.ByteBuffer;
-
-/**
- * Abstract IO routines for B+Tree inner pages.
- */
-public abstract class BPlusIOInner<L> extends BPlusIO<L> {
-    /** */
-    protected static final int ITEM_SIZE = 16;
-
-    /** */
-    protected static final int SHIFT_LEFT = ITEMS_OFF;
-
-    /** */
-    protected static final int SHIFT_LINK = ITEMS_OFF + 8;
-
-    /** */
-    protected static final int SHIFT_RIGHT = ITEMS_OFF + 16;
-
-    /**
-     * @param ver Page format version.
-     */
-    protected BPlusIOInner(int ver) {
-        super(ver);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getMaxCount(ByteBuffer buf) {
-        //  (capacity - ITEMS_OFF - RIGHTMOST_PAGE_ID_SLOT_SIZE) / ITEM_SIZE
-        return (buf.capacity() - ITEMS_OFF - 8) >>> 4;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isLeaf() {
-        return false;
-    }
-
-    /**
-     * @param buf Buffer.
-     * @param idx Index.
-     * @return Page ID.
-     */
-    public long getLeft(ByteBuffer buf, int idx) {
-        return buf.getLong(offset(idx, SHIFT_LEFT));
-    }
-
-    /**
-     * @param buf Buffer.
-     * @param idx Index.
-     * @param pageId Page ID.
-     */
-    public void setLeft(ByteBuffer buf, int idx, long pageId) {
-        buf.putLong(offset(idx, SHIFT_LEFT), pageId);
-
-        assert pageId == getLeft(buf, idx);
-    }
-
-    /**
-     * @param buf Buffer.
-     * @param idx Index.
-     * @return Page ID.
-     */
-    public long getRight(ByteBuffer buf, int idx) {
-        return buf.getLong(offset(idx, SHIFT_RIGHT));
-    }
-
-    /**
-     * @param buf Buffer.
-     * @param idx Index.
-     * @param pageId Page ID.
-     */
-    public void setRight(ByteBuffer buf, int idx, long pageId) {
-        buf.putLong(offset(idx, SHIFT_RIGHT), pageId);
-
-        assert pageId == getRight(buf, idx);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void copyItems(ByteBuffer src, ByteBuffer dst, int srcIdx, int dstIdx,
int cnt,
-        boolean cpLeft) {
-        assert srcIdx != dstIdx || src != dst;
-
-        if (dstIdx > srcIdx) {
-            for (int i = cnt - 1; i >= 0; i--) {
-                dst.putLong(offset(dstIdx + i, SHIFT_RIGHT), src.getLong(offset(srcIdx +
i, SHIFT_RIGHT)));
-                dst.putLong(offset(dstIdx + i, SHIFT_LINK), src.getLong(offset(srcIdx + i,
SHIFT_LINK)));
-            }
-
-            if (cpLeft)
-                dst.putLong(offset(dstIdx, SHIFT_LEFT), src.getLong(offset(srcIdx, SHIFT_LEFT)));
-        }
-        else {
-            if (cpLeft)
-                dst.putLong(offset(dstIdx, SHIFT_LEFT), src.getLong(offset(srcIdx, SHIFT_LEFT)));
-
-            for (int i = 0; i < cnt; i++) {
-                dst.putLong(offset(dstIdx + i, SHIFT_RIGHT), src.getLong(offset(srcIdx +
i, SHIFT_RIGHT)));
-                dst.putLong(offset(dstIdx + i, SHIFT_LINK), src.getLong(offset(srcIdx + i,
SHIFT_LINK)));
-            }
-        }
-    }
-
-    /**
-     * @param idx Index of element.
-     * @param shift It can be either link itself or left or right page ID.
-     * @return Offset from byte buffer begin in bytes.
-     */
-    protected static int offset(int idx, int shift) {
-        assert idx >= 0: idx;
-
-        return shift + ITEM_SIZE * idx;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/8218c2d0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIOLeaf.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIOLeaf.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIOLeaf.java
deleted file mode 100644
index 0aaa3b8..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIOLeaf.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.cache.database.tree.io;
-
-import java.nio.ByteBuffer;
-
-/**
- * Abstract IO routines for B+Tree leaf pages.
- */
-public abstract class BPlusIOLeaf<L> extends BPlusIO<L> {
-    /** */
-    protected static final int ITEM_SIZE = 8;
-
-    /**
-     * @param ver Page format version.
-     */
-    protected BPlusIOLeaf(int ver) {
-        super(ver);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isLeaf() {
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getMaxCount(ByteBuffer buf) {
-        return (buf.capacity() - ITEMS_OFF) >>> 3; // divide by ITEM_SIZE
-    }
-
-//        /** {@inheritDoc} */
-//        @Override public long getLink(ByteBuffer buf, int idx) {
-//            assert idx < getCount(buf): idx;
-//
-//            return buf.getLong(offset(idx));
-//        }
-//
-//        /** {@inheritDoc} */
-//        @Override public void setLink(ByteBuffer buf, int idx, long link) {
-//            buf.putLong(offset(idx), link);
-//
-//            assert getLink(buf, idx) == link;
-//        }
-
-    /** {@inheritDoc} */
-    @Override public void copyItems(ByteBuffer src, ByteBuffer dst, int srcIdx, int dstIdx,
int cnt,
-        boolean cpLeft) {
-        assert srcIdx != dstIdx || src != dst;
-
-        if (dstIdx > srcIdx) {
-            for (int i = cnt - 1; i >= 0; i--)
-                dst.putLong(offset(dstIdx + i), src.getLong(offset(srcIdx + i)));
-        }
-        else {
-            for (int i = 0; i < cnt; i++)
-                dst.putLong(offset(dstIdx + i), src.getLong(offset(srcIdx + i)));
-        }
-    }
-
-    /**
-     * @param idx Index of item.
-     * @return Offset.
-     */
-    protected static int offset(int idx) {
-        assert idx >= 0: idx;
-
-        return ITEMS_OFF + idx * ITEM_SIZE;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/8218c2d0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIOMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIOMeta.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIOMeta.java
deleted file mode 100644
index a8657b1..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIOMeta.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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.cache.database.tree.io;
-
-import java.nio.ByteBuffer;
-
-/**
- * IO routines for B+Tree meta pages.
- */
-public class BPlusIOMeta extends PageIO {
-    /** */
-    public static final IOVersions<BPlusIOMeta> VERSIONS = new IOVersions<>(
-        new BPlusIOMeta(1)
-    );
-
-    /** */
-    private static final int LVLS_OFF = COMMON_HEADER_END;
-
-    /** */
-    private static final int REFS_OFF = LVLS_OFF + 1;
-
-    /**
-     * @param ver Page format version.
-     */
-    protected BPlusIOMeta(int ver) {
-        super(ver);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int getType() {
-        return T_BPLUS_META;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void initNewPage(ByteBuffer buf, long pageId) {
-        super.initNewPage(buf, pageId);
-
-        setLevelsCount(buf, 0);
-    }
-
-    /**
-     * @param buf Buffer.
-     * @return Number of levels in this tree.
-     */
-    public int getLevelsCount(ByteBuffer buf) {
-        return buf.get(LVLS_OFF);
-    }
-
-    /**
-     * @param buf  Buffer.
-     * @param lvls Number of levels in this tree.
-     */
-    public void setLevelsCount(ByteBuffer buf, int lvls) {
-        assert lvls >= 0 && lvls < 30;
-
-        buf.put(LVLS_OFF, (byte)lvls);
-
-        assert getLevelsCount(buf) == lvls;
-    }
-
-    /**
-     * @param lvl Level.
-     * @return Offset for page reference.
-     */
-    private static int offset(int lvl) {
-        return lvl * 8 + REFS_OFF;
-    }
-
-    /**
-     * @param buf Buffer.
-     * @param lvl Level.
-     * @return Page reference at that level.
-     */
-    public long getLeftmostPageId(ByteBuffer buf, int lvl) {
-        return buf.getLong(offset(lvl));
-    }
-
-    /**
-     * @param buf    Buffer.
-     * @param lvl    Level.
-     * @param pageId Page ID.
-     */
-    public void setLeftmostPageId(ByteBuffer buf, int lvl, long pageId) {
-        assert lvl >= 0 && lvl < getLevelsCount(buf);
-
-        buf.putLong(offset(lvl), pageId);
-
-        assert getLeftmostPageId(buf, lvl) == pageId;
-    }
-
-    /**
-     * @param buf Buffer.
-     * @return Root level.
-     */
-    public int getRootLevel(ByteBuffer buf) {
-        int lvls = getLevelsCount(buf); // The highest level page is root.
-
-        assert lvls > 0 : lvls;
-
-        return lvls - 1;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/8218c2d0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusInnerIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusInnerIO.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusInnerIO.java
new file mode 100644
index 0000000..9975be2
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusInnerIO.java
@@ -0,0 +1,131 @@
+/*
+ * 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.cache.database.tree.io;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Abstract IO routines for B+Tree inner pages.
+ */
+public abstract class BPlusInnerIO<L> extends BPlusIO<L> {
+    /** */
+    protected static final int ITEM_SIZE = 16;
+
+    /** */
+    protected static final int SHIFT_LEFT = ITEMS_OFF;
+
+    /** */
+    protected static final int SHIFT_LINK = ITEMS_OFF + 8;
+
+    /** */
+    protected static final int SHIFT_RIGHT = ITEMS_OFF + 16;
+
+    /**
+     * @param ver Page format version.
+     */
+    protected BPlusInnerIO(int ver) {
+        super(ver);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getMaxCount(ByteBuffer buf) {
+        //  (capacity - ITEMS_OFF - RIGHTMOST_PAGE_ID_SLOT_SIZE) / ITEM_SIZE
+        return (buf.capacity() - ITEMS_OFF - 8) >>> 4;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isLeaf() {
+        return false;
+    }
+
+    /**
+     * @param buf Buffer.
+     * @param idx Index.
+     * @return Page ID.
+     */
+    public long getLeft(ByteBuffer buf, int idx) {
+        return buf.getLong(offset(idx, SHIFT_LEFT));
+    }
+
+    /**
+     * @param buf Buffer.
+     * @param idx Index.
+     * @param pageId Page ID.
+     */
+    public void setLeft(ByteBuffer buf, int idx, long pageId) {
+        buf.putLong(offset(idx, SHIFT_LEFT), pageId);
+
+        assert pageId == getLeft(buf, idx);
+    }
+
+    /**
+     * @param buf Buffer.
+     * @param idx Index.
+     * @return Page ID.
+     */
+    public long getRight(ByteBuffer buf, int idx) {
+        return buf.getLong(offset(idx, SHIFT_RIGHT));
+    }
+
+    /**
+     * @param buf Buffer.
+     * @param idx Index.
+     * @param pageId Page ID.
+     */
+    public void setRight(ByteBuffer buf, int idx, long pageId) {
+        buf.putLong(offset(idx, SHIFT_RIGHT), pageId);
+
+        assert pageId == getRight(buf, idx);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void copyItems(ByteBuffer src, ByteBuffer dst, int srcIdx, int dstIdx,
int cnt,
+        boolean cpLeft) {
+        assert srcIdx != dstIdx || src != dst;
+
+        if (dstIdx > srcIdx) {
+            for (int i = cnt - 1; i >= 0; i--) {
+                dst.putLong(offset(dstIdx + i, SHIFT_RIGHT), src.getLong(offset(srcIdx +
i, SHIFT_RIGHT)));
+                dst.putLong(offset(dstIdx + i, SHIFT_LINK), src.getLong(offset(srcIdx + i,
SHIFT_LINK)));
+            }
+
+            if (cpLeft)
+                dst.putLong(offset(dstIdx, SHIFT_LEFT), src.getLong(offset(srcIdx, SHIFT_LEFT)));
+        }
+        else {
+            if (cpLeft)
+                dst.putLong(offset(dstIdx, SHIFT_LEFT), src.getLong(offset(srcIdx, SHIFT_LEFT)));
+
+            for (int i = 0; i < cnt; i++) {
+                dst.putLong(offset(dstIdx + i, SHIFT_RIGHT), src.getLong(offset(srcIdx +
i, SHIFT_RIGHT)));
+                dst.putLong(offset(dstIdx + i, SHIFT_LINK), src.getLong(offset(srcIdx + i,
SHIFT_LINK)));
+            }
+        }
+    }
+
+    /**
+     * @param idx Index of element.
+     * @param shift It can be either link itself or left or right page ID.
+     * @return Offset from byte buffer begin in bytes.
+     */
+    protected static int offset(int idx, int shift) {
+        assert idx >= 0: idx;
+
+        return shift + ITEM_SIZE * idx;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/8218c2d0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusLeafIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusLeafIO.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusLeafIO.java
new file mode 100644
index 0000000..73ba044
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusLeafIO.java
@@ -0,0 +1,84 @@
+/*
+ * 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.cache.database.tree.io;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Abstract IO routines for B+Tree leaf pages.
+ */
+public abstract class BPlusLeafIO<L> extends BPlusIO<L> {
+    /** */
+    protected static final int ITEM_SIZE = 8;
+
+    /**
+     * @param ver Page format version.
+     */
+    protected BPlusLeafIO(int ver) {
+        super(ver);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isLeaf() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getMaxCount(ByteBuffer buf) {
+        return (buf.capacity() - ITEMS_OFF) >>> 3; // divide by ITEM_SIZE
+    }
+
+//        /** {@inheritDoc} */
+//        @Override public long getLink(ByteBuffer buf, int idx) {
+//            assert idx < getCount(buf): idx;
+//
+//            return buf.getLong(offset(idx));
+//        }
+//
+//        /** {@inheritDoc} */
+//        @Override public void setLink(ByteBuffer buf, int idx, long link) {
+//            buf.putLong(offset(idx), link);
+//
+//            assert getLink(buf, idx) == link;
+//        }
+
+    /** {@inheritDoc} */
+    @Override public void copyItems(ByteBuffer src, ByteBuffer dst, int srcIdx, int dstIdx,
int cnt,
+        boolean cpLeft) {
+        assert srcIdx != dstIdx || src != dst;
+
+        if (dstIdx > srcIdx) {
+            for (int i = cnt - 1; i >= 0; i--)
+                dst.putLong(offset(dstIdx + i), src.getLong(offset(srcIdx + i)));
+        }
+        else {
+            for (int i = 0; i < cnt; i++)
+                dst.putLong(offset(dstIdx + i), src.getLong(offset(srcIdx + i)));
+        }
+    }
+
+    /**
+     * @param idx Index of item.
+     * @return Offset.
+     */
+    protected static int offset(int idx) {
+        assert idx >= 0: idx;
+
+        return ITEMS_OFF + idx * ITEM_SIZE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/8218c2d0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusMetaIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusMetaIO.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusMetaIO.java
new file mode 100644
index 0000000..7034548
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusMetaIO.java
@@ -0,0 +1,117 @@
+/*
+ * 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.cache.database.tree.io;
+
+import java.nio.ByteBuffer;
+
+/**
+ * IO routines for B+Tree meta pages.
+ */
+public class BPlusMetaIO extends PageIO {
+    /** */
+    public static final IOVersions<BPlusMetaIO> VERSIONS = new IOVersions<>(
+        new BPlusMetaIO(1)
+    );
+
+    /** */
+    private static final int LVLS_OFF = COMMON_HEADER_END;
+
+    /** */
+    private static final int REFS_OFF = LVLS_OFF + 1;
+
+    /**
+     * @param ver Page format version.
+     */
+    protected BPlusMetaIO(int ver) {
+        super(ver);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int getType() {
+        return T_BPLUS_META;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void initNewPage(ByteBuffer buf, long pageId) {
+        super.initNewPage(buf, pageId);
+
+        setLevelsCount(buf, 0);
+    }
+
+    /**
+     * @param buf Buffer.
+     * @return Number of levels in this tree.
+     */
+    public int getLevelsCount(ByteBuffer buf) {
+        return buf.get(LVLS_OFF);
+    }
+
+    /**
+     * @param buf  Buffer.
+     * @param lvls Number of levels in this tree.
+     */
+    public void setLevelsCount(ByteBuffer buf, int lvls) {
+        assert lvls >= 0 && lvls < 30;
+
+        buf.put(LVLS_OFF, (byte)lvls);
+
+        assert getLevelsCount(buf) == lvls;
+    }
+
+    /**
+     * @param lvl Level.
+     * @return Offset for page reference.
+     */
+    private static int offset(int lvl) {
+        return lvl * 8 + REFS_OFF;
+    }
+
+    /**
+     * @param buf Buffer.
+     * @param lvl Level.
+     * @return Page reference at that level.
+     */
+    public long getLeftmostPageId(ByteBuffer buf, int lvl) {
+        return buf.getLong(offset(lvl));
+    }
+
+    /**
+     * @param buf    Buffer.
+     * @param lvl    Level.
+     * @param pageId Page ID.
+     */
+    public void setLeftmostPageId(ByteBuffer buf, int lvl, long pageId) {
+        assert lvl >= 0 && lvl < getLevelsCount(buf);
+
+        buf.putLong(offset(lvl), pageId);
+
+        assert getLeftmostPageId(buf, lvl) == pageId;
+    }
+
+    /**
+     * @param buf Buffer.
+     * @return Root level.
+     */
+    public int getRootLevel(ByteBuffer buf) {
+        int lvls = getLevelsCount(buf); // The highest level page is root.
+
+        assert lvls > 0 : lvls;
+
+        return lvls - 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/8218c2d0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/BPlusTreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/BPlusTreeIndex.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/BPlusTreeIndex.java
index 1996d83..583d771 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/BPlusTreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/BPlusTreeIndex.java
@@ -27,8 +27,8 @@ import org.apache.ignite.internal.pagemem.PageMemory;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 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.BPlusIOInner;
-import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIOLeaf;
+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.io.PageIO;
 import org.apache.ignite.internal.processors.query.h2.database.io.H2InnerIO;
 import org.apache.ignite.internal.processors.query.h2.database.io.H2LeafIO;
@@ -259,12 +259,12 @@ public class BPlusTreeIndex extends PageMemoryIndex {
         }
 
         /** {@inheritDoc} */
-        @Override protected BPlusIOInner<SearchRow> latestInnerIO() {
+        @Override protected BPlusInnerIO<SearchRow> latestInnerIO() {
             return H2InnerIO.VERSIONS.latest();
         }
 
         /** {@inheritDoc} */
-        @Override protected BPlusIOLeaf<SearchRow> latestLeafIO() {
+        @Override protected BPlusLeafIO<SearchRow> latestLeafIO() {
             return H2LeafIO.VERSIONS.latest();
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/8218c2d0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2InnerIO.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2InnerIO.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2InnerIO.java
index 70d5034..3fa51c1 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2InnerIO.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2InnerIO.java
@@ -19,7 +19,7 @@ package org.apache.ignite.internal.processors.query.h2.database.io;
 
 import java.nio.ByteBuffer;
 import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIO;
-import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIOInner;
+import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusInnerIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.IOVersions;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2Row;
 import org.h2.result.SearchRow;
@@ -27,7 +27,7 @@ import org.h2.result.SearchRow;
 /**
  * Inner page for H2 row references.
  */
-public class H2InnerIO extends BPlusIOInner<SearchRow> implements H2RowLinkIO {
+public class H2InnerIO extends BPlusInnerIO<SearchRow> implements H2RowLinkIO {
     /** */
     public static final IOVersions<H2InnerIO> VERSIONS = new IOVersions<>(
         new H2InnerIO(1)

http://git-wip-us.apache.org/repos/asf/ignite/blob/8218c2d0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2LeafIO.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2LeafIO.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2LeafIO.java
index 4cb877c..b06d557 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2LeafIO.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/io/H2LeafIO.java
@@ -19,7 +19,7 @@ package org.apache.ignite.internal.processors.query.h2.database.io;
 
 import java.nio.ByteBuffer;
 import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIO;
-import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIOLeaf;
+import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusLeafIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.IOVersions;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2Row;
 import org.h2.result.SearchRow;
@@ -27,7 +27,7 @@ import org.h2.result.SearchRow;
 /**
  * Leaf page for H2 row references.
  */
-public class H2LeafIO extends BPlusIOLeaf<SearchRow> implements H2RowLinkIO {
+public class H2LeafIO extends BPlusLeafIO<SearchRow> implements H2RowLinkIO {
     /** */
     public static final IOVersions<H2LeafIO> VERSIONS = new IOVersions<>(
         new H2LeafIO(1)


Mime
View raw message