io.sirix.index.path.PathIndex Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sirix-core Show documentation
Show all versions of sirix-core Show documentation
SirixDB is a hybrid on-disk and in-memory document oriented, versioned database system. It has a lightweight buffer manager, stores everything in a huge persistent and durable tree and allows efficient reconstruction of every revision. Furthermore, SirixDB implements change tracking, diffing and supports time travel queries.
package io.sirix.index.path;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterators;
import io.sirix.index.*;
import io.sirix.index.redblacktree.RBNodeKey;
import io.sirix.api.PageReadOnlyTrx;
import io.sirix.api.PageTrx;
import io.sirix.index.path.summary.PathSummaryReader;
import io.sirix.index.redblacktree.RBTreeReader;
import io.sirix.index.redblacktree.keyvalue.NodeReferences;
import io.sirix.settings.Fixed;
import java.util.Iterator;
import java.util.Optional;
import java.util.Set;
public interface PathIndex {
B createBuilder(PageTrx pageTrx, PathSummaryReader pathSummaryReader, IndexDef indexDef);
L createListener(PageTrx pageTrx, PathSummaryReader pathSummaryReader, IndexDef indexDef);
default Iterator openIndex(final PageReadOnlyTrx pageRtx, final IndexDef indexDef,
final PathFilter filter) {
final RBTreeReader reader =
RBTreeReader.getInstance(pageRtx.getResourceSession().getIndexCache(),
pageRtx,
indexDef.getType(),
indexDef.getID());
if (filter != null && filter.getPCRs().size() == 1) {
final Optional optionalNodeReferences =
reader.get(filter.getPCRs().iterator().next(), SearchMode.EQUAL);
return Iterators.forArray(optionalNodeReferences.orElse(new NodeReferences()));
} else {
final Iterator> iter =
reader.new RBNodeIterator(Fixed.DOCUMENT_NODE_KEY.getStandardProperty());
final Set setFilter = filter == null ? ImmutableSet.of() : ImmutableSet.of(filter);
return new IndexFilterAxis<>(reader, iter, setFilter);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy