Search in sources :

Example 1 with KeyValuePage

use of org.sirix.page.interfaces.KeyValuePage in project sirix by sirixdb.

the class PersistentFileCache method get.

@Override
public PageContainer get(PageReference reference) {
    if (reference.getPersistentLogKey() < 0)
        return PageContainer.emptyInstance();
    final Page modifiedPage = mWriter.read(reference, mPageReadTrx);
    final Page completePage;
    if (modifiedPage instanceof KeyValuePage) {
        final long peristKey = reference.getPersistentLogKey();
        reference.setPersistentLogKey(peristKey + reference.getLength());
        completePage = mWriter.read(reference, mPageReadTrx);
        reference.setPersistentLogKey(peristKey);
    } else {
        completePage = modifiedPage;
    }
    return new PageContainer(completePage, modifiedPage);
}
Also used : KeyValuePage(org.sirix.page.interfaces.KeyValuePage) KeyValuePage(org.sirix.page.interfaces.KeyValuePage) Page(org.sirix.page.interfaces.Page)

Example 2 with KeyValuePage

use of org.sirix.page.interfaces.KeyValuePage in project sirix by sirixdb.

the class PageReadTrxImpl method getRecordPageContainer.

@Override
public <K extends Comparable<? super K>, V extends Record, T extends KeyValuePage<K, V>> PageContainer getRecordPageContainer(@Nonnegative final Long recordPageKey, final int index, final PageKind pageKind) throws SirixIOException {
    assertNotClosed();
    checkArgument(recordPageKey >= 0, "recordPageKey must not be negative!");
    final Optional<PageReference> pageReferenceToRecordPage = getLeafPageReference(checkNotNull(recordPageKey), index, checkNotNull(pageKind));
    if (!pageReferenceToRecordPage.isPresent()) {
        return PageContainer.emptyInstance();
    }
    // Try to get from resource buffer manager.
    final PageContainer recordPageContainerFromBuffer = mResourceBufferManager.getRecordPageCache().get(pageReferenceToRecordPage.get());
    if (recordPageContainerFromBuffer != null) {
        return recordPageContainerFromBuffer;
    }
    // Load list of page "fragments" from persistent storage.
    final List<T> pages = getSnapshotPages(pageReferenceToRecordPage.get());
    if (pages.isEmpty()) {
        return PageContainer.emptyInstance();
    }
    final int mileStoneRevision = mResourceConfig.mRevisionsToRestore;
    final Versioning revisioning = mResourceConfig.mRevisionKind;
    final Page completePage = revisioning.combineRecordPages(pages, mileStoneRevision, this);
    final PageContainer recordPageContainer = new PageContainer(completePage, clone(completePage));
    if (mTrxIntentLog == null)
        mResourceBufferManager.getRecordPageCache().put(pageReferenceToRecordPage.get(), recordPageContainer);
    return recordPageContainer;
}
Also used : PageReference(org.sirix.page.PageReference) PageContainer(org.sirix.cache.PageContainer) Versioning(org.sirix.settings.Versioning) KeyValuePage(org.sirix.page.interfaces.KeyValuePage) UnorderedKeyValuePage(org.sirix.page.UnorderedKeyValuePage) CASPage(org.sirix.page.CASPage) Page(org.sirix.page.interfaces.Page) RevisionRootPage(org.sirix.page.RevisionRootPage) NamePage(org.sirix.page.NamePage) PathSummaryPage(org.sirix.page.PathSummaryPage) UberPage(org.sirix.page.UberPage) PathPage(org.sirix.page.PathPage) IndirectPage(org.sirix.page.IndirectPage)

Example 3 with KeyValuePage

use of org.sirix.page.interfaces.KeyValuePage in project sirix by sirixdb.

the class PageWriteTrxImpl method createEntry.

@Override
public Record createEntry(final Long key, final Record record, final PageKind pageKind, final int index, final Optional<UnorderedKeyValuePage> keyValuePage) throws SirixIOException {
    mPageRtx.assertNotClosed();
    // Allocate record key and increment record count.
    long recordKey;
    switch(pageKind) {
        case RECORDPAGE:
            recordKey = mNewRoot.incrementAndGetMaxNodeKey();
            break;
        case PATHSUMMARYPAGE:
            final PathSummaryPage pathSummaryPage = ((PathSummaryPage) mNewRoot.getPathSummaryPageReference().getPage());
            recordKey = pathSummaryPage.incrementAndGetMaxNodeKey(index);
            break;
        case CASPAGE:
            final CASPage casPage = ((CASPage) mNewRoot.getCASPageReference().getPage());
            recordKey = casPage.incrementAndGetMaxNodeKey(index);
            break;
        case PATHPAGE:
            final PathPage pathPage = ((PathPage) mNewRoot.getPathPageReference().getPage());
            recordKey = pathPage.incrementAndGetMaxNodeKey(index);
            break;
        case NAMEPAGE:
            final NamePage namePage = ((NamePage) mNewRoot.getNamePageReference().getPage());
            recordKey = namePage.incrementAndGetMaxNodeKey(index);
            break;
        default:
            throw new IllegalStateException();
    }
    final long recordPageKey = mPageRtx.pageKey(recordKey);
    final PageContainer cont = prepareRecordPage(recordPageKey, index, pageKind);
    @SuppressWarnings("unchecked") final KeyValuePage<Long, Record> modified = (KeyValuePage<Long, Record>) cont.getModified();
    modified.setEntry(record.getNodeKey(), record);
    return record;
}
Also used : PageContainer(org.sirix.cache.PageContainer) PathSummaryPage(org.sirix.page.PathSummaryPage) CASPage(org.sirix.page.CASPage) NamePage(org.sirix.page.NamePage) PathPage(org.sirix.page.PathPage) KeyValuePage(org.sirix.page.interfaces.KeyValuePage) UnorderedKeyValuePage(org.sirix.page.UnorderedKeyValuePage) Record(org.sirix.node.interfaces.Record)

Aggregations

KeyValuePage (org.sirix.page.interfaces.KeyValuePage)3 PageContainer (org.sirix.cache.PageContainer)2 CASPage (org.sirix.page.CASPage)2 NamePage (org.sirix.page.NamePage)2 PathPage (org.sirix.page.PathPage)2 PathSummaryPage (org.sirix.page.PathSummaryPage)2 UnorderedKeyValuePage (org.sirix.page.UnorderedKeyValuePage)2 Page (org.sirix.page.interfaces.Page)2 Record (org.sirix.node.interfaces.Record)1 IndirectPage (org.sirix.page.IndirectPage)1 PageReference (org.sirix.page.PageReference)1 RevisionRootPage (org.sirix.page.RevisionRootPage)1 UberPage (org.sirix.page.UberPage)1 Versioning (org.sirix.settings.Versioning)1