Search in sources :

Example 1 with CASPage

use of org.sirix.page.CASPage 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

PageContainer (org.sirix.cache.PageContainer)1 Record (org.sirix.node.interfaces.Record)1 CASPage (org.sirix.page.CASPage)1 NamePage (org.sirix.page.NamePage)1 PathPage (org.sirix.page.PathPage)1 PathSummaryPage (org.sirix.page.PathSummaryPage)1 UnorderedKeyValuePage (org.sirix.page.UnorderedKeyValuePage)1 KeyValuePage (org.sirix.page.interfaces.KeyValuePage)1