Search in sources :

Example 1 with ITreeIndexMetadataFrame

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();
    }
}
Also used : ICachedPage(org.apache.hyracks.storage.common.buffercache.ICachedPage) ITreeIndexMetadataFrame(org.apache.hyracks.storage.am.common.api.ITreeIndexMetadataFrame) IBufferCache(org.apache.hyracks.storage.common.buffercache.IBufferCache)

Example 2 with ITreeIndexMetadataFrame

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;
}
Also used : IFIFOPageQueue(org.apache.hyracks.storage.common.buffercache.IFIFOPageQueue) ITreeIndexMetadataFrame(org.apache.hyracks.storage.am.common.api.ITreeIndexMetadataFrame)

Example 3 with ITreeIndexMetadataFrame

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;
        }
    }
}
Also used : ICachedPage(org.apache.hyracks.storage.common.buffercache.ICachedPage) ITreeIndexMetadataFrame(org.apache.hyracks.storage.am.common.api.ITreeIndexMetadataFrame) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 4 with ITreeIndexMetadataFrame

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);
    }
}
Also used : ICachedPage(org.apache.hyracks.storage.common.buffercache.ICachedPage) ITreeIndexMetadataFrame(org.apache.hyracks.storage.am.common.api.ITreeIndexMetadataFrame)

Example 5 with ITreeIndexMetadataFrame

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;
    }
}
Also used : ICachedPage(org.apache.hyracks.storage.common.buffercache.ICachedPage) ITreeIndexMetadataFrame(org.apache.hyracks.storage.am.common.api.ITreeIndexMetadataFrame)

Aggregations

ITreeIndexMetadataFrame (org.apache.hyracks.storage.am.common.api.ITreeIndexMetadataFrame)10 ICachedPage (org.apache.hyracks.storage.common.buffercache.ICachedPage)7 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)3 IBufferCache (org.apache.hyracks.storage.common.buffercache.IBufferCache)2 DataOutput (java.io.DataOutput)1 Random (java.util.Random)1 IFrame (org.apache.hyracks.api.comm.IFrame)1 IFrameTupleAccessor (org.apache.hyracks.api.comm.IFrameTupleAccessor)1 VSizeFrame (org.apache.hyracks.api.comm.VSizeFrame)1 IBinaryComparatorFactory (org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory)1 ISerializerDeserializer (org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)1 ITypeTraits (org.apache.hyracks.api.dataflow.value.ITypeTraits)1 RecordDescriptor (org.apache.hyracks.api.dataflow.value.RecordDescriptor)1 ArrayTupleBuilder (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder)1 FrameTupleAccessor (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor)1 FrameTupleAppender (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender)1 FrameTupleReference (org.apache.hyracks.dataflow.common.data.accessors.FrameTupleReference)1 IBTreeInteriorFrame (org.apache.hyracks.storage.am.btree.api.IBTreeInteriorFrame)1 IBTreeLeafFrame (org.apache.hyracks.storage.am.btree.api.IBTreeLeafFrame)1 BTreeNSMInteriorFrameFactory (org.apache.hyracks.storage.am.btree.frames.BTreeNSMInteriorFrameFactory)1