ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [20/50] ignite git commit: ignite-db - io copy fix
Date Thu, 28 Apr 2016 08:52:50 GMT
ignite-db - io copy fix


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

Branch: refs/heads/ignite-db-x-10884
Commit: 3df530a9ae55c7d56d07c241f4fccde83ee97589
Parents: 96023b8
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Mon Apr 25 19:50:48 2016 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Mon Apr 25 19:50:48 2016 +0300

----------------------------------------------------------------------
 .../cache/database/freelist/io/FreeLeafIO.java  | 13 +++++++++++
 .../cache/database/tree/io/BPlusIO.java         | 23 +++++++++++++++++---
 .../cache/database/tree/io/BPlusInnerIO.java    | 19 +++-------------
 .../cache/database/tree/io/BPlusLeafIO.java     |  7 +++---
 .../database/tree/reuse/io/ReuseLeafIO.java     |  8 +++++++
 .../query/h2/database/io/H2LeafIO.java          |  8 +++++++
 6 files changed, 56 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3df530a9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeLeafIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeLeafIO.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeLeafIO.java
index 8503c7d..edde01c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeLeafIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeLeafIO.java
@@ -18,11 +18,13 @@
 package org.apache.ignite.internal.processors.cache.database.freelist.io;
 
 import java.nio.ByteBuffer;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.pagemem.PageIdAllocator;
 import org.apache.ignite.internal.pagemem.PageIdUtils;
 import org.apache.ignite.internal.processors.cache.database.freelist.FreeItem;
 import org.apache.ignite.internal.processors.cache.database.freelist.FreeTree;
 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.BPlusLeafIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.IOVersions;
 
@@ -51,6 +53,17 @@ public class FreeLeafIO extends BPlusLeafIO<FreeItem> implements
FreeIO {
     }
 
     /** {@inheritDoc} */
+    @Override public void store(ByteBuffer dst, int dstIdx, BPlusIO<FreeItem> srcIo,
ByteBuffer src, int srcIdx)
+        throws IgniteCheckedException {
+        assert srcIo == this: srcIo;
+
+        int off = offset(dstIdx);
+
+        dst.putShort(off, getFreeSpace(src, srcIdx));
+        dst.putInt(off + 2, getPageIndex(src, srcIdx));
+    }
+
+    /** {@inheritDoc} */
     @Override public short getFreeSpace(ByteBuffer buf, int idx) {
         int off = offset(idx);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3df530a9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIO.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIO.java
index 33a8a69..fbffe21 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/BPlusIO.java
@@ -161,8 +161,22 @@ public abstract class BPlusIO<L> extends PageIO {
      * @param buf Buffer.
      * @param idx Index.
      * @param row Lookup or full row.
+     * @throws IgniteCheckedException If failed.
+     */
+    public abstract void store(ByteBuffer buf, int idx, L row) throws IgniteCheckedException;
+
+    /**
+     * Store row info from the given source.
+     *
+     * @param dst Destination buffer
+     * @param dstIdx Destination index.
+     * @param srcIo Source IO.
+     * @param src Source buffer.
+     * @param srcIdx Source index.
+     * @throws IgniteCheckedException If failed.
      */
-    public abstract void store(ByteBuffer buf, int idx, L row);
+    public abstract void store(ByteBuffer dst, int dstIdx, BPlusIO<L> srcIo, ByteBuffer
src, int srcIdx)
+        throws IgniteCheckedException;
 
     /**
      * Get lookup row.
@@ -176,7 +190,8 @@ public abstract class BPlusIO<L> extends PageIO {
     public abstract L getLookupRow(BPlusTree<L, ?> tree, ByteBuffer buf, int idx) throws
IgniteCheckedException;
 
     /**
-     * Copy items from source buffer to destination buffer. Both pages must be of the same
type.
+     * Copy items from source buffer to destination buffer.
+     * Both pages must be of the same type and the same version.
      *
      * @param src Source buffer.
      * @param dst Destination buffer.
@@ -184,6 +199,8 @@ public abstract class BPlusIO<L> extends PageIO {
      * @param dstIdx Destination begin index.
      * @param cnt Items count.
      * @param cpLeft Copy leftmost link (makes sense only for inner pages).
+     * @throws IgniteCheckedException If failed.
      */
-    public abstract void copyItems(ByteBuffer src, ByteBuffer dst, int srcIdx, int dstIdx,
int cnt, boolean cpLeft);
+    public abstract void copyItems(ByteBuffer src, ByteBuffer dst, int srcIdx, int dstIdx,
int cnt, boolean cpLeft)
+        throws IgniteCheckedException;
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3df530a9/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
index 958fa6c..60c8f58 100644
--- 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
@@ -93,13 +93,13 @@ public abstract class BPlusInnerIO<L> extends BPlusIO<L> {
 
     /** {@inheritDoc} */
     @Override public final void copyItems(ByteBuffer src, ByteBuffer dst, int srcIdx, int
dstIdx, int cnt,
-        boolean cpLeft) {
+        boolean cpLeft) throws IgniteCheckedException {
         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)));
+                store(dst, dstIdx + i, this, src, srcIdx + i); // TODO optimize with copy
by itemSize
             }
 
             if (cpLeft)
@@ -111,25 +111,12 @@ public abstract class BPlusInnerIO<L> extends BPlusIO<L>
{
 
             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)));
+                store(dst, dstIdx + i, this, src, srcIdx + i); // TODO optimize with copy
by itemSize
             }
         }
     }
 
     /**
-     * Store row info from the given source.
-     *
-     * @param dst Destination buffer
-     * @param dstIdx Destination index.
-     * @param srcIo Source IO.
-     * @param src Source buffer.
-     * @param srcIdx Source index.
-     * @throws IgniteCheckedException If failed.
-     */
-    public abstract void store(ByteBuffer dst, int dstIdx, BPlusIO<L> srcIo, ByteBuffer
src, int srcIdx)
-        throws IgniteCheckedException;
-
-    /**
      * @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.

http://git-wip-us.apache.org/repos/asf/ignite/blob/3df530a9/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
index 3688a75..1b86ef9 100644
--- 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
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache.database.tree.io;
 
 import java.nio.ByteBuffer;
+import org.apache.ignite.IgniteCheckedException;
 
 /**
  * Abstract IO routines for B+Tree leaf pages.
@@ -39,16 +40,16 @@ public abstract class BPlusLeafIO<L> extends BPlusIO<L> {
 
     /** {@inheritDoc} */
     @Override public final void copyItems(ByteBuffer src, ByteBuffer dst, int srcIdx, int
dstIdx, int cnt,
-        boolean cpLeft) {
+        boolean cpLeft) throws IgniteCheckedException {
         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)));
+                store(dst, dstIdx + i, this, src, srcIdx + i); // TODO optimize with copy
by itemSize
         }
         else {
             for (int i = 0; i < cnt; i++)
-                dst.putLong(offset(dstIdx + i), src.getLong(offset(srcIdx + i)));
+                store(dst, dstIdx + i, this, src, srcIdx + i); // TODO optimize with copy
by itemSize
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3df530a9/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 69d08c9..bf46024 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
@@ -21,6 +21,7 @@ import java.nio.ByteBuffer;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.pagemem.FullPageId;
 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.BPlusLeafIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.IOVersions;
 
@@ -45,6 +46,13 @@ public class ReuseLeafIO extends BPlusLeafIO<FullPageId> {
         buf.putLong(offset(idx), fullPageId.pageId());
     }
 
+    /** {@inheritDoc} */
+    @Override public void store(ByteBuffer dst, int dstIdx, BPlusIO<FullPageId> srcIo,
ByteBuffer src, int srcIdx) {
+        assert srcIo == this;
+
+        dst.putLong(offset(dstIdx), getPageId(src, srcIdx));
+    }
+
     /**
      * @param buf Buffer.
      * @param idx Index.

http://git-wip-us.apache.org/repos/asf/ignite/blob/3df530a9/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 b3d3ae0..c2c915a 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
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.query.h2.database.io;
 import java.nio.ByteBuffer;
 import org.apache.ignite.IgniteCheckedException;
 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.BPlusLeafIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.IOVersions;
 import org.apache.ignite.internal.processors.query.h2.database.H2Tree;
@@ -52,6 +53,13 @@ public class H2LeafIO extends BPlusLeafIO<SearchRow> implements H2RowLinkIO
{
     }
 
     /** {@inheritDoc} */
+    @Override public void store(ByteBuffer dst, int dstIdx, BPlusIO<SearchRow> srcIo,
ByteBuffer src, int srcIdx) {
+        assert srcIo == this;
+
+        setLink(dst, dstIdx, getLink(src, srcIdx));
+    }
+
+    /** {@inheritDoc} */
     @Override public SearchRow getLookupRow(BPlusTree<SearchRow,?> tree, ByteBuffer
buf, int idx)
         throws IgniteCheckedException {
         long link = getLink(buf, idx);


Mime
View raw message