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);
}
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;
}
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;
}
Aggregations