asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mb...@apache.org
Subject asterixdb git commit: Cleanup Large Page Logic
Date Fri, 24 Jun 2016 17:02:41 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 7f3fb7925 -> dc58d30d7


Cleanup Large Page Logic

Change-Id: I26f9a8e4530edfda1b5f78114a5c8038bf8a27f4
Reviewed-on: https://asterix-gerrit.ics.uci.edu/955
Reviewed-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>


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

Branch: refs/heads/master
Commit: dc58d30d75a76fcc52f60febc5a8a94956230553
Parents: 7f3fb79
Author: Michael Blow <mblow@apache.org>
Authored: Fri Jun 24 11:32:22 2016 -0400
Committer: Michael Blow <michael.blow@couchbase.com>
Committed: Fri Jun 24 10:02:16 2016 -0700

----------------------------------------------------------------------
 .../am/btree/frames/BTreeNSMLeafFrame.java      | 31 ++++++++++----------
 .../am/lsm/common/impls/VirtualBufferCache.java |  5 ++++
 .../storage/common/buffercache/CachedPage.java  |  5 ++++
 .../storage/common/buffercache/ICachedPage.java |  2 ++
 4 files changed, 27 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/dc58d30d/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/frames/BTreeNSMLeafFrame.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/frames/BTreeNSMLeafFrame.java
b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/frames/BTreeNSMLeafFrame.java
index 63f516e..f7af7ad 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/frames/BTreeNSMLeafFrame.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/frames/BTreeNSMLeafFrame.java
@@ -175,10 +175,7 @@ public class BTreeNSMLeafFrame extends TreeIndexNSMFrame implements IBTreeLeafFr
     }
 
     boolean isLargeTuple(int tupleSize) {
-        // TODO(mblow): make page size available to avoid calculating it
-        int pageSize = getLargeFlag() ? buf.capacity() / page.getFrameSizeMultiplier() :
buf.capacity();
-
-        return tupleSize > getMaxTupleSize(pageSize);
+        return tupleSize > getMaxTupleSize(page.getPageSize());
     }
 
     @Override
@@ -247,9 +244,11 @@ public class BTreeNSMLeafFrame extends TreeIndexNSMFrame implements IBTreeLeafFr
                 targetFrame = this;
             }
             int tuplesToRight = tupleCount - tuplesToLeft;
-            if (getLargeFlag()) {
-                ((BTreeNSMLeafFrame) rightFrame).growCapacity(extraPageBlockHelper, bufferCache,
-                        buf.capacity() - rightFrame.getBuffer().capacity());
+
+            ((BTreeNSMLeafFrame) rightFrame).setLargeFlag(getLargeFlag());
+            int deltaPages = page.getFrameSizeMultiplier() - rightFrame.getPage().getFrameSizeMultiplier();
+            if (deltaPages > 0) {
+                ((BTreeNSMLeafFrame) rightFrame).growCapacity(extraPageBlockHelper, bufferCache,
deltaPages);
             }
 
             ByteBuffer right = rightFrame.getBuffer();
@@ -298,18 +297,18 @@ public class BTreeNSMLeafFrame extends TreeIndexNSMFrame implements
IBTreeLeafFr
 
     public void ensureCapacity(IBufferCache bufferCache, ITupleReference tuple,
                                IExtraPageBlockHelper extraPageBlockHelper) throws HyracksDataException
{
+        // we call ensureCapacity() for large tuples- ensure large flag is set
+        setLargeFlag(true);
         int gapBytes = getBytesRequiredToWriteTuple(tuple) - getFreeContiguousSpace();
-        growCapacity(extraPageBlockHelper, bufferCache, gapBytes);
+        if (gapBytes > 0) {
+            int deltaPages = (int) Math.ceil((double) gapBytes / bufferCache.getPageSize());
+            growCapacity(extraPageBlockHelper, bufferCache, deltaPages);
+        }
     }
 
-    public void growCapacity(IExtraPageBlockHelper extraPageBlockHelper,
-            IBufferCache bufferCache, int delta) throws HyracksDataException {
-        setLargeFlag(true);
-        if (delta <= 0) {
-            return;
-        }
-        int deltaPages = (int) Math.ceil((double) delta / bufferCache.getPageSize());
-        int framePagesOld = getBuffer().capacity() / bufferCache.getPageSize();
+    private void growCapacity(IExtraPageBlockHelper extraPageBlockHelper,
+            IBufferCache bufferCache, int deltaPages) throws HyracksDataException {
+        int framePagesOld = page.getFrameSizeMultiplier();
         int newMultiplier = framePagesOld + deltaPages;
 
         // we need to get the old slot offsets before we grow

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/dc58d30d/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/VirtualBufferCache.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/VirtualBufferCache.java
b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/VirtualBufferCache.java
index 40c7734..c8ce00f 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/VirtualBufferCache.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/VirtualBufferCache.java
@@ -405,6 +405,11 @@ public class VirtualBufferCache implements IVirtualBufferCache {
         }
 
         @Override
+        public int getPageSize() {
+            return pageSize;
+        }
+
+        @Override
         public int getFrameSizeMultiplier() {
             return multiplier;
         }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/dc58d30d/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/CachedPage.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/CachedPage.java
b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/CachedPage.java
index 4541d52..f003649 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/CachedPage.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/CachedPage.java
@@ -165,6 +165,11 @@ public class CachedPage implements ICachedPageInternal {
     }
 
     @Override
+    public int getPageSize() {
+        return pageReplacementStrategy.getPageSize();
+    }
+
+    @Override
     public void setFrameSizeMultiplier(int multiplier) {
         this.multiplier = multiplier;
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/dc58d30d/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/ICachedPage.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/ICachedPage.java
b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/ICachedPage.java
index 8107234..abbe233 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/ICachedPage.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/ICachedPage.java
@@ -38,5 +38,7 @@ public interface ICachedPage {
 
     void setQueueInfo(IQueueInfo queueInfo);
 
+    int getPageSize();
+
     int getFrameSizeMultiplier();
 }


Mime
View raw message