[ASTERIXDB-3407][STO] Increment page counter for valid pages
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
When reading a valid page from the buffer cache,
the page counter in CloudMegaPageReadContext should
be incremented.
Change-Id: I7cfa419d216cf875a4e403c8b90b5a0007bf9bfc
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18323
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree-column/src/main/java/org/apache/hyracks/storage/am/lsm/btree/column/cloud/buffercache/read/CloudMegaPageReadContext.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree-column/src/main/java/org/apache/hyracks/storage/am/lsm/btree/column/cloud/buffercache/read/CloudMegaPageReadContext.java
index 0f0b0b9..f1b2fd4 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree-column/src/main/java/org/apache/hyracks/storage/am/lsm/btree/column/cloud/buffercache/read/CloudMegaPageReadContext.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree-column/src/main/java/org/apache/hyracks/storage/am/lsm/btree/column/cloud/buffercache/read/CloudMegaPageReadContext.java
@@ -68,7 +68,7 @@
@Override
public void onPin(ICachedPage page) throws HyracksDataException {
CloudCachedPage cachedPage = (CloudCachedPage) page;
- if (gapStream != null && cachedPage.skipCloudStream()) {
+ if (cachedPage.skipCloudStream()) {
/*
* This page is requested but the buffer cache has a valid copy in memory. Also, the page itself was
* requested to be read from the cloud. Since this page is valid, no buffer cache read() will be performed.
@@ -76,14 +76,8 @@
* up writing the bytes of this page in the position of another page. Therefore, we should skip the bytes
* for this particular page to avoid placing the bytes of this page into another page's position.
*/
- try {
- long remaining = cachedPage.getCompressedPageSize();
- while (remaining > 0) {
- remaining -= gapStream.skip(remaining);
- }
- } catch (IOException e) {
- throw HyracksDataException.create(e);
- }
+ skipCloudBytes(cachedPage);
+ pageCounter++;
}
}
@@ -187,16 +181,32 @@
return gapStream;
}
- LOGGER.info("Cloud stream read for {} pages", numberOfContiguousPages - pageCounter);
int requiredNumOfPages = numberOfContiguousPages - pageCounter;
long offset = cPage.getCompressedPageOffset();
int pageId = BufferedFileHandle.getPageId(cPage.getDiskPageId());
long length = fileHandle.getPagesTotalSize(pageId, requiredNumOfPages);
+ LOGGER.info("Cloud stream read for {} pages [{}, {}]", numberOfContiguousPages - pageCounter, pageId,
+ pageId + requiredNumOfPages);
ICloudIOManager cloudIOManager = (ICloudIOManager) ioManager;
gapStream = cloudIOManager.cloudRead(fileHandle.getFileHandle(), offset, length);
return gapStream;
}
+ private void skipCloudBytes(CloudCachedPage cachedPage) throws HyracksDataException {
+ if (gapStream == null) {
+ return;
+ }
+
+ try {
+ long remaining = cachedPage.getCompressedPageSize();
+ while (remaining > 0) {
+ remaining -= gapStream.skip(remaining);
+ }
+ } catch (IOException e) {
+ throw HyracksDataException.create(e);
+ }
+ }
+
}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/compression/file/CompressedFileManager.java b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/compression/file/CompressedFileManager.java
index 365b92d..da908b1 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/compression/file/CompressedFileManager.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/compression/file/CompressedFileManager.java
@@ -258,6 +258,10 @@
}
public long getTotalCompressedSize(int startPageId, int numberOfPages) throws HyracksDataException {
+ if (startPageId + numberOfPages > totalNumOfPages) {
+ throw new IndexOutOfBoundsException(startPageId + " + " + numberOfPages + " > " + totalNumOfPages);
+ }
+
int lafPageId = -1;
ICachedPage lafPage = null;
long totalSize = 0;