ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/2] ignite git commit: # Conflicts: # modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
Date Fri, 13 Jan 2017 13:37:15 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-gg-11810-1 c7bd20c5d -> 86896a81f


# Conflicts:
#	modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java


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

Branch: refs/heads/ignite-gg-11810-1
Commit: 4a36602cc0598e6970c48dd89f0ddc6361317d73
Parents: 3202edd
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Jan 13 16:36:58 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Jan 13 16:36:58 2017 +0300

----------------------------------------------------------------------
 .../ignite/internal/pagemem/PageMemory.java     |   4 +
 .../ignite/internal/pagemem/PageUtils.java      |   2 +-
 .../pagemem/impl/PageMemoryNoStoreImpl.java     |  60 +++++++----
 .../internal/pagemem/impl/PageNoStoreImpl.java  |  13 +--
 .../cache/IgniteCacheOffheapManagerImpl.java    |  92 ++++++----------
 .../cache/database/CacheDataRowAdapter.java     |  82 +++++++--------
 .../cache/database/DataStructure.java           |   8 ++
 .../cache/database/tree/BPlusTree.java          | 104 ++++++++++---------
 .../cache/database/tree/util/PageHandler.java   |  23 ++++
 .../util/GridCursorIteratorWrapper.java         |  17 +++
 ...niteCachePartitionedFieldsQuerySelfTest.java |   8 +-
 ...gniteCacheReplicatedFieldsQuerySelfTest.java |   6 +-
 .../query/h2/opt/GridH2TableSelfTest.java       |   6 +-
 .../query/h2/sql/GridQueryParsingTest.java      |   4 +-
 14 files changed, 227 insertions(+), 202 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4a36602c/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageMemory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageMemory.java
b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageMemory.java
index cfee19f..f90e718 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageMemory.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageMemory.java
@@ -38,6 +38,10 @@ public interface PageMemory extends LifecycleAware, PageIdAllocator {
      */
     public Page page(int cacheId, long pageId) throws IgniteCheckedException;
 
+    public long readLockPage0(int cacheId, long pageId);
+
+    public void readUnlockPage0(long pageAddr);
+
     /**
      * @see #page(int, long)
      * Will not read page from file if it is not present in memory.

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a36602c/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageUtils.java
index e9e228a..f824368 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageUtils.java
@@ -130,7 +130,7 @@ public class PageUtils {
         assert addr > 0 : addr;
         assert off >= 0;
         assert bytes != null;
-        assert bytesOff >= 0 && bytesOff < bytes.length : bytesOff;
+        assert bytesOff >= 0 && (bytesOff < bytes.length || bytes.length ==
0) : bytesOff;
 
         GridUnsafe.copyMemory(bytes, GridUnsafe.BYTE_ARR_OFF + bytesOff, null, addr + off,
bytes.length - bytesOff);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a36602c/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
index 79ac383..fd0ae75 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
@@ -220,13 +220,13 @@ public class PageMemoryNoStoreImpl implements PageMemory {
             relPtr = seg.borrowFreePage();
 
             if (relPtr != INVALID_REL_PTR) {
-                absPtr = seg.absolute(relPtr);
+                absPtr = seg.absolute(PageIdUtils.pageIndex(relPtr));
 
                 break;
             }
         }
 
-        // No segments conatined a free page.
+        // No segments contained a free page.
         if (relPtr == INVALID_REL_PTR) {
             int segAllocIdx = nextRoundRobinIndex();
 
@@ -238,7 +238,7 @@ public class PageMemoryNoStoreImpl implements PageMemory {
                 relPtr = seg.allocateFreePage(flags);
 
                 if (relPtr != INVALID_REL_PTR) {
-                    absPtr = seg.absolute(relPtr);
+                    absPtr = seg.absolute(PageIdUtils.pageIndex(relPtr));
 
                     break;
                 }
@@ -263,7 +263,7 @@ public class PageMemoryNoStoreImpl implements PageMemory {
 
     /** {@inheritDoc} */
     @Override public boolean freePage(int cacheId, long pageId) {
-        Segment seg = segment(pageId);
+        Segment seg = segment(PageIdUtils.pageIndex(pageId));
 
         seg.releaseFreePage(pageId);
 
@@ -272,9 +272,11 @@ public class PageMemoryNoStoreImpl implements PageMemory {
 
     /** {@inheritDoc} */
     @Override public Page page(int cacheId, long pageId) throws IgniteCheckedException {
-        Segment seg = segment(pageId);
+        int pageIdx = PageIdUtils.pageIndex(pageId);
 
-        return seg.acquirePage(cacheId, pageId);
+        Segment seg = segment(pageIdx);
+
+        return seg.acquirePage(pageIdx, pageId);
     }
 
     /** {@inheritDoc} */
@@ -285,7 +287,7 @@ public class PageMemoryNoStoreImpl implements PageMemory {
     /** {@inheritDoc} */
     @Override public void releasePage(Page p) {
         if (trackAcquiredPages) {
-            Segment seg = segment(p.id());
+            Segment seg = segment(PageIdUtils.pageIndex(p.id()));
 
             seg.onPageRelease();
         }
@@ -363,6 +365,23 @@ public class PageMemoryNoStoreImpl implements PageMemory {
         return rwLock.readLock(absPtr + LOCK_OFFSET, tag);
     }
 
+    @Override public long readLockPage0(int cacheId, long pageId) {
+        int pageIdx = PageIdUtils.pageIndex(pageId);
+
+        Segment seg = segment(pageIdx);
+
+        long absPtr = seg.absolute(pageIdx);
+
+        if (readLockPage(absPtr, PageIdUtils.tag(pageId)))
+            return absPtr + PageMemoryNoStoreImpl.PAGE_OVERHEAD;
+
+        return 0;
+    }
+
+    @Override public void readUnlockPage0(long pageAddr) {
+        readUnlockPage(pageAddr - PAGE_OVERHEAD);
+    }
+
     /**
      * @param absPtr Page absolute address.
      */
@@ -442,12 +461,10 @@ public class PageMemoryNoStoreImpl implements PageMemory {
     }
 
     /**
-     * @param pageId Page ID.
+     * @param pageIdx Page index.
      * @return Segment.
      */
-    private Segment segment(long pageId) {
-        long pageIdx = PageIdUtils.pageIndex(pageId);
-
+    private Segment segment(int pageIdx) {
         int segIdx = segmentIndex(pageIdx);
 
         return segments[segIdx];
@@ -537,18 +554,17 @@ public class PageMemoryNoStoreImpl implements PageMemory {
         }
 
         /**
-         * @param cacheId Cache ID.
          * @param pageId Page ID to pin.
          * @return Pinned page impl.
          */
         @SuppressWarnings("TypeMayBeWeakened")
-        private PageNoStoreImpl acquirePage(int cacheId, long pageId) {
-            long absPtr = absolute(pageId);
+        private PageNoStoreImpl acquirePage(int pageIdx, long pageId) {
+            long absPtr = absolute(pageIdx);
 
             if (trackAcquiredPages)
                 acquiredPages.incrementAndGet();
 
-            return new PageNoStoreImpl(PageMemoryNoStoreImpl.this, absPtr, cacheId, pageId);
+            return new PageNoStoreImpl(PageMemoryNoStoreImpl.this, absPtr, pageId);
         }
 
         /**
@@ -558,12 +574,10 @@ public class PageMemoryNoStoreImpl implements PageMemory {
         }
 
         /**
-         * @param relativePtr Relative pointer.
+         * @param pageIdx Page index.
          * @return Absolute pointer.
          */
-        private long absolute(long relativePtr) {
-            int pageIdx = PageIdUtils.pageIndex(relativePtr);
-
+        private long absolute(int pageIdx) {
             pageIdx &= idxMask;
 
             long off = ((long)pageIdx) * sysPageSize;
@@ -589,10 +603,12 @@ public class PageMemoryNoStoreImpl implements PageMemory {
          * @param pageId Page ID to release.
          */
         private void releaseFreePage(long pageId) {
+            int pageIdx = PageIdUtils.pageIndex(pageId);
+
             // Clear out flags and file ID.
-            long relPtr = PageIdUtils.pageId(0, (byte)0, PageIdUtils.pageIndex(pageId));
+            long relPtr = PageIdUtils.pageId(0, (byte)0, pageIdx);
 
-            long absPtr = absolute(relPtr);
+            long absPtr = absolute(pageIdx);
 
             // Second, write clean relative pointer instead of page ID.
             writePageId(absPtr, relPtr);
@@ -624,7 +640,7 @@ public class PageMemoryNoStoreImpl implements PageMemory {
                 long cnt = ((freePageRelPtrMasked & COUNTER_MASK) + COUNTER_INC) &
COUNTER_MASK;
 
                 if (freePageRelPtr != INVALID_REL_PTR) {
-                    long freePageAbsPtr = absolute(freePageRelPtr);
+                    long freePageAbsPtr = absolute(PageIdUtils.pageIndex(freePageRelPtr));
 
                     long nextFreePageRelPtr = GridUnsafe.getLong(freePageAbsPtr) & ADDRESS_MASK;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a36602c/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageNoStoreImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageNoStoreImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageNoStoreImpl.java
index 3d6a553..d68466f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageNoStoreImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageNoStoreImpl.java
@@ -36,21 +36,17 @@ public class PageNoStoreImpl implements Page {
     private long pageId;
 
     /** */
-    private int cacheId;
-
-    /** */
     private PageMemoryNoStoreImpl pageMem;
 
     /**
+     * @param pageMem Page memory.
      * @param absPtr Absolute pointer.
+     * @param pageId Page ID.
      */
-    PageNoStoreImpl(
-        PageMemoryNoStoreImpl pageMem, long absPtr, int cacheId, long pageId
-    ) {
+    PageNoStoreImpl(PageMemoryNoStoreImpl pageMem, long absPtr, long pageId) {
         this.pageMem = pageMem;
         this.absPtr = absPtr;
 
-        this.cacheId = cacheId;
         this.pageId = pageId;
     }
 
@@ -68,7 +64,7 @@ public class PageNoStoreImpl implements Page {
 
     /** {@inheritDoc} */
     @Override public FullPageId fullId() {
-        return new FullPageId(pageId, cacheId);
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -142,7 +138,6 @@ public class PageNoStoreImpl implements Page {
         SB sb = new SB("PageNoStoreImpl [absPtr=0x");
 
         sb.appendHex(absPtr);
-        sb.a(", cacheId=").a(cacheId);
         sb.a(", pageId=0x").appendHex(pageId);
         sb.a("]");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a36602c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
index 9838768..76d0832 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
@@ -1074,41 +1074,6 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
     /**
      *
      */
-    private static class LinkSearchRow implements CacheSearchRow {
-        /** */
-        private final int hash;
-
-        /** */
-        private final long link;
-
-        /**
-         * @param hash Key hash code.
-         * @param link Link.
-         */
-        LinkSearchRow(int hash, long link) {
-            this.hash = hash;
-            this.link = link;
-        }
-
-        /** {@inheritDoc} */
-        @Override public KeyCacheObject key() {
-            throw new UnsupportedOperationException();
-        }
-
-        /** {@inheritDoc} */
-        @Override public long link() {
-            return link;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hash() {
-            return hash;
-        }
-    }
-
-    /**
-     *
-     */
     private class DataRow extends CacheDataRowAdapter {
         /** */
         protected int part = -1;
@@ -1119,8 +1084,9 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
         /**
          * @param hash Hash code.
          * @param link Link.
+         * @param keyOnly If {@code true} initializes only key.
          */
-        DataRow(int hash, long link) {
+        DataRow(int hash, long link, boolean keyOnly) {
             super(link);
 
             this.hash = hash;
@@ -1129,7 +1095,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
 
             try {
                 // We can not init data row lazily because underlying buffer can be concurrently
cleared.
-                initFromLink(cctx, false);
+                initFromLink(cctx, keyOnly);
             }
             catch (IgniteCheckedException e) {
                 throw new IgniteException(e);
@@ -1238,41 +1204,41 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
 
             PageMemory pageMem = cctx.shared().database().pageMemory();
 
-            try (Page page = page(pageId(link))) {
-                long pageAddr = page.getForReadPointer(); // Non-empty data page must not
be recycled.
+//            try (Page page = page(pageId(link))) {
+//            }
+            long pageAddr = pageMem.readLockPage0(0, pageId(link)); // Non-empty data page
must not be recycled.
 
-                assert pageAddr != 0L : link;
+            assert pageAddr != 0L : link;
 
-                try {
-                    DataPageIO io = DataPageIO.VERSIONS.forPage(pageAddr);
-
-                    DataPagePayload data = io.readPayload(pageAddr,
-                        itemId(link),
-                        pageMem.pageSize());
+            try {
+                DataPageIO io = DataPageIO.VERSIONS.forPage(pageAddr);
 
-                    if (data.nextLink() == 0) {
-                        long addr = pageAddr + data.offset();
+                DataPagePayload data = io.readPayload(pageAddr,
+                    itemId(link),
+                    pageMem.pageSize());
 
-                        int len = PageUtils.getInt(addr, 0);
+                if (data.nextLink() == 0) {
+                    long addr = pageAddr + data.offset();
 
-                        int size = Math.min(bytes.length, len);
+                    int len = PageUtils.getInt(addr, 0);
 
-                        addr += 5; // Skip length and type byte.
+                    int size = Math.min(bytes.length, len);
 
-                        for (int i = 0; i < size; i++) {
-                            byte b1 = PageUtils.getByte(addr, i);
-                            byte b2 = bytes[i];
+                    addr += 5; // Skip length and type byte.
 
-                            if (b1 != b2)
-                                return b1 > b2 ? 1 : -1;
-                        }
+                    for (int i = 0; i < size; i++) {
+                        byte b1 = PageUtils.getByte(addr, i);
+                        byte b2 = bytes[i];
 
-                        return Integer.compare(len, bytes.length);
+                        if (b1 != b2)
+                            return b1 > b2 ? 1 : -1;
                     }
+
+                    return Integer.compare(len, bytes.length);
                 }
-                finally {
-                    page.releaseRead();
-                }
+            }
+            finally {
+                pageMem.readUnlockPage0(pageAddr);
             }
 
             // TODO GG-11768.
@@ -1323,7 +1289,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
          * @return Search row.
          */
         private CacheSearchRow keySearchRow(int hash, long link) {
-            return new LinkSearchRow(hash, link);
+            return new DataRow(hash, link, true);
         }
 
         /**
@@ -1332,7 +1298,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter
imple
          * @return Data row.
          */
         private CacheDataRow dataRow(int hash, long link) {
-            return new DataRow(hash, link);
+            return new DataRow(hash, link, false);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a36602c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
index acb435e..3e215d5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java
@@ -93,45 +93,45 @@ public class CacheDataRowAdapter implements CacheDataRow {
         do {
             PageMemory pageMem = cctx.shared().database().pageMemory();
 
-            try (Page page = page(pageId(nextLink), cctx)) {
-                long pageAddr = page.getForReadPointer(); // Non-empty data page must not
be recycled.
+            long pageAddr = pageMem.readLockPage0(0, pageId(nextLink)); // Non-empty data
page must not be recycled.
 
-                assert pageAddr != 0L : nextLink;
+            assert pageAddr != 0L : nextLink;
 
-                try {
-                    DataPageIO io = DataPageIO.VERSIONS.forPage(pageAddr);
+            try {
+                DataPageIO io = DataPageIO.VERSIONS.forPage(pageAddr);
 
-                    DataPagePayload data = io.readPayload(pageAddr,
-                        itemId(nextLink),
-                        pageMem.pageSize());
+                DataPagePayload data = io.readPayload(pageAddr,
+                    itemId(nextLink),
+                    pageMem.pageSize());
 
-                    nextLink = data.nextLink();
+                nextLink = data.nextLink();
 
-                    if (first) {
-                        if (nextLink == 0) {
-                            // Fast path for a single page row.
-                            readFullRow(coctx, pageAddr + data.offset(), keyOnly);
+                if (first) {
+                    if (nextLink == 0) {
+                        // Fast path for a single page row.
+                        readFullRow(coctx, pageAddr + data.offset(), keyOnly);
 
-                            return;
-                        }
-
-                        first = false;
+                        return;
                     }
 
-                    ByteBuffer buf = pageMem.pageBuffer(pageAddr);
+                    first = false;
+                }
 
-                    buf.position(data.offset());
-                    buf.limit(data.offset() + data.payloadSize());
+                ByteBuffer buf = pageMem.pageBuffer(pageAddr);
 
-                    incomplete = readFragment(coctx, buf, keyOnly, incomplete);
+                buf.position(data.offset());
+                buf.limit(data.offset() + data.payloadSize());
 
-                    if (keyOnly && key != null)
-                        return;
-                }
-                finally {
-                    page.releaseRead();
-                }
+                incomplete = readFragment(coctx, buf, keyOnly, incomplete);
+
+                if (keyOnly && key != null)
+                    return;
+            }
+            finally {
+                pageMem.readUnlockPage0(pageAddr);
             }
+//            try (Page page = page(pageId(nextLink), cctx)) {
+//            }
         }
         while(nextLink != 0);
 
@@ -200,17 +200,13 @@ public class CacheDataRowAdapter implements CacheDataRow {
         int len = PageUtils.getInt(addr, off);
         off += 4;
 
-        if (len == 0)
-            key = null;
-        else {
-            byte type = PageUtils.getByte(addr, off);
-            off++;
+        byte type = PageUtils.getByte(addr, off);
+        off++;
 
-            byte[] bytes = PageUtils.getBytes(addr, off, len);
-            off += len;
+        byte[] bytes = PageUtils.getBytes(addr, off, len);
+        off += len;
 
-            key = coctx.processor().toKeyCacheObject(coctx, type, bytes);
-        }
+        key = coctx.processor().toKeyCacheObject(coctx, type, bytes);
 
         if (keyOnly) {
             assert key != null: "key";
@@ -221,17 +217,13 @@ public class CacheDataRowAdapter implements CacheDataRow {
         len = PageUtils.getInt(addr, off);
         off += 4;
 
-        if (len == 0)
-            val = null;
-        else {
-            byte type = PageUtils.getByte(addr, off);
-            off++;
+        type = PageUtils.getByte(addr, off);
+        off++;
 
-            byte[] bytes = PageUtils.getBytes(addr, off, len);
-            off += len;
+        bytes = PageUtils.getBytes(addr, off, len);
+        off += len;
 
-            val = coctx.processor().toCacheObject(coctx, type, bytes);
-        }
+        val = coctx.processor().toCacheObject(coctx, type, bytes);
 
         ver = CacheVersionIO.read(addr + off, false);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a36602c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/DataStructure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/DataStructure.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/DataStructure.java
index f47a697..1ca38da 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/DataStructure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/DataStructure.java
@@ -162,6 +162,14 @@ public abstract class DataStructure implements PageLockListener {
         return PageHandler.readLock(page, this);
     }
 
+    protected final long readLock0(long pageId) {
+        return pageMem.readLockPage0(0, pageId);
+    }
+
+    protected final void readUnlock0(long pageAddr) {
+        pageMem.readUnlockPage0(pageAddr);
+    }
+
     /**
      * @param page Page.
      * @param buf Buffer.

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a36602c/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 7cf829e..82d3ae6 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
@@ -746,15 +746,23 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
             firstPageId = getFirstPageId(meta, 0); // Level 0 is always at the bottom.
         }
 
-        try (Page first = page(firstPageId)) {
-            long pageAddr = readLock(first); // We always merge pages backwards, the first
page is never removed.
+//        try (Page first = page(firstPageId)) {
+//            long pageAddr = readLock(first); // We always merge pages backwards, the first
page is never removed.
+//
+//            try {
+//                cursor.init(pageAddr, io(pageAddr), 0);
+//            }
+//            finally {
+//                readUnlock(first, pageAddr);
+//            }
+//        }
+        long pageAddr = readLock0(firstPageId); // We always merge pages backwards, the first
page is never removed.
 
-            try {
-                cursor.init(pageAddr, io(pageAddr), 0);
-            }
-            finally {
-                readUnlock(first, pageAddr);
-            }
+        try {
+            cursor.init(pageAddr, io(pageAddr), 0);
+        }
+        finally {
+            readUnlock0(pageAddr);
         }
 
         return cursor;
@@ -856,7 +864,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
      */
     private Result findDown(final Get g, final long pageId, final long fwdId, final int lvl)
         throws IgniteCheckedException {
-        Page page = page(pageId);
+        //Page page = page(pageId);
 
         try {
             for (;;) {
@@ -864,7 +872,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
                 g.pageId = pageId;
                 g.fwdId = fwdId;
 
-                Result res = readPage(page, this, search, g, lvl, RETRY);
+                Result res = readPage(pageMem, pageId, search, g, lvl, RETRY);
 
                 switch (res) {
                     case GO_DOWN:
@@ -898,8 +906,8 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
             }
         }
         finally {
-            if (g.canRelease(page, lvl))
-                page.close();
+//            if (g.canRelease(page, lvl))
+//                page.close();
         }
     }
 
@@ -1021,28 +1029,26 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
      * @throws IgniteCheckedException If failed.
      */
     private L getGreatestRowInSubTree(long pageId) throws IgniteCheckedException {
-        try (Page page = page(pageId)) {
-            long pageAddr = readLock(page); // No correctness guaranties.
+        long pageAddr = readLock0(pageId); // No correctness guaranties.
 
-            try {
-                BPlusIO<L> io = io(pageAddr);
+        try {
+            BPlusIO<L> io = io(pageAddr);
 
-                int cnt = io.getCount(pageAddr);
+            int cnt = io.getCount(pageAddr);
 
-                if (io.isLeaf()) {
-                    if (cnt <= 0) // This code is called only if the tree is not empty,
so we can't see empty leaf.
-                        fail("Invalid leaf count: " + cnt + " " + U.hexLong(pageId));
+            if (io.isLeaf()) {
+                if (cnt <= 0) // This code is called only if the tree is not empty, so
we can't see empty leaf.
+                    fail("Invalid leaf count: " + cnt + " " + U.hexLong(pageId));
 
-                    return io.getLookupRow(this, pageAddr, cnt - 1);
-                }
+                return io.getLookupRow(this, pageAddr, cnt - 1);
+            }
 
-                long rightId = inner(io).getLeft(pageAddr, cnt);// The same as getRight(cnt
- 1), but good for routing pages.
+            long rightId = inner(io).getLeft(pageAddr, cnt);// The same as getRight(cnt -
1), but good for routing pages.
 
-                return getGreatestRowInSubTree(rightId);
-            }
-            finally {
-                readUnlock(page, pageAddr);
-            }
+            return getGreatestRowInSubTree(rightId);
+        }
+        finally {
+            readUnlock0(pageAddr);
         }
     }
 
@@ -1385,7 +1391,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
                 r.fwdId = fwdId;
                 r.backId = backId;
 
-                Result res = readPage(page, this, search, r, lvl, RETRY);
+                Result res = readPage(pageMem, pageId, search, r, lvl, RETRY);
 
                 switch (res) {
                     case GO_DOWN_X:
@@ -1784,10 +1790,12 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
      * @return Operation result.
      */
     private Result askNeighbor(long pageId, Get g, boolean back) throws IgniteCheckedException
{
-        try (Page page = page(pageId)) {
-            return readPage(page, this, askNeighbor, g,
-                back ? TRUE.ordinal() : FALSE.ordinal(), RETRY);
-        }
+        return readPage(pageMem, pageId, askNeighbor, g,
+            back ? TRUE.ordinal() : FALSE.ordinal(), RETRY);
+//        try (Page page = page(pageId)) {
+//            return readPage(page, this, askNeighbor, g,
+//                back ? TRUE.ordinal() : FALSE.ordinal(), RETRY);
+//        }
     }
 
     /**
@@ -1810,7 +1818,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
                 p.pageId = pageId;
                 p.fwdId = fwdId;
 
-                Result res = readPage(page, this, search, p, lvl, RETRY);
+                Result res = readPage(pageMem, pageId, search, p, lvl, RETRY);
 
                 switch (res) {
                     case GO_DOWN:
@@ -3671,24 +3679,22 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
                     return false; // Done.
                 }
 
-                try (Page next = page(nextPageId)) {
-                    long pageAddr = readLock(next); // Doing explicit null check.
+                long pageAddr = readLock0(nextPageId); // Doing explicit null check.
 
-                    // If concurrent merge occurred we have to reinitialize cursor from the
last returned row.
-                    if (pageAddr == 0L)
-                        break;
+                // If concurrent merge occurred we have to reinitialize cursor from the last
returned row.
+                if (pageAddr == 0L)
+                    break;
 
-                    try {
-                        BPlusIO<L> io = io(pageAddr);
+                try {
+                    BPlusIO<L> io = io(pageAddr);
 
-                        if (fillFromBuffer(pageAddr, io, 0, io.getCount(pageAddr)))
-                            return true;
+                    if (fillFromBuffer(pageAddr, io, 0, io.getCount(pageAddr)))
+                        return true;
 
-                        // Continue fetching forward.
-                    }
-                    finally {
-                        readUnlock(next, pageAddr);
-                    }
+                    // Continue fetching forward.
+                }
+                finally {
+                    readUnlock0(pageAddr);
                 }
             }
 
@@ -3724,7 +3730,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
         @SuppressWarnings("unchecked")
         @Override public final Result run(Page page, PageIO iox, long pageAddr, G g, int
lvl)
             throws IgniteCheckedException {
-            assert PageIO.getPageId(pageAddr) == page.id();
+//            assert PageIO.getPageId(pageAddr) == page.id();
 
             // If we've passed the check for correct page ID, we can safely cast.
             BPlusIO<L> io = (BPlusIO<L>)iox;

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a36602c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/util/PageHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/util/PageHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/util/PageHandler.java
index 3e6e637..37adc49 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/util/PageHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/util/PageHandler.java
@@ -95,6 +95,29 @@ public abstract class PageHandler<X, R> {
         }
     }
 
+    public static <X, R> R readPage(
+        PageMemory pageMem,
+        long pageId,
+        PageHandler<X, R> h,
+        X arg,
+        int intArg,
+        R lockFailed
+    ) throws IgniteCheckedException {
+        long pageAddr = pageMem.readLockPage0(0, pageId);
+
+        if (pageAddr == 0L)
+            return lockFailed;
+
+        try {
+            PageIO io = PageIO.getPageIO(pageAddr);
+
+            return h.run(null, io, pageAddr, arg, intArg);
+        }
+        finally {
+            pageMem.readUnlockPage0(pageAddr);
+        }
+    }
+
     /**
      * @param pageMem Page memory.
      * @param page Page.

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a36602c/modules/core/src/main/java/org/apache/ignite/internal/util/GridCursorIteratorWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridCursorIteratorWrapper.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/GridCursorIteratorWrapper.java
index 201c8dd..e13854b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridCursorIteratorWrapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridCursorIteratorWrapper.java
@@ -1,3 +1,20 @@
+/*
+ * 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.util;
 
 import java.util.Iterator;

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a36602c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQuerySelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQuerySelfTest.java
index 26f3191..4934255 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedFieldsQuerySelfTest.java
@@ -62,20 +62,20 @@ public class IgniteCachePartitionedFieldsQuerySelfTest extends IgniteCacheAbstra
 
     /** @throws Exception If failed. */
     public void testLocalQuery() throws Exception {
-        IgniteCache<Object, Object> cache = grid(0).cache( null);
+        IgniteCache<Integer, Integer> cache = jcache(Integer.class, Integer.class);
 
         awaitPartitionMapExchange(true, true, null);
 
-        int expected = 0;
+        int exp = 0;
 
         for(Cache.Entry e: cache.localEntries(CachePeekMode.PRIMARY)){
             if(e.getValue() instanceof Integer)
-                expected++;
+                exp++;
         }
 
         QueryCursor<List<?>> qry = cache
             .query(new SqlFieldsQuery("select _key, _val from Integer").setLocal(true));
 
-        assertEquals(expected, qry.getAll().size());
+        assertEquals(exp, qry.getAll().size());
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a36602c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java
index 4ec840c..953e5fa 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java
@@ -48,13 +48,13 @@ public class IgniteCacheReplicatedFieldsQuerySelfTest extends IgniteCacheAbstrac
      * @throws Exception If failed.
      */
     public void testLostIterator() throws Exception {
-        IgniteCache<Object, Object> cache = grid(0).cache(null);
+        IgniteCache<Integer, Integer> cache = intCache;
 
         QueryCursor<List<?>> qry = null;
 
-        int maximumQueryIteratorCount = cache.getConfiguration(CacheConfiguration.class).getMaxQueryIteratorsCount();
+        int maximumQryIterCnt = cache.getConfiguration(CacheConfiguration.class).getMaxQueryIteratorsCount();
 
-        for (int i = 0; i < maximumQueryIteratorCount + 1; i++) {
+        for (int i = 0; i < maximumQryIterCnt + 1; i++) {
             QueryCursor<List<?>> q = cache
                 .query(new SqlFieldsQuery("select _key from Integer where _key >= 0 order
by _key"));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a36602c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
index 5daf415..72f186c 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TableSelfTest.java
@@ -27,16 +27,14 @@ import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Random;
 import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.ignite.*;
+import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.processors.query.h2.database.H2RowFactory;
-import org.apache.ignite.internal.util.lang.*;
+import org.apache.ignite.internal.util.lang.GridCursor;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.h2.Driver;

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a36602c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
index 0992fe2..09a1884 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/GridQueryParsingTest.java
@@ -383,10 +383,10 @@ public class GridQueryParsingTest extends GridCommonAbstractTest {
         checkQuery("update Person p set name='Peter', old = length('zzz') limit 20");
         checkQuery("update Person p set name=DEFAULT, old = null limit ?");
         checkQuery("update Person p set name=? where old >= ? and old < ? limit ?");
-        checkQuery("update Person p set name=(select a.Street from Address a where a.id=p.addrId),
old = (select 42)" +
+        checkQuery("update Person p set name=(select a.Street from \"addr\".Address a where
a.id=p.addrId), old = (select 42)" +
             " where old = sqrt(?)");
         checkQuery("update Person p set (name, old) = (select 'Peter', 42)");
-        checkQuery("update Person p set (name, old) = (select street, id from Address where
id > 5 and id <= ?)");
+        checkQuery("update Person p set (name, old) = (select street, id from \"addr\".Address
where id > 5 and id <= ?)");
     }
 
     /**


Mime
View raw message