Search in sources :

Example 1 with IndexLogKey

use of org.sirix.cache.IndexLogKey in project sirix by sirixdb.

the class PageReadTrxImpl method getRecord.

@Override
public Optional<Record> getRecord(final long nodeKey, final PageKind pageKind, @Nonnegative final int index) {
    checkNotNull(pageKind);
    assertNotClosed();
    if (nodeKey == Fixed.NULL_NODE_KEY.getStandardProperty()) {
        return Optional.empty();
    }
    final long recordPageKey = pageKey(nodeKey);
    final PageContainer cont;
    try {
        switch(pageKind) {
            case RECORDPAGE:
            case PATHSUMMARYPAGE:
            case PATHPAGE:
            case CASPAGE:
            case NAMEPAGE:
                cont = mNodeCache.get(new IndexLogKey(pageKind, recordPageKey, index));
                break;
            default:
                throw new IllegalStateException();
        }
    } catch (final ExecutionException | UncheckedExecutionException e) {
        throw new SirixIOException(e.getCause());
    }
    if (PageContainer.emptyInstance().equals(cont)) {
        return Optional.empty();
    }
    final Record retVal = ((UnorderedKeyValuePage) cont.getComplete()).getValue(nodeKey);
    return checkItemIfDeleted(retVal);
}
Also used : PageContainer(org.sirix.cache.PageContainer) IndexLogKey(org.sirix.cache.IndexLogKey) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) Record(org.sirix.node.interfaces.Record) UnorderedKeyValuePage(org.sirix.page.UnorderedKeyValuePage) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) SirixIOException(org.sirix.exception.SirixIOException)

Aggregations

UncheckedExecutionException (com.google.common.util.concurrent.UncheckedExecutionException)1 ExecutionException (java.util.concurrent.ExecutionException)1 IndexLogKey (org.sirix.cache.IndexLogKey)1 PageContainer (org.sirix.cache.PageContainer)1 SirixIOException (org.sirix.exception.SirixIOException)1 Record (org.sirix.node.interfaces.Record)1 UnorderedKeyValuePage (org.sirix.page.UnorderedKeyValuePage)1