You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by AsterixDB Code Review <do...@asterix-gerrit.ics.uci.edu> on 2024/02/20 22:03:51 UTC
Change in asterixdb[master]: [WIP] Introduce IBufferOperationContext
From Wail Alkowaileet <wa...@gmail.com>:
Wail Alkowaileet has uploaded this change for review. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18171 )
Change subject: [WIP] Introduce IBufferOperationContext
......................................................................
[WIP] Introduce IBufferOperationContext
Change-Id: I4472b34926845b1c78a6582dfe8bafd4dc8a3e7a
---
M hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/freepage/AppendOnlyLinkedMetadataPageManager.java
M hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/org/apache/hyracks/storage/am/btree/StorageFileAccessTest.java
M hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/IBufferCache.java
A hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/NoStatsBufferCacheOperationContext.java
M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/GlobalVirtualBufferCache.java
M hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/VirtualBufferCache.java
M hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/TreeTupleSorter.java
M hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/AbstractTreeIndex.java
M hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/freepage/VirtualFreePageManager.java
M hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/impls/RTreeSearchCursor.java
M hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeCountingSearchCursor.java
M hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/util/TreeIndexStatsGatherer.java
M hyracks-fullstack/hyracks/hyracks-storage-am-bloomfilter/src/main/java/org/apache/hyracks/storage/am/bloomfilter/impls/BloomFilter.java
A hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/PinNewBufferCacheOperationContext.java
M hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/ondisk/fixedsize/FixedSizeElementInvertedListScanCursor.java
M hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/freepage/LinkedMetaDataPageManager.java
M hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeRangeSearchCursor.java
M hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndexFileManager.java
M hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree-column/src/main/java/org/apache/hyracks/storage/am/lsm/btree/column/impls/btree/ColumnBTreeRangeSearchCursor.java
M hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheWithCompressionTest.java
M hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/AbstractOnDiskInvertedListCursor.java
M hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java
M hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/MultitenantVirtualBufferCache.java
M hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/TreeIndexDiskOrderScanCursor.java
M hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/DiskBTreeRangeSearchCursor.java
M hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/impls/RTree.java
M hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/org/apache/hyracks/storage/am/lsm/common/test/VirtualBufferCacheTest.java
M hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/org/apache/hyracks/storage/am/btree/FieldPrefixNSMTest.java
M hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheTest.java
M hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/util/TreeIndexBufferCacheWarmup.java
M hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/DebugBufferCache.java
M hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheRegressionTest.java
A hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/IBufferCacheOperationContext.java
A hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/BufferCacheOperationContextProvider.java
M hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/compression/file/CompressedFileManager.java
M hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTree.java
M hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/org/apache/hyracks/storage/am/lsm/btree/impl/TestVirtualBufferCache.java
M hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/CachedPage.java
M hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/DiskBTree.java
A hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/DefaultBufferCacheOperationContext.java
40 files changed, 382 insertions(+), 249 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/71/18171/1
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/GlobalVirtualBufferCache.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/GlobalVirtualBufferCache.java
index fb88c65..372c41a 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/GlobalVirtualBufferCache.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/GlobalVirtualBufferCache.java
@@ -18,6 +18,8 @@
*/
package org.apache.asterix.common.context;
+import static org.apache.hyracks.storage.common.buffercache.context.BufferCacheOperationContextProvider.DEFAULT;
+
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
@@ -49,6 +51,7 @@
import org.apache.hyracks.storage.common.buffercache.IPageWriteCallback;
import org.apache.hyracks.storage.common.buffercache.IPageWriteFailureCallback;
import org.apache.hyracks.storage.common.buffercache.VirtualPage;
+import org.apache.hyracks.storage.common.buffercache.context.IBufferCacheOperationContext;
import org.apache.hyracks.storage.common.file.BufferedFileHandle;
import org.apache.hyracks.storage.common.file.IFileMapManager;
import org.apache.hyracks.util.ExitUtil;
@@ -264,20 +267,20 @@
}
@Override
- public ICachedPage pin(long dpid, boolean newPage) throws HyracksDataException {
- ICachedPage page = vbc.pin(dpid, newPage);
- if (newPage) {
+ public ICachedPage pin(long dpid) throws HyracksDataException {
+ return pin(dpid, DEFAULT);
+ }
+
+ @Override
+ public ICachedPage pin(long dpid, IBufferCacheOperationContext context) throws HyracksDataException {
+ ICachedPage page = vbc.pin(dpid, context);
+ if (context.isNewPage()) {
incrementFilteredMemoryComponentUsage(dpid, 1);
checkAndNotifyFlushThread();
}
return page;
}
- @Override
- public ICachedPage pin(long dpid, boolean newPage, boolean incrementStats) throws HyracksDataException {
- return pin(dpid, newPage);
- }
-
private void incrementFilteredMemoryComponentUsage(long dpid, int pages) {
if (filteredMemoryComponentMaxNumPages > 0) {
// update memory usage of filtered index
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-bloomfilter/src/main/java/org/apache/hyracks/storage/am/bloomfilter/impls/BloomFilter.java b/hyracks-fullstack/hyracks/hyracks-storage-am-bloomfilter/src/main/java/org/apache/hyracks/storage/am/bloomfilter/impls/BloomFilter.java
index 6c0badc..11005a0 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-bloomfilter/src/main/java/org/apache/hyracks/storage/am/bloomfilter/impls/BloomFilter.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-bloomfilter/src/main/java/org/apache/hyracks/storage/am/bloomfilter/impls/BloomFilter.java
@@ -92,7 +92,7 @@
pages = new ICachedPage[numPages];
}
for (int i = 0; i < numPages; i++) {
- pages[i] = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, i + 1), false);
+ pages[i] = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, i + 1));
}
pagesPinned = true;
}
@@ -155,7 +155,7 @@
if (pagesPinned) {
page = pages[pageId];
} else {
- page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId + 1), false);
+ page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId + 1));
unpinWhenExit = true;
}
ByteBuffer buffer = page.getBuffer();
@@ -186,7 +186,7 @@
// we increment the page id by one, since the metadata page id of the filter is 0.
ICachedPage page =
- bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, (int) (hash / numBitsPerPage) + 1), false);
+ bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, (int) (hash / numBitsPerPage) + 1));
page.acquireReadLatch();
try {
ByteBuffer buffer = page.getBuffer();
@@ -235,7 +235,7 @@
version = DEFAULT_BLOOM_FILTER_VERSION;
return;
}
- ICachedPage metaPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, METADATA_PAGE_ID), false);
+ ICachedPage metaPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, METADATA_PAGE_ID));
metaPage.acquireReadLatch();
try {
numPages = metaPage.getBuffer().getInt(NUM_PAGES_OFFSET);
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTree.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTree.java
index 40b2f5c..2741c04 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTree.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTree.java
@@ -19,6 +19,8 @@
package org.apache.hyracks.storage.am.btree.impls;
+import static org.apache.hyracks.storage.common.buffercache.context.BufferCacheOperationContextProvider.NEW;
+
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -99,7 +101,7 @@
RangePredicate diskOrderScanPred = new RangePredicate(null, null, true, true, ctx.getCmp(), ctx.getCmp());
int maxPageId = freePageManager.getMaxPageId(ctx.getMetaFrame());
int currentPageId = bulkloadLeafStart;
- ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), currentPageId), false);
+ ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), currentPageId));
page.acquireReadLatch();
try {
cursor.setBufferCache(bufferCache);
@@ -131,7 +133,7 @@
}
private void validate(BTreeOpContext ctx, int pageId) throws HyracksDataException {
- ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId), false);
+ ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId));
ctx.getInteriorFrame().setPage(page);
PageValidationInfo currentPvi = ctx.getValidationInfos().peekFirst();
@@ -215,7 +217,7 @@
ICachedPage originalPage = ctx.getInteriorFrame().getPage();
for (int i = 0; i < ctx.getSmPages().size(); i++) {
int pageId = ctx.getSmPages().get(i);
- ICachedPage smPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId), false);
+ ICachedPage smPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId));
smPage.acquireWriteLatch();
try {
ctx.getInteriorFrame().setPage(smPage);
@@ -240,11 +242,11 @@
private void createNewRoot(BTreeOpContext ctx) throws HyracksDataException {
// Make sure the root is always in the same page.
ICachedPage leftNode =
- bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), ctx.getSplitKey().getLeftPage()), false);
+ bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), ctx.getSplitKey().getLeftPage()));
leftNode.acquireWriteLatch();
try {
int newLeftId = freePageManager.takePage(ctx.getMetaFrame());
- ICachedPage newLeftNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), newLeftId), true);
+ ICachedPage newLeftNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), newLeftId), NEW);
newLeftNode.acquireWriteLatch();
try {
boolean largePage = false;
@@ -352,7 +354,7 @@
}
}
int rightPageId = freePageManager.takePage(ctx.getMetaFrame());
- ICachedPage rightNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), rightPageId), true);
+ ICachedPage rightNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), rightPageId), NEW);
rightNode.acquireWriteLatch();
try {
IBTreeLeafFrame rightFrame = ctx.createLeafFrame();
@@ -472,7 +474,7 @@
case INSUFFICIENT_SPACE: {
int rightPageId = freePageManager.takePage(ctx.getMetaFrame());
ICachedPage rightNode =
- bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), rightPageId), true);
+ bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), rightPageId), NEW);
rightNode.acquireWriteLatch();
try {
IBTreeFrame rightFrame = ctx.createInteriorFrame();
@@ -551,7 +553,7 @@
}
private ICachedPage isConsistent(int pageId, BTreeOpContext ctx) throws Exception {
- ICachedPage node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId), false);
+ ICachedPage node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId));
node.acquireReadLatch();
ctx.getInteriorFrame().setPage(node);
boolean isConsistent = ctx.getPageLsns().getLast() == ctx.getInteriorFrame().getPageLsn();
@@ -565,7 +567,7 @@
private void performOp(int pageId, ICachedPage parent, boolean parentIsReadLatched, BTreeOpContext ctx)
throws HyracksDataException {
- ICachedPage node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId), false);
+ ICachedPage node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId));
ctx.getInteriorFrame().setPage(node);
// this check performs an unprotected read in the page
// the following could happen: TODO fill out
@@ -626,8 +628,8 @@
case UPDATE: {
// Is there a propagated split key?
if (ctx.getSplitKey().getBuffer() != null) {
- ICachedPage interiorNode = bufferCache
- .pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId), false);
+ ICachedPage interiorNode =
+ bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId));
interiorNode.acquireWriteLatch();
try {
// Insert or update op. Both can cause split keys to propagate upwards.
@@ -776,7 +778,7 @@
public void printTree(int pageId, ICachedPage parent, boolean unpin, IBTreeLeafFrame leafFrame,
IBTreeInteriorFrame interiorFrame, byte treeHeight, ISerializerDeserializer[] keySerdes,
StringBuilder strBuilder, MultiComparator cmp) throws Exception {
- ICachedPage node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId), false);
+ ICachedPage node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId));
node.acquireReadLatch();
try {
if (parent != null && unpin == true) {
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeCountingSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeCountingSearchCursor.java
index 1491424..37d3828 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeCountingSearchCursor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeCountingSearchCursor.java
@@ -119,7 +119,7 @@
private void fetchNextLeafPage(int nextLeafPage) throws HyracksDataException {
do {
- ICachedPage nextLeaf = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, nextLeafPage), false);
+ ICachedPage nextLeaf = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, nextLeafPage));
if (exclusiveLatchNodes) {
nextLeaf.acquireWriteLatch();
page.releaseWriteLatch(isPageDirty);
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeRangeSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeRangeSearchCursor.java
index 9ccd881..6727703 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeRangeSearchCursor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeRangeSearchCursor.java
@@ -303,7 +303,7 @@
}
protected ICachedPage acquirePage(int pageId) throws HyracksDataException {
- ICachedPage nextPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId), false);
+ ICachedPage nextPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId));
if (exclusiveLatchNodes) {
nextPage.acquireWriteLatch();
} else {
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/DiskBTree.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/DiskBTree.java
index 179f1da..af00227 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/DiskBTree.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/DiskBTree.java
@@ -56,7 +56,7 @@
RangePredicate diskOrderScanPred = new RangePredicate(null, null, true, true, ctx.getCmp(), ctx.getCmp());
int maxPageId = freePageManager.getMaxPageId(ctx.getMetaFrame());
int currentPageId = bulkloadLeafStart;
- ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), currentPageId), false);
+ ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), currentPageId));
try {
cursor.setBufferCache(bufferCache);
cursor.setFileId(getFileId());
@@ -101,7 +101,7 @@
}
}
}
- ICachedPage rootNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), rootPage), false);
+ ICachedPage rootNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), rootPage));
searchDown(rootNode, rootPage, ctx, cursor);
}
@@ -125,7 +125,7 @@
bufferCache.unpin(currentPage);
pageId = childPageId;
- currentPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), childPageId), false);
+ currentPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), childPageId));
ctx.getInteriorFrame().setPage(currentPage);
}
@@ -230,7 +230,7 @@
@Override
protected ICachedPage acquireNextPage() throws HyracksDataException {
- ICachedPage nextPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, currentPageId), false);
+ ICachedPage nextPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, currentPageId));
return nextPage;
}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/DiskBTreeRangeSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/DiskBTreeRangeSearchCursor.java
index d788398..3dc4df7 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/DiskBTreeRangeSearchCursor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/DiskBTreeRangeSearchCursor.java
@@ -73,7 +73,7 @@
@Override
protected ICachedPage acquirePage(int pageId) throws HyracksDataException {
stats.getPageCounter().update(1);
- return bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId), false);
+ return bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId));
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/freepage/AppendOnlyLinkedMetadataPageManager.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/freepage/AppendOnlyLinkedMetadataPageManager.java
index 45fbd1b..d5d860a 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/freepage/AppendOnlyLinkedMetadataPageManager.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/freepage/AppendOnlyLinkedMetadataPageManager.java
@@ -52,7 +52,7 @@
@Override
public void releasePage(ITreeIndexMetadataFrame metaFrame, int freePageNum) throws HyracksDataException {
- ICachedPage metaPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()), false);
+ ICachedPage metaPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()));
metaPage.acquireWriteLatch();
try {
metaFrame.setPage(metaPage);
@@ -64,7 +64,7 @@
throw new HyracksDataException(
"Inconsistent Meta Page State. It has no space, but it also has no entries.");
}
- ICachedPage newNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, newPageNum), false);
+ ICachedPage newNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, newPageNum));
newNode.acquireWriteLatch();
try {
int metaMaxPage = metaFrame.getMaxPage();
@@ -103,7 +103,7 @@
if (freePage < 0) { // no free page entry on this page
int nextPage = metaFrame.getNextMetadataPage();
if (nextPage > 0) { // sibling may have free pages
- ICachedPage nextNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, nextPage), false);
+ ICachedPage nextNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, nextPage));
nextNode.acquireWriteLatch();
// we copy over the free space entries of nextpage into the
// first meta page (metaDataPage)
@@ -158,7 +158,7 @@
if (mdPage < 0) {
return IBufferCache.INVALID_PAGEID;
}
- metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, mdPage), false);
+ metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, mdPage));
} else {
metaNode = confiscatedPage;
}
@@ -282,7 +282,7 @@
public int getRootPageId() throws HyracksDataException {
ICachedPage metaNode;
if (confiscatedPage == null) {
- metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()), false);
+ metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()));
} else {
metaNode = confiscatedPage;
}
@@ -320,8 +320,7 @@
}
private ICachedPage pinPage() throws HyracksDataException {
- return confiscatedPage == null
- ? bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()), false)
+ return confiscatedPage == null ? bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()))
: confiscatedPage;
}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/freepage/LinkedMetaDataPageManager.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/freepage/LinkedMetaDataPageManager.java
index e348e24..e7c6327 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/freepage/LinkedMetaDataPageManager.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/freepage/LinkedMetaDataPageManager.java
@@ -18,6 +18,8 @@
*/
package org.apache.hyracks.storage.am.common.freepage;
+import static org.apache.hyracks.storage.common.buffercache.context.BufferCacheOperationContextProvider.NEW;
+
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.api.IValueReference;
@@ -32,8 +34,7 @@
import org.apache.hyracks.storage.common.file.BufferedFileHandle;
/**
- * @deprecated
- * This class must not be used. Instead, use {@link AppendOnlyLinkedMetadataPageManager}
+ * @deprecated This class must not be used. Instead, use {@link AppendOnlyLinkedMetadataPageManager}
*/
@Deprecated
public class LinkedMetaDataPageManager implements IMetadataPageManager {
@@ -50,7 +51,7 @@
@Override
public void releasePage(ITreeIndexMetadataFrame metaFrame, int freePageNum) throws HyracksDataException {
// Get the metadata node
- ICachedPage metaPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()), false);
+ ICachedPage metaPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()));
metaPage.acquireWriteLatch();
try {
metaFrame.setPage(metaPage);
@@ -65,7 +66,7 @@
"Inconsistent Meta Page State. It has no space, but it also has no entries.");
}
- ICachedPage newNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, newPageNum), false);
+ ICachedPage newNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, newPageNum));
newNode.acquireWriteLatch();
try {
@@ -100,7 +101,7 @@
@Override
public int takePage(ITreeIndexMetadataFrame metaFrame) throws HyracksDataException {
- ICachedPage metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()), false);
+ ICachedPage metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()));
metaNode.acquireWriteLatch();
int freePage = IBufferCache.INVALID_PAGEID;
try {
@@ -109,7 +110,7 @@
if (freePage < 0) { // no free page entry on this page
int nextPage = metaFrame.getNextMetadataPage();
if (nextPage > 0) { // sibling may have free pages
- ICachedPage nextNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, nextPage), false);
+ ICachedPage nextNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, nextPage));
nextNode.acquireWriteLatch();
// we copy over the free space entries of nextpage into the
@@ -169,7 +170,7 @@
if (mdPage < 0) {
return IBufferCache.INVALID_PAGEID;
}
- metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, mdPage), false);
+ metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, mdPage));
metaNode.acquireReadLatch();
int maxPage = -1;
@@ -192,7 +193,7 @@
if (metaPage == IBufferCache.INVALID_PAGEID) {
throw new HyracksDataException("No valid metadata found in this file.");
}
- ICachedPage metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()), true);
+ ICachedPage metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()), NEW);
metaNode.acquireWriteLatch();
try {
metaFrame.setPage(metaNode);
@@ -205,7 +206,7 @@
bufferCache.unpin(metaNode);
}
int rootPage = getRootPageId();
- ICachedPage rootNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, rootPage), true);
+ ICachedPage rootNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, rootPage), NEW);
rootNode.acquireWriteLatch();
try {
ITreeIndexFrame leafFrame = leafFrameFactory.createFrame();
@@ -230,7 +231,7 @@
@Override
public void setRootPageId(int rootPage) throws HyracksDataException {
- ICachedPage metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()), false);
+ ICachedPage metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()));
ITreeIndexMetadataFrame metaFrame = frameFactory.createFrame();
metaNode.acquireWriteLatch();
try {
@@ -246,8 +247,7 @@
@Override
public void close(IPageWriteFailureCallback callback) throws HyracksDataException {
if (ready) {
- ICachedPage metaNode =
- bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()), false);
+ ICachedPage metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()));
ITreeIndexMetadataFrame metaFrame = frameFactory.createFrame();
metaNode.acquireWriteLatch();
try {
@@ -280,7 +280,7 @@
@Override
public int getRootPageId() throws HyracksDataException {
ICachedPage metaNode;
- metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()), false);
+ metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()));
ITreeIndexMetadataFrame metaFrame = frameFactory.createFrame();
metaNode.acquireReadLatch();
try {
@@ -299,7 +299,7 @@
@Override
public boolean isEmpty(ITreeIndexFrame frame, int rootPage) throws HyracksDataException {
- ICachedPage rootNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, rootPage), false);
+ ICachedPage rootNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, rootPage));
rootNode.acquireReadLatch();
try {
frame.setPage(rootNode);
@@ -325,8 +325,7 @@
public long getFileOffset(ITreeIndexMetadataFrame frame, IValueReference key) throws HyracksDataException {
int metadataPageNum = getMetadataPageId();
if (metadataPageNum != IBufferCache.INVALID_PAGEID) {
- ICachedPage metaNode =
- bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()), false);
+ ICachedPage metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()));
metaNode.acquireReadLatch();
try {
frame.setPage(metaNode);
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/AbstractTreeIndex.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/AbstractTreeIndex.java
index a319c53..ff1011a 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/AbstractTreeIndex.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/AbstractTreeIndex.java
@@ -167,7 +167,7 @@
}
public byte getTreeHeight(ITreeIndexFrame frame) throws HyracksDataException {
- ICachedPage rootNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, rootPage), false);
+ ICachedPage rootNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, rootPage));
rootNode.acquireReadLatch();
try {
frame.setPage(rootNode);
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/TreeIndexDiskOrderScanCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/TreeIndexDiskOrderScanCursor.java
index 36fba76..14decb4 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/TreeIndexDiskOrderScanCursor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/TreeIndexDiskOrderScanCursor.java
@@ -151,7 +151,7 @@
}
protected ICachedPage acquireNextPage() throws HyracksDataException {
- ICachedPage nextPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, currentPageId), false);
+ ICachedPage nextPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, currentPageId));
nextPage.acquireReadLatch();
return nextPage;
}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/util/TreeIndexBufferCacheWarmup.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/util/TreeIndexBufferCacheWarmup.java
index 959f27a..4b8337b 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/util/TreeIndexBufferCacheWarmup.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/util/TreeIndexBufferCacheWarmup.java
@@ -53,7 +53,7 @@
// scan entire file to determine pages in each level
int maxPageId = freePageManager.getMaxPageId(metaFrame);
for (int pageId = 0; pageId <= maxPageId; pageId++) {
- ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId), false);
+ ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId));
page.acquireReadLatch();
try {
frame.setPage(page);
@@ -87,7 +87,7 @@
int pageId = remainingPageIds[index];
// pin & latch then immediately unlatch & unpin
- ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId), false);
+ ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId));
page.acquireReadLatch();
page.releaseReadLatch();
bufferCache.unpin(page);
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/util/TreeIndexStatsGatherer.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/util/TreeIndexStatsGatherer.java
index 5410282..b6f239b 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/util/TreeIndexStatsGatherer.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/util/TreeIndexStatsGatherer.java
@@ -49,7 +49,7 @@
treeIndexStats.begin();
int maxPageId = freePageManager.getMaxPageId(metaFrame);
for (int pageId = 0; pageId <= maxPageId; pageId++) {
- ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId), false);
+ ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId));
page.acquireReadLatch();
try {
metaFrame.setPage(page);
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree-column/src/main/java/org/apache/hyracks/storage/am/lsm/btree/column/impls/btree/ColumnBTreeRangeSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree-column/src/main/java/org/apache/hyracks/storage/am/lsm/btree/column/impls/btree/ColumnBTreeRangeSearchCursor.java
index 39952df..abac582 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree-column/src/main/java/org/apache/hyracks/storage/am/lsm/btree/column/impls/btree/ColumnBTreeRangeSearchCursor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree-column/src/main/java/org/apache/hyracks/storage/am/lsm/btree/column/impls/btree/ColumnBTreeRangeSearchCursor.java
@@ -86,7 +86,7 @@
private void fetchNextLeafPage(int leafPage) throws HyracksDataException {
int nextLeafPage = leafPage;
do {
- ICachedPage nextLeaf = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, nextLeafPage), false);
+ ICachedPage nextLeaf = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, nextLeafPage));
stats.getPageCounter().update(1);
bufferCache.unpin(page0);
page0 = nextLeaf;
@@ -285,7 +285,7 @@
@Override
public ICachedPage pin(int pageId) throws HyracksDataException {
stats.getPageCounter().update(1);
- return bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId), false);
+ return bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId));
}
@Override
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/freepage/VirtualFreePageManager.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/freepage/VirtualFreePageManager.java
index 9d62c0d..144d662 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/freepage/VirtualFreePageManager.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/freepage/VirtualFreePageManager.java
@@ -19,6 +19,8 @@
package org.apache.hyracks.storage.am.lsm.common.freepage;
+import static org.apache.hyracks.storage.common.buffercache.context.BufferCacheOperationContextProvider.NEW;
+
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.hyracks.api.exceptions.HyracksDataException;
@@ -97,11 +99,11 @@
public void init(ITreeIndexFrameFactory interiorFrameFactory, ITreeIndexFrameFactory leafFrameFactory)
throws HyracksDataException {
currentPageId.set(1);
- ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, 0), true);
+ ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, 0), NEW);
page.acquireWriteLatch();
page.releaseWriteLatch(false);
bufferCache.unpin(page);
- page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, currentPageId.get()), true);
+ page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, currentPageId.get()), NEW);
if (leafFrameFactory != null) {
page.acquireWriteLatch();
ITreeIndexFrame leafFrame = leafFrameFactory.createFrame();
@@ -130,7 +132,7 @@
@Override
public boolean isEmpty(ITreeIndexFrame frame, int rootPage) throws HyracksDataException {
- ICachedPage rootNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, rootPage), false);
+ ICachedPage rootNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, rootPage));
rootNode.acquireReadLatch();
try {
frame.setPage(rootNode);
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndexFileManager.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndexFileManager.java
index cff54a0..0c442a7 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndexFileManager.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndexFileManager.java
@@ -115,8 +115,7 @@
return TreeIndexState.INVALID;
}
ITreeIndexMetadataFrame metadataFrame = treeIndex.getPageManager().createMetadataFrame();
- ICachedPage page =
- bufferCache.pin(BufferedFileHandle.getDiskPageId(treeIndex.getFileId(), metadataPage), false);
+ ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(treeIndex.getFileId(), metadataPage));
page.acquireReadLatch();
try {
metadataFrame.setPage(page);
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/MultitenantVirtualBufferCache.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/MultitenantVirtualBufferCache.java
index 959bb50..66cc7c7 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/MultitenantVirtualBufferCache.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/MultitenantVirtualBufferCache.java
@@ -18,6 +18,8 @@
*/
package org.apache.hyracks.storage.am.lsm.common.impls;
+import static org.apache.hyracks.storage.common.buffercache.context.BufferCacheOperationContextProvider.DEFAULT;
+
import java.util.HashMap;
import java.util.Map;
@@ -31,6 +33,7 @@
import org.apache.hyracks.storage.common.buffercache.IFIFOPageWriter;
import org.apache.hyracks.storage.common.buffercache.IPageWriteCallback;
import org.apache.hyracks.storage.common.buffercache.IPageWriteFailureCallback;
+import org.apache.hyracks.storage.common.buffercache.context.IBufferCacheOperationContext;
import org.apache.hyracks.storage.common.file.IFileMapManager;
import org.apache.hyracks.util.JSONUtil;
@@ -65,13 +68,13 @@
}
@Override
- public ICachedPage pin(long dpid, boolean newPage) throws HyracksDataException {
- return vbc.pin(dpid, newPage);
+ public ICachedPage pin(long dpid) throws HyracksDataException {
+ return pin(dpid, DEFAULT);
}
@Override
- public ICachedPage pin(long dpid, boolean newPage, boolean incrementStats) throws HyracksDataException {
- return vbc.pin(dpid, newPage);
+ public ICachedPage pin(long dpid, IBufferCacheOperationContext context) throws HyracksDataException {
+ return vbc.pin(dpid, context);
}
@Override
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 e222461..234b4601 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
@@ -18,6 +18,8 @@
*/
package org.apache.hyracks.storage.am.lsm.common.impls;
+import static org.apache.hyracks.storage.common.buffercache.context.BufferCacheOperationContextProvider.DEFAULT;
+
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
@@ -39,6 +41,7 @@
import org.apache.hyracks.storage.common.buffercache.IPageWriteCallback;
import org.apache.hyracks.storage.common.buffercache.IPageWriteFailureCallback;
import org.apache.hyracks.storage.common.buffercache.VirtualPage;
+import org.apache.hyracks.storage.common.buffercache.context.IBufferCacheOperationContext;
import org.apache.hyracks.storage.common.file.BufferedFileHandle;
import org.apache.hyracks.storage.common.file.FileMapManager;
import org.apache.hyracks.storage.common.file.IFileMapManager;
@@ -228,7 +231,13 @@
}
@Override
- public ICachedPage pin(long dpid, boolean newPage) throws HyracksDataException {
+ public ICachedPage pin(long dpid) throws HyracksDataException {
+ return pin(dpid, DEFAULT);
+ }
+
+ @Override
+ public ICachedPage pin(long dpid, IBufferCacheOperationContext context) throws HyracksDataException {
+ boolean newPage = context.isNewPage();
VirtualPage page;
int hash = hash(dpid);
CacheBucket bucket = buckets[hash];
@@ -260,11 +269,6 @@
return page;
}
- @Override
- public ICachedPage pin(long dpid, boolean newPage, boolean incrementStats) throws HyracksDataException {
- return pin(dpid, newPage);
- }
-
private int hash(long dpid) {
int hashValue = (int) dpid ^ (Integer.reverse((int) (dpid >>> 32)) >>> 1);
return hashValue % buckets.length;
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/AbstractOnDiskInvertedListCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/AbstractOnDiskInvertedListCursor.java
index 9886da4..c5ad6eb 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/AbstractOnDiskInvertedListCursor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/AbstractOnDiskInvertedListCursor.java
@@ -130,7 +130,8 @@
/**
* Tries to allocate enough buffers to read the inverted list at once. If memory budget is not enough, this method
- * stops allocating buffers. */
+ * stops allocating buffers.
+ */
protected void allocateBuffers() throws HyracksDataException {
do {
ByteBuffer tmpBuffer = bufferManagerForSearch.acquireFrame(bufferCache.getPageSize());
@@ -205,7 +206,7 @@
int currentBufferIdx = 0;
ByteBuffer tmpBuffer;
for (int i = bufferStartPageId; i <= endPageId; i++) {
- page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, i), false);
+ page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, i));
stats.getPageCounter().update(1);
// Copies the content to the buffer (working memory).
// Assumption: processing inverted list takes time; so, we don't want to keep them on the buffer cache.
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/ondisk/fixedsize/FixedSizeElementInvertedListScanCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/ondisk/fixedsize/FixedSizeElementInvertedListScanCursor.java
index 458eb6b..f237865 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/ondisk/fixedsize/FixedSizeElementInvertedListScanCursor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/ondisk/fixedsize/FixedSizeElementInvertedListScanCursor.java
@@ -119,7 +119,7 @@
return;
}
unloadPages();
- page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, currentPageId), false);
+ page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, currentPageId));
pinnedPageId = currentPageId;
pinned = true;
stats.getPageCounter().update(1);
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/TreeTupleSorter.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/TreeTupleSorter.java
index 9ef305c..3d3a069 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/TreeTupleSorter.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/org/apache/hyracks/storage/am/lsm/rtree/impls/TreeTupleSorter.java
@@ -76,8 +76,7 @@
// We don't latch pages since this code is only used by flush () before
// bulk-loading the r-tree to disk and flush is not concurrent.
//
- ICachedPage node1 =
- bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, tPointers[currentTupleIndex * 2]), false);
+ ICachedPage node1 = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, tPointers[currentTupleIndex * 2]));
try {
leafFrame1.setPage(node1);
frameTuple1.resetByTupleOffset(leafFrame1.getBuffer().array(), tPointers[currentTupleIndex * 2 + 1]);
@@ -183,10 +182,10 @@
int j1 = tPointers[tp1 * 2 + 1];
int i2 = tp2i;
int j2 = tp2j;
- ICachedPage node1 = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, i1), false);
+ ICachedPage node1 = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, i1));
try {
leafFrame1.setPage(node1);
- ICachedPage node2 = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, i2), false);
+ ICachedPage node2 = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, i2));
try {
leafFrame2.setPage(node2);
frameTuple1.resetByTupleOffset(leafFrame1.getBuffer().array(), j1);
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/impls/RTree.java b/hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/impls/RTree.java
index d85200f..600b761 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/impls/RTree.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/impls/RTree.java
@@ -19,6 +19,8 @@
package org.apache.hyracks.storage.am.rtree.impls;
+import static org.apache.hyracks.storage.common.buffercache.context.BufferCacheOperationContextProvider.NEW;
+
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@@ -104,7 +106,7 @@
public void printTree(int pageId, ICachedPage parent, boolean unpin, IRTreeLeafFrame leafFrame,
IRTreeInteriorFrame interiorFrame, byte treeHeight, ISerializerDeserializer[] keySerdes,
StringBuilder strBuilder, MultiComparator cmp) throws Exception {
- ICachedPage node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId), false);
+ ICachedPage node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId));
node.acquireReadLatch();
try {
if (parent != null && unpin == true) {
@@ -174,7 +176,7 @@
while (true) {
if (!writeLatched) {
- node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId), false);
+ node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId));
ctx.getInteriorFrame().setPage(node);
isLeaf = ctx.getInteriorFrame().isLeaf();
if (isLeaf) {
@@ -232,7 +234,7 @@
readLatched = false;
bufferCache.unpin(node);
- node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId), false);
+ node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId));
node.acquireWriteLatch();
writeLatched = true;
ctx.getInteriorFrame().setPage(node);
@@ -349,7 +351,7 @@
case INSUFFICIENT_SPACE: {
int rightPageId = freePageManager.takePage(ctx.getMetaFrame());
ICachedPage rightNode =
- bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), rightPageId), true);
+ bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), rightPageId), NEW);
rightNode.acquireWriteLatch();
try {
@@ -394,7 +396,7 @@
if (pageId == rootPage) {
int newLeftId = freePageManager.takePage(ctx.getMetaFrame());
ICachedPage newLeftNode =
- bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), newLeftId), true);
+ bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), newLeftId), NEW);
newLeftNode.acquireWriteLatch();
succeeded = false;
try {
@@ -452,7 +454,7 @@
boolean succeeded = false;
boolean writeLatched = false;
int parentId = ctx.getPathList().getLastPageId();
- ICachedPage parentNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), parentId), false);
+ ICachedPage parentNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), parentId));
parentNode.acquireWriteLatch();
writeLatched = true;
ctx.getInteriorFrame().setPage(parentNode);
@@ -478,7 +480,7 @@
}
parentId = rightPage;
- parentNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), parentId), false);
+ parentNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), parentId));
parentNode.acquireWriteLatch();
writeLatched = true;
ctx.getInteriorFrame().setPage(parentNode);
@@ -532,7 +534,7 @@
pageId = ctx.getTraverseList().getFirstPageId();
parentIndex = ctx.getTraverseList().getFirstPageIndex();
- node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId), false);
+ node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId));
node.acquireReadLatch();
readLatched = true;
ctx.getInteriorFrame().setPage(node);
@@ -615,7 +617,7 @@
int pageId = ctx.getPathList().getLastPageId();
long parentLsn = ctx.getPathList().getLastPageLsn();
ctx.getPathList().moveLast();
- node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId), false);
+ node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId));
node.acquireReadLatch();
readLatched = true;
ctx.getInteriorFrame().setPage(node);
@@ -648,7 +650,7 @@
readLatched = false;
bufferCache.unpin(node);
- node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId), false);
+ node = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), pageId));
node.acquireWriteLatch();
writeLatched = true;
ctx.getLeafFrame().setPage(node);
@@ -737,7 +739,7 @@
int currentPageId = bulkloadLeafStart;
int maxPageId = freePageManager.getMaxPageId(ctx.getMetaFrame());
- ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), currentPageId), false);
+ ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(getFileId(), currentPageId));
page.acquireReadLatch();
try {
cursor.setBufferCache(bufferCache);
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/impls/RTreeSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/impls/RTreeSearchCursor.java
index 80fc5bd..f78f010 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/impls/RTreeSearchCursor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/impls/RTreeSearchCursor.java
@@ -115,7 +115,7 @@
if (fileId < 0) {
throw new IllegalStateException();
}
- ICachedPage node = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId), false);
+ ICachedPage node = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId));
node.acquireReadLatch();
stats.getPageCounter().update(1);
readLatched = true;
@@ -154,7 +154,7 @@
} else {
page = node;
this.pageId = pageId; // This is only needed for the
- // LSMRTree flush operation
+ // LSMRTree flush operation
leafFrame.setPage(page);
tupleIndex = 0;
succeeded = true;
@@ -191,15 +191,15 @@
if (leafFrame.intersect(searchKey, i, cmp)) {
frameTuple.resetByTupleIndex(leafFrame, i);
currentTupleIndex = i; // This is only needed for the
- // LSMRTree flush operation
+ // LSMRTree flush operation
tupleIndexInc = i + 1;
return true;
}
} else {
frameTuple.resetByTupleIndex(leafFrame, i);
currentTupleIndex = i; // This is only needed for the
- // LSMRTree
- // flush operation
+ // LSMRTree
+ // flush operation
tupleIndexInc = i + 1;
return true;
}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java
index fed916d..101f394 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/BufferCache.java
@@ -18,6 +18,8 @@
*/
package org.apache.hyracks.storage.common.buffercache;
+import static org.apache.hyracks.storage.common.buffercache.context.BufferCacheOperationContextProvider.DEFAULT;
+
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
@@ -43,6 +45,7 @@
import org.apache.hyracks.api.lifecycle.ILifeCycleComponent;
import org.apache.hyracks.api.replication.IIOReplicationManager;
import org.apache.hyracks.api.util.ExceptionUtils;
+import org.apache.hyracks.storage.common.buffercache.context.IBufferCacheOperationContext;
import org.apache.hyracks.storage.common.compression.file.ICompressedPageWriter;
import org.apache.hyracks.storage.common.file.BufferedFileHandle;
import org.apache.hyracks.storage.common.file.IFileMapManager;
@@ -124,7 +127,6 @@
public BufferCache(IIOManager ioManager, IPageReplacementStrategy pageReplacementStrategy,
IPageCleanerPolicy pageCleanerPolicy, IFileMapManager fileMapManager, int maxOpenFiles, int ioQueueLen,
ThreadFactory threadFactory, IIOReplicationManager ioReplicationManager) {
-
this(ioManager, pageReplacementStrategy, pageCleanerPolicy, fileMapManager, maxOpenFiles, ioQueueLen,
threadFactory);
this.ioReplicationManager = ioReplicationManager;
@@ -164,12 +166,14 @@
}
@Override
- public ICachedPage pin(long dpid, boolean newPage) throws HyracksDataException {
- return pin(dpid, newPage, true);
+ public ICachedPage pin(long dpid) throws HyracksDataException {
+ return pin(dpid, DEFAULT);
}
@Override
- public ICachedPage pin(long dpid, boolean newPage, boolean incrementStats) throws HyracksDataException {
+ public ICachedPage pin(long dpid, IBufferCacheOperationContext context) throws HyracksDataException {
+ boolean newPage = context.isNewPage();
+ boolean incrementStats = context.incrementStats();
// Calling the pinSanityCheck should be used only for debugging, since
// the synchronized block over the fileInfoMap is a hot spot.
if (DEBUG) {
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 1d4c789..ea14331 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
@@ -190,6 +190,7 @@
return multiplier > 1;
}
+ @Override
public void setCompressedPageOffset(long offset) {
this.compressedOffset = offset;
}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/DebugBufferCache.java b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/DebugBufferCache.java
index c76c781..e3f75f6 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/DebugBufferCache.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/DebugBufferCache.java
@@ -24,6 +24,7 @@
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.api.io.FileReference;
import org.apache.hyracks.api.replication.IIOReplicationManager;
+import org.apache.hyracks.storage.common.buffercache.context.IBufferCacheOperationContext;
/**
* Implementation of an IBufferCache that counts the number of pins/unpins,
@@ -77,15 +78,15 @@
}
@Override
- public ICachedPage pin(long dpid, boolean newPage, boolean incrementStats) throws HyracksDataException {
- ICachedPage page = bufferCache.pin(dpid, newPage, incrementStats);
- pinCount.addAndGet(1);
- return page;
+ public ICachedPage pin(long dpid) throws HyracksDataException {
+ return null;
}
@Override
- public ICachedPage pin(long dpid, boolean newPage) throws HyracksDataException {
- return pin(dpid, newPage, true);
+ public ICachedPage pin(long dpid, IBufferCacheOperationContext context) throws HyracksDataException {
+ ICachedPage page = bufferCache.pin(dpid, context);
+ pinCount.addAndGet(1);
+ return page;
}
@Override
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/IBufferCache.java b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/IBufferCache.java
index 3e977bd..97e27ae 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/IBufferCache.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/IBufferCache.java
@@ -21,6 +21,7 @@
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.api.io.FileReference;
import org.apache.hyracks.api.replication.IIOReplicationManager;
+import org.apache.hyracks.storage.common.buffercache.context.IBufferCacheOperationContext;
import org.apache.hyracks.storage.common.compression.file.ICompressedPageWriter;
public interface IBufferCache {
@@ -32,52 +33,42 @@
/**
* Create file on disk
*
- * @param fileRef
- * the file to create
+ * @param fileRef the file to create
* @return the file id
- * @throws HyracksDataException
- * if the file already exists or attempt to create the file failed
+ * @throws HyracksDataException if the file already exists or attempt to create the file failed
*/
int createFile(FileReference fileRef) throws HyracksDataException;
/**
* Open the file and register it (if not registered) with the file map manager
*
- * @param fileRef
- * the file to open
+ * @param fileRef the file to open
* @return the file id
- * @throws HyracksDataException
- * if the file doesn't exist or buffer cache failed to open the file
+ * @throws HyracksDataException if the file doesn't exist or buffer cache failed to open the file
*/
int openFile(FileReference fileRef) throws HyracksDataException;
/**
* Open the mapped file with the passed file id
*
- * @param fileId
- * the file id
- * @throws HyracksDataException
- * if the file doesn't exist or buffer cache fails to open the file
+ * @param fileId the file id
+ * @throws HyracksDataException if the file doesn't exist or buffer cache fails to open the file
*/
void openFile(int fileId) throws HyracksDataException;
/**
* close the file
*
- * @param fileId
- * the file id
- * @throws HyracksDataException
- * if file doesn't exist or is not open
+ * @param fileId the file id
+ * @throws HyracksDataException if file doesn't exist or is not open
*/
void closeFile(int fileId) throws HyracksDataException;
/**
* delete the file from memory and disk
*
- * @param fileId
- * the file id
- * @throws HyracksDataException
- * if the file doesn't exist or if a failure to delete takes place
+ * @param fileId the file id
+ * @throws HyracksDataException if the file doesn't exist or if a failure to delete takes place
*/
void deleteFile(int fileId) throws HyracksDataException;
@@ -92,45 +83,18 @@
/**
* Pin the page so it can't be evicted from the buffer cache...
*
- * @param dpid
- * page id is a unique id that is a combination of file id and page id
- * @param newPage
- * whether this page is expected to be new.
- * NOTE: undefined:
- * -- what if the flag is true but the page exists?
- * -- what if the flag is false but the page doesn't exist
+ * @param dpid page id is a unique id that is a combination of file id and page id
* @return the pinned page
* @throws HyracksDataException
*/
- ICachedPage pin(long dpid, boolean newPage) throws HyracksDataException;
+ ICachedPage pin(long dpid) throws HyracksDataException;
- /**
- * Pin the page so it can't be evicted from the buffer cache...
- *
- * @param dpid
- * page id is a unique id that is a combination of file id and page id
- * @param newPage
- * whether this page is expected to be new.
- * NOTE: undefined:
- * -- what if the flag is true but the page exists?
- * -- what if the flag is false but the page doesn't exist
- *
- * @param incrementStats
- * whether to increment the coldRead and pinCount counters when
- * the page is pinned. this is to not bias the count when using
- * accessors that cause nested pins due to wrapping file handles,
- * like compression
- *
- * @return the pinned page
- * @throws HyracksDataException
- */
- ICachedPage pin(long dpid, boolean newPage, boolean incrementStats) throws HyracksDataException;
+ ICachedPage pin(long dpid, IBufferCacheOperationContext context) throws HyracksDataException;
/**
* Unpin a pinned page so its buffer can be recycled
*
- * @param page
- * the page
+ * @param page the page
* @throws HyracksDataException
*/
void unpin(ICachedPage page) throws HyracksDataException;
@@ -138,8 +102,7 @@
/**
* Flush the page if it is dirty
*
- * @param page
- * the page to flush
+ * @param page the page to flush
* @throws HyracksDataException
*/
void flush(ICachedPage page) throws HyracksDataException;
@@ -148,10 +111,8 @@
* Force bits that have been already flushed to disk
* This method doesn't flush all dirty pages to disk but simply calls the sync method on the filesystem api
*
- * @param fileId
- * the file id
- * @param metadata
- * whether metadata should be synced as well
+ * @param fileId the file id
+ * @param metadata whether metadata should be synced as well
* @throws HyracksDataException
*/
void force(int fileId, boolean metadata) throws HyracksDataException;
@@ -159,8 +120,7 @@
/**
* Take a page such that no one else has access to it
*
- * @param dpid
- * the unique (fileId,pageId)
+ * @param dpid the unique (fileId,pageId)
* @return the confiscated page or null if no page is available
* @throws HyracksDataException
*/
@@ -174,14 +134,10 @@
/**
* Take a large page such that no one else has access to it
*
- * @param dpid
- * the unique (fileId,pageId)
- * @param multiplier
- * how many multiples of the original page size
- * @param extraBlockPageId
- * the page id where the large block comes from
- * @return
- * the confiscated page or null if a large page couldn't be found
+ * @param dpid the unique (fileId,pageId)
+ * @param multiplier how many multiples of the original page size
+ * @param extraBlockPageId the page id where the large block comes from
+ * @return the confiscated page or null if a large page couldn't be found
* @throws HyracksDataException
*/
ICachedPage confiscateLargePage(long dpid, int multiplier, int extraBlockPageId) throws HyracksDataException;
@@ -189,18 +145,15 @@
/**
* Return and re-insert a confiscated page
*
- * @param page
- * the confiscated page
+ * @param page the confiscated page
*/
void returnPage(ICachedPage page);
/**
* Return a confiscated page
*
- * @param page
- * the confiscated page
- * @param reinsert
- * if true, return the page to the cache, otherwise, destroy
+ * @param page the confiscated page
+ * @param reinsert if true, return the page to the cache, otherwise, destroy
*/
void returnPage(ICachedPage page, boolean reinsert);
@@ -226,8 +179,7 @@
/**
* Get the number of pages used for a file
*
- * @param fileId
- * the file id
+ * @param fileId the file id
* @return the number of pages used for the file
* @throws HyracksDataException
*/
@@ -236,8 +188,7 @@
/**
* Get the reference count for a file (num of open - num of close)
*
- * @param fileId
- * the file
+ * @param fileId the file
* @return the reference count
*/
int getFileReferenceCount(int fileId);
@@ -256,6 +207,7 @@
IFIFOPageWriter createFIFOWriter(IPageWriteCallback callback, IPageWriteFailureCallback failureCallback);
// TODO: remove the replication out of the buffer cache interface
+
/**
* @return true if replication is enabled, false otherwise
*/
@@ -268,7 +220,7 @@
/**
* Deletes the file and recycle all of its pages without flushing them.
- *
+ * <p>
* ONLY call this if you absolutely, positively know this file has no dirty pages in the cache!
* Bypasses the normal lifecycle of a file handle and evicts all references to it immediately.
*/
@@ -277,12 +229,9 @@
/**
* Resize the page
*
- * @param page
- * the page to resize
- * @param multiplier
- * how many multiples of the original page size
- * @param extraPageBlockHelper
- * helper to determine the location of the resize block
+ * @param page the page to resize
+ * @param multiplier how many multiples of the original page size
+ * @param extraPageBlockHelper helper to determine the location of the resize block
* @throws HyracksDataException
*/
void resizePage(ICachedPage page, int multiplier, IExtraPageBlockHelper extraPageBlockHelper)
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/BufferCacheOperationContextProvider.java b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/BufferCacheOperationContextProvider.java
new file mode 100644
index 0000000..bad2484
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/BufferCacheOperationContextProvider.java
@@ -0,0 +1,39 @@
+/*
+ * 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.hyracks.storage.common.buffercache.context;
+
+public class BufferCacheOperationContextProvider {
+ private BufferCacheOperationContextProvider() {
+ }
+
+ /**
+ * Pin a page and increment stats
+ */
+ public static final IBufferCacheOperationContext DEFAULT = new DefaultBufferCacheOperationContext();
+
+ /**
+ * Pin a new page
+ */
+ public static final IBufferCacheOperationContext NEW = new PinNewBufferCacheOperationContext();
+
+ /**
+ * Pin a page and do not increment the stats of the pinned page
+ */
+ public static final IBufferCacheOperationContext NO_STATS = new NoStatsBufferCacheOperationContext();
+}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/DefaultBufferCacheOperationContext.java b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/DefaultBufferCacheOperationContext.java
new file mode 100644
index 0000000..a04147a
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/DefaultBufferCacheOperationContext.java
@@ -0,0 +1,31 @@
+/*
+ * 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.hyracks.storage.common.buffercache.context;
+
+class DefaultBufferCacheOperationContext implements IBufferCacheOperationContext {
+ @Override
+ public boolean isNewPage() {
+ return false;
+ }
+
+ @Override
+ public boolean incrementStats() {
+ return true;
+ }
+}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/IBufferCacheOperationContext.java b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/IBufferCacheOperationContext.java
new file mode 100644
index 0000000..2518658
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/IBufferCacheOperationContext.java
@@ -0,0 +1,25 @@
+/*
+ * 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.hyracks.storage.common.buffercache.context;
+
+public interface IBufferCacheOperationContext {
+ boolean isNewPage();
+
+ boolean incrementStats();
+}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/NoStatsBufferCacheOperationContext.java b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/NoStatsBufferCacheOperationContext.java
new file mode 100644
index 0000000..3fe6910
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/NoStatsBufferCacheOperationContext.java
@@ -0,0 +1,31 @@
+/*
+ * 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.hyracks.storage.common.buffercache.context;
+
+class NoStatsBufferCacheOperationContext implements IBufferCacheOperationContext {
+ @Override
+ public boolean isNewPage() {
+ return false;
+ }
+
+ @Override
+ public boolean incrementStats() {
+ return false;
+ }
+}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/PinNewBufferCacheOperationContext.java b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/PinNewBufferCacheOperationContext.java
new file mode 100644
index 0000000..966f948
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/buffercache/context/PinNewBufferCacheOperationContext.java
@@ -0,0 +1,32 @@
+/*
+ * 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.hyracks.storage.common.buffercache.context;
+
+class PinNewBufferCacheOperationContext implements IBufferCacheOperationContext {
+
+ @Override
+ public boolean isNewPage() {
+ return true;
+ }
+
+ @Override
+ public boolean incrementStats() {
+ return true;
+ }
+}
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 8db171a..b76d9c7 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
@@ -18,6 +18,8 @@
*/
package org.apache.hyracks.storage.common.compression.file;
+import static org.apache.hyracks.storage.common.buffercache.context.BufferCacheOperationContextProvider.NO_STATS;
+
import java.nio.ByteBuffer;
import java.util.EnumSet;
@@ -32,10 +34,10 @@
/**
* CompressedFileManager is responsible to manage the Look Aside File (LAF file), which contains
* the compression information. LAF file format is as follow:
- *
+ * <p>
* [<offset0, size0>, <offset1, size1> .... <offsetN, sizeN>]
* Each entry <offsetM, sizeM> is an entry of 16-bytes for page M (8 bytes for offset and 8 for size).
- *
+ * <p>
* The file is responsible to store the beginning and the size of each page after compression.
*/
public class CompressedFileManager {
@@ -92,11 +94,9 @@
* If the file is empty (i.e. the number of pages is zero)
* Then the state will be WRITABLE.
*
- * @return
- * true if the file exists and was closed
- * false otherwise
- * @throws IllegalStateException
- * if the the file is not in CLOSED state
+ * @return true if the file exists and was closed
+ * false otherwise
+ * @throws IllegalStateException if the the file is not in CLOSED state
*/
public boolean open() throws HyracksDataException {
ensureState(CLOSED);
@@ -115,11 +115,9 @@
/**
* Close LAF file
*
- * @return
- * true if the LAF file exists and was OPEN
- * false otherwise
- * @throws IllegalStateException
- * if the the file is not in OPEN state
+ * @return true if the LAF file exists and was OPEN
+ * false otherwise
+ * @throws IllegalStateException if the the file is not in OPEN state
*/
public boolean close() throws HyracksDataException {
ensureState(OPEN_OR_INVALID);
@@ -136,8 +134,7 @@
/**
* Close and purge LAF file
*
- * @throws IllegalStateException
- * if the the file is not in OPEN state
+ * @throws IllegalStateException if the the file is not in OPEN state
*/
public void purge() throws HyracksDataException {
if (close()) {
@@ -148,8 +145,7 @@
/**
* Delete LAF file
*
- * @throws IllegalStateException
- * if the the file is not in CLOSED state
+ * @throws IllegalStateException if the the file is not in CLOSED state
*/
public void delete() throws HyracksDataException {
ensureState(CLOSED_OR_INVALID);
@@ -161,8 +157,7 @@
/**
* Force LAF file content to disk
*
- * @throws IllegalStateException
- * if the the file is not in CLOSED state
+ * @throws IllegalStateException if the the file is not in CLOSED state
*/
public void force(boolean metadata) throws HyracksDataException {
ensureState(OPEN);
@@ -203,15 +198,11 @@
/**
* Add extra page information (offset, size) after compression.
*
- * @param extraPageId
- * extra page ID
- * @param size
- * size of the extra page
- * @param extraPageIndex
- * the index of the extra page (starting from 0)
+ * @param extraPageId extra page ID
+ * @param size size of the extra page
+ * @param extraPageIndex the index of the extra page (starting from 0)
* @return offset for the compressed page.
- * @throws IllegalStateException
- * If the file is not in WRITABLE state
+ * @throws IllegalStateException If the file is not in WRITABLE state
*/
public long writeExtraPageInfo(int extraPageId, long size, int extraPageIndex) throws HyracksDataException {
ensureState(WRITABLE);
@@ -231,10 +222,8 @@
* This methods is used by {@link LAFWriter#endWriting()} to signal the end of writing.
* After calling this methods, LAF file will be READ-ONLY.
*
- * @param totalNumOfPages
- * The total number of pages of the index
- * @throws IllegalStateException
- * If the file is not in WRITABLE state
+ * @param totalNumOfPages The total number of pages of the index
+ * @throws IllegalStateException If the file is not in WRITABLE state
*/
void endWriting(int totalNumOfPages) {
ensureState(WRITABLE);
@@ -316,7 +305,7 @@
final long dpid = getDiskPageId(numOfPages - 1);
//exclude the LAF from the buffer cache pin/read stats, because it is hot in any
//sane scenario. otherwise it inflates the query's cache ratio greatly.
- final ICachedPage page = bufferCache.pin(dpid, false, false);
+ final ICachedPage page = bufferCache.pin(dpid, NO_STATS);
try {
final ByteBuffer buf = page.getBuffer();
@@ -338,7 +327,7 @@
//don't increment the stats with this pin. this is because we are pinning on behalf
//of a caller, so our pins will be an interfering access pattern that conflates itself
//with the caller's cache pattern.
- return bufferCache.pin(getDiskPageId(pageId), false, false);
+ return bufferCache.pin(getDiskPageId(pageId), NO_STATS);
}
private long getDiskPageId(int pageId) {
diff --git a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/org/apache/hyracks/storage/am/btree/FieldPrefixNSMTest.java b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/org/apache/hyracks/storage/am/btree/FieldPrefixNSMTest.java
index e9b9e7f..ddb9d9e 100644
--- a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/org/apache/hyracks/storage/am/btree/FieldPrefixNSMTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/org/apache/hyracks/storage/am/btree/FieldPrefixNSMTest.java
@@ -19,6 +19,8 @@
package org.apache.hyracks.storage.am.btree;
+import static org.apache.hyracks.storage.common.buffercache.context.BufferCacheOperationContextProvider.NEW;
+
import java.io.DataOutput;
import java.util.Random;
@@ -128,7 +130,7 @@
bufferCache.createFile(harness.getFileReference());
int btreeFileId = bufferCache.openFile(harness.getFileReference());
IHyracksTaskContext ctx = harness.getHyracksTaskContext();
- ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(btreeFileId, 0), true);
+ ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(btreeFileId, 0), NEW);
try {
BTreeTypeAwareTupleWriter tupleWriter = new BTreeTypeAwareTupleWriter(typeTraits, false, null, null);
diff --git a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/org/apache/hyracks/storage/am/btree/StorageFileAccessTest.java b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/org/apache/hyracks/storage/am/btree/StorageFileAccessTest.java
index 576c6bb..bdcb206 100644
--- a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/org/apache/hyracks/storage/am/btree/StorageFileAccessTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/org/apache/hyracks/storage/am/btree/StorageFileAccessTest.java
@@ -87,7 +87,7 @@
}
try {
- ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId), false);
+ ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId));
LatchType latch = null;
switch (fta) {
diff --git a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/org/apache/hyracks/storage/am/lsm/btree/impl/TestVirtualBufferCache.java b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/org/apache/hyracks/storage/am/lsm/btree/impl/TestVirtualBufferCache.java
index e697b54..254abb8 100644
--- a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/org/apache/hyracks/storage/am/lsm/btree/impl/TestVirtualBufferCache.java
+++ b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/org/apache/hyracks/storage/am/lsm/btree/impl/TestVirtualBufferCache.java
@@ -18,6 +18,8 @@
*/
package org.apache.hyracks.storage.am.lsm.btree.impl;
+import static org.apache.hyracks.storage.common.buffercache.context.BufferCacheOperationContextProvider.DEFAULT;
+
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
@@ -33,6 +35,7 @@
import org.apache.hyracks.storage.common.buffercache.IFIFOPageWriter;
import org.apache.hyracks.storage.common.buffercache.IPageWriteCallback;
import org.apache.hyracks.storage.common.buffercache.IPageWriteFailureCallback;
+import org.apache.hyracks.storage.common.buffercache.context.IBufferCacheOperationContext;
import org.apache.hyracks.storage.common.file.IFileMapManager;
public class TestVirtualBufferCache implements IVirtualBufferCache {
@@ -89,8 +92,13 @@
}
@Override
- public ICachedPage pin(long dpid, boolean newPage) throws HyracksDataException {
- ICachedPage page = vbc.pin(dpid, newPage);
+ public ICachedPage pin(long dpid) throws HyracksDataException {
+ return pin(dpid, DEFAULT);
+ }
+
+ @Override
+ public ICachedPage pin(long dpid, IBufferCacheOperationContext context) throws HyracksDataException {
+ ICachedPage page = vbc.pin(dpid, context);
// the memory component can be full after each but, but isFull may not be called by the memory component
// for correctness, we call isFull here after each pin
for (ILSMMemoryComponent component : isFullMap.keySet()) {
@@ -101,11 +109,6 @@
}
@Override
- public ICachedPage pin(long dpid, boolean newPage, boolean incrementStats) throws HyracksDataException {
- return pin(dpid, newPage);
- }
-
- @Override
public void unpin(ICachedPage page) throws HyracksDataException {
vbc.unpin(page);
}
diff --git a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/org/apache/hyracks/storage/am/lsm/common/test/VirtualBufferCacheTest.java b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/org/apache/hyracks/storage/am/lsm/common/test/VirtualBufferCacheTest.java
index 0e749fc..f18986b 100644
--- a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/org/apache/hyracks/storage/am/lsm/common/test/VirtualBufferCacheTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/org/apache/hyracks/storage/am/lsm/common/test/VirtualBufferCacheTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.hyracks.storage.am.lsm.common.test;
+import static org.apache.hyracks.storage.common.buffercache.context.BufferCacheOperationContextProvider.NEW;
import static org.junit.Assert.assertTrue;
import java.util.Collections;
@@ -71,7 +72,7 @@
}
public void pin(VirtualBufferCache vbc, int multiplier) throws HyracksDataException {
- ICachedPage p = vbc.pin(BufferedFileHandle.getDiskPageId(fileId, pinCount), true);
+ ICachedPage p = vbc.pin(BufferedFileHandle.getDiskPageId(fileId, pinCount), NEW);
pinnedPages.add(p);
pinCount++;
totalNumPages++;
@@ -148,7 +149,7 @@
switch (req.getType()) {
case PIN_PAGE:
ICachedPage p = vbc.pin(
- BufferedFileHandle.getDiskPageId(fileState.fileId, fileState.helper.pinCount), true);
+ BufferedFileHandle.getDiskPageId(fileState.fileId, fileState.helper.pinCount), NEW);
fileState.helper.pinnedPages.add(p);
++fileState.helper.pinCount;
break;
diff --git a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheRegressionTest.java b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheRegressionTest.java
index 3a857cc..9fe6b59 100644
--- a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheRegressionTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheRegressionTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.hyracks.storage.common;
+import static org.apache.hyracks.storage.common.buffercache.context.BufferCacheOperationContextProvider.NEW;
import static org.junit.Assert.fail;
import java.io.File;
@@ -95,7 +96,7 @@
// Fill the first page with known data and make it dirty by write
// latching it.
- ICachedPage writePage = bufferCache.pin(BufferedFileHandle.getDiskPageId(firstFileId, 0), true);
+ ICachedPage writePage = bufferCache.pin(BufferedFileHandle.getDiskPageId(firstFileId, 0), NEW);
writePage.acquireWriteLatch();
try {
ByteBuffer buf = writePage.getBuffer();
diff --git a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheTest.java b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheTest.java
index 6ed4a09..2b221da 100644
--- a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheTest.java
@@ -18,6 +18,8 @@
*/
package org.apache.hyracks.storage.common;
+import static org.apache.hyracks.storage.common.buffercache.context.BufferCacheOperationContextProvider.NEW;
+
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -126,7 +128,7 @@
pageNumber = (pageNumber + 1) % numPages;
try {
long dpid = BufferedFileHandle.getDiskPageId(fileId, pageNumber);
- ICachedPage page = bufferCache.pin(dpid, false);
+ ICachedPage page = bufferCache.pin(dpid);
successfulReads++;
bufferCache.unpin(page);
} catch (HyracksDataException hde) {
@@ -186,7 +188,7 @@
ICachedPage page = null;
// pin page should succeed
- page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId), true);
+ page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId), NEW);
page.acquireWriteLatch();
try {
for (int i = 0; i < num; i++) {
@@ -203,7 +205,7 @@
bufferCache.openFile(fileId);
// tryPin should succeed because page should still be cached
- page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId), false);
+ page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId));
Assert.assertNotNull(page);
page.acquireReadLatch();
try {
@@ -298,7 +300,7 @@
fileIds.add(fileId);
ICachedPage page = null;
- page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId), true);
+ page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId), NEW);
page.acquireWriteLatch();
try {
ArrayList<Integer> values = new ArrayList<>();
@@ -373,7 +375,7 @@
// pin first page and verify contents
ICachedPage page = null;
- page = bufferCache.pin(BufferedFileHandle.getDiskPageId(closedFileId, testPageId), false);
+ page = bufferCache.pin(BufferedFileHandle.getDiskPageId(closedFileId, testPageId));
page.acquireReadLatch();
try {
ArrayList<Integer> values = pageContents.get(closedFileId);
@@ -411,7 +413,7 @@
Thread interruptedReader = null;
try {
for (int i = 0; i < expectedPinCount; i++) {
- ICachedPage aPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId), false);
+ ICachedPage aPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId));
bufferCache.unpin(aPage);
((CachedPage) aPage).invalidate();
actualPinCount.incrementAndGet();
@@ -420,7 +422,7 @@
interruptedReader = new Thread(() -> {
try {
Thread.currentThread().interrupt();
- bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId + 1), false);
+ bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId + 1));
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheWithCompressionTest.java b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheWithCompressionTest.java
index 963b1d8..e401393 100644
--- a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheWithCompressionTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheWithCompressionTest.java
@@ -137,7 +137,7 @@
pageNumber = (pageNumber + 1) % numPages;
try {
long dpid = BufferedFileHandle.getDiskPageId(fileId, pageNumber);
- ICachedPage page = bufferCache.pin(dpid, false);
+ ICachedPage page = bufferCache.pin(dpid);
successfulReads++;
bufferCache.unpin(page);
} catch (HyracksDataException hde) {
@@ -216,7 +216,7 @@
bufferCache.openFile(fileId);
// tryPin should succeed because page should still be cached
- page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId), false);
+ page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId));
Assert.assertNotNull(page);
try {
// verify contents of page
@@ -323,7 +323,7 @@
// pin first page and verify contents
ICachedPage page = null;
- page = bufferCache.pin(BufferedFileHandle.getDiskPageId(closedFileId, testPageId), false);
+ page = bufferCache.pin(BufferedFileHandle.getDiskPageId(closedFileId, testPageId));
try {
ArrayList<Integer> values = pageContents.get(closedFileId);
for (int j = 0; j < values.size(); j++) {
@@ -359,7 +359,7 @@
Thread interruptedReader = null;
try {
for (int i = 0; i < expectedPinCount; i++) {
- ICachedPage aPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId), false);
+ ICachedPage aPage = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId));
bufferCache.unpin(aPage);
((CachedPage) aPage).invalidate();
actualPinCount.incrementAndGet();
@@ -368,7 +368,7 @@
interruptedReader = new Thread(() -> {
try {
Thread.currentThread().interrupt();
- bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId + 1), false);
+ bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId + 1));
} catch (Exception e) {
e.printStackTrace();
}
--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18171
To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: I4472b34926845b1c78a6582dfe8bafd4dc8a3e7a
Gerrit-Change-Number: 18171
Gerrit-PatchSet: 1
Gerrit-Owner: Wail Alkowaileet <wa...@gmail.com>
Gerrit-MessageType: newchange