use of org.apache.hyracks.storage.am.common.api.ITreeIndexMetadataFrame in project asterixdb by apache.
the class AbstractLSMIndexFileManager method isValidTreeIndex.
protected TreeIndexState isValidTreeIndex(ITreeIndex treeIndex) throws HyracksDataException {
IBufferCache bufferCache = treeIndex.getBufferCache();
treeIndex.activate();
try {
int metadataPage = treeIndex.getPageManager().getMetadataPageId();
if (metadataPage < 0) {
return TreeIndexState.INVALID;
}
ITreeIndexMetadataFrame metadataFrame = treeIndex.getPageManager().createMetadataFrame();
ICachedPage page = bufferCache.pin(BufferedFileHandle.getDiskPageId(treeIndex.getFileId(), metadataPage), false);
page.acquireReadLatch();
try {
metadataFrame.setPage(page);
if (!metadataFrame.isValid()) {
return TreeIndexState.INVALID;
} else if (metadataFrame.getVersion() != ITreeIndexFrame.Constants.VERSION) {
return TreeIndexState.VERSION_MISMATCH;
} else {
return TreeIndexState.VALID;
}
} finally {
page.releaseReadLatch();
bufferCache.unpin(page);
}
} finally {
treeIndex.deactivate();
}
}
use of org.apache.hyracks.storage.am.common.api.ITreeIndexMetadataFrame in project asterixdb by apache.
the class AppendOnlyLinkedMetadataPageManager method close.
@Override
public void close() throws HyracksDataException {
if (ready) {
IFIFOPageQueue queue = bufferCache.createFIFOQueue();
ITreeIndexMetadataFrame metaFrame = frameFactory.createFrame();
confiscatedPage.acquireWriteLatch();
try {
metaFrame.setPage(confiscatedPage);
metaFrame.setValid(true);
} finally {
confiscatedPage.releaseWriteLatch(false);
}
int finalMetaPage = getMaxPageId(metaFrame) + 1;
bufferCache.setPageDiskId(confiscatedPage, BufferedFileHandle.getDiskPageId(fileId, finalMetaPage));
queue.put(confiscatedPage);
bufferCache.finishQueue();
metadataPage = getMetadataPageId();
ready = false;
} else if (confiscatedPage != null) {
bufferCache.returnPage(confiscatedPage, false);
}
confiscatedPage = null;
}
use of org.apache.hyracks.storage.am.common.api.ITreeIndexMetadataFrame in project asterixdb by apache.
the class AppendOnlyLinkedMetadataPageManager method open.
@Override
public void open(int fileId) throws HyracksDataException {
this.fileId = fileId;
// get the number of pages of the file
int pages = bufferCache.getNumPagesOfFile(fileId);
//if there are no pages in the file yet, we're just initializing
if (pages == 0) {
if (confiscatedPage != null) {
throw new HyracksDataException("Metadata Page Manager is already initialized");
}
ITreeIndexMetadataFrame metaFrame = createMetadataFrame();
ICachedPage metaNode = bufferCache.confiscatePage(BufferCache.INVALID_DPID);
try {
metaFrame.setPage(metaNode);
metaFrame.init();
metaFrame.setMaxPage(-1);
} finally {
confiscatedPage = metaNode;
}
}
}
use of org.apache.hyracks.storage.am.common.api.ITreeIndexMetadataFrame in project asterixdb by apache.
the class LinkedMetaDataPageManager method getRootPageId.
@Override
public int getRootPageId() throws HyracksDataException {
ICachedPage metaNode;
metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()), false);
ITreeIndexMetadataFrame metaFrame = frameFactory.createFrame();
metaNode.acquireReadLatch();
try {
metaFrame.setPage(metaNode);
return metaFrame.getRootPageId();
} finally {
metaNode.releaseReadLatch();
bufferCache.unpin(metaNode);
}
}
use of org.apache.hyracks.storage.am.common.api.ITreeIndexMetadataFrame in project asterixdb by apache.
the class LinkedMetaDataPageManager method close.
@Override
public void close() throws HyracksDataException {
if (ready) {
ICachedPage metaNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, getMetadataPageId()), false);
ITreeIndexMetadataFrame metaFrame = frameFactory.createFrame();
metaNode.acquireWriteLatch();
try {
metaFrame.setPage(metaNode);
metaFrame.setValid(true);
} finally {
metaNode.releaseWriteLatch(true);
bufferCache.flushDirtyPage(metaNode);
bufferCache.unpin(metaNode);
ready = true;
}
ready = false;
}
}
Aggregations