Search in sources :

Example 21 with NodeTable

use of org.apache.jena.tdb.store.nodetable.NodeTable in project jena by apache.

the class TDBInternal method getNodeId.

/**
 * Return the NodeId for a node. Returns NodeId.NodeDoesNotExist when the
 * node is not found. Returns null when not a TDB-backed dataset.
 */
public static NodeId getNodeId(DatasetGraphTDB dsg, Node node) {
    if (dsg == null)
        return null;
    NodeTable nodeTable = dsg.getQuadTable().getNodeTupleTable().getNodeTable();
    NodeId nodeId = nodeTable.getNodeIdForNode(node);
    return nodeId;
}
Also used : NodeId(org.apache.jena.tdb.store.NodeId) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable)

Example 22 with NodeTable

use of org.apache.jena.tdb.store.nodetable.NodeTable in project jena by apache.

the class SolverLibTDB method convertToNodeIds.

static Set<NodeId> convertToNodeIds(Collection<Node> nodes, DatasetGraphTDB dataset) {
    Set<NodeId> graphIds = new HashSet<>();
    NodeTable nt = dataset.getQuadTable().getNodeTupleTable().getNodeTable();
    for (Node n : nodes) graphIds.add(nt.getNodeIdForNode(n));
    return graphIds;
}
Also used : Node(org.apache.jena.graph.Node) NodeId(org.apache.jena.tdb.store.NodeId) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable)

Example 23 with NodeTable

use of org.apache.jena.tdb.store.nodetable.NodeTable in project jena by apache.

the class DatasetBuilderStd method buildNodeTable.

// -------------
private NodeTable buildNodeTable(FileSet fsIndex, FileSet fsObjectFile, StoreParams params) {
    RecordFactory recordFactory = new RecordFactory(SystemTDB.LenNodeHash, SystemTDB.SizeOfNodeId);
    Index idx = /*indexBuilder.*/
    buildIndex(fsIndex, recordFactory, params);
    ObjectFile objectFile = objectFileBuilder.buildObjectFile(fsObjectFile, Names.extNodeData);
    NodeTable nodeTable = new NodeTableNative(idx, objectFile);
    nodeTable = NodeTableCache.create(nodeTable, params.getNode2NodeIdCacheSize(), params.getNodeId2NodeCacheSize(), params.getNodeMissCacheSize());
    nodeTable = NodeTableInline.create(nodeTable);
    return nodeTable;
}
Also used : RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) NodeTableNative(org.apache.jena.tdb.store.nodetable.NodeTableNative) ObjectFile(org.apache.jena.tdb.base.objectfile.ObjectFile) BuilderStdIndex(org.apache.jena.tdb.index.BuilderStdIndex) RangeIndex(org.apache.jena.tdb.index.RangeIndex) Index(org.apache.jena.tdb.index.Index) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable)

Example 24 with NodeTable

use of org.apache.jena.tdb.store.nodetable.NodeTable in project jena by apache.

the class DatasetBuilderStd method makePrefixTable.

protected DatasetPrefixesTDB makePrefixTable(Location location, DatasetControl policy, StoreParams params) {
    String primary = params.getPrimaryIndexPrefix();
    String[] indexes = params.getPrefixIndexes();
    TupleIndex[] prefixIndexes = makeTupleIndexes(location, primary, indexes, new String[] { params.getIndexPrefix() }, params);
    if (prefixIndexes.length != 1)
        error(log, "Wrong number of prefix table tuples indexes: " + prefixIndexes.length);
    String pnNode2Id = params.getPrefixNode2Id();
    String pnId2Node = params.getPrefixId2Node();
    // No cache - the prefix mapping is a cache
    NodeTable prefixNodes = makeNodeTableNoCache(location, pnNode2Id, pnId2Node, params);
    NodeTupleTable prefixTable = new NodeTupleTableConcrete(primary.length(), prefixIndexes, prefixNodes, policy);
    DatasetPrefixesTDB prefixes = new DatasetPrefixesTDB(prefixTable);
    return prefixes;
}
Also used : NodeTupleTable(org.apache.jena.tdb.store.nodetupletable.NodeTupleTable) NodeTupleTableConcrete(org.apache.jena.tdb.store.nodetupletable.NodeTupleTableConcrete) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable)

Example 25 with NodeTable

use of org.apache.jena.tdb.store.nodetable.NodeTable in project jena by apache.

the class SolverRX method matchQuadPattern.

// Entry point from SolverLib.
/*package*/
static Iterator<BindingNodeId> matchQuadPattern(Iterator<BindingNodeId> chain, Node graphNode, Triple tPattern, NodeTupleTable nodeTupleTable, Tuple<Node> patternTuple, boolean anyGraph, Predicate<Tuple<NodeId>> filter, ExecutionContext execCxt) {
    if (DATAPATH) {
        if (!tripleHasEmbTripleWithVars(tPattern))
            // No RDF-star <<>> with variables.
            return StageMatchTuple.access(nodeTupleTable, chain, patternTuple, filter, anyGraph, execCxt);
    }
    // RDF-star <<>> with variables.
    // This path should work regardless.
    boolean isTriple = (patternTuple.len() == 3);
    NodeTable nodeTable = nodeTupleTable.getNodeTable();
    Function<BindingNodeId, Iterator<BindingNodeId>> step = bnid -> find(bnid, nodeTupleTable, graphNode, tPattern, anyGraph, filter, execCxt);
    return Iter.flatMap(chain, step);
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) Iterator(java.util.Iterator) Predicate(java.util.function.Predicate) TupleLib(org.apache.jena.tdb.lib.TupleLib) SolverLib.nodeTopLevel(org.apache.jena.sparql.engine.main.solver.SolverLib.nodeTopLevel) Triple(org.apache.jena.graph.Triple) SolverLibTDB.convFromBinding(org.apache.jena.tdb.solver.SolverLibTDB.convFromBinding) SolverLib.tripleHasEmbTripleWithVars(org.apache.jena.sparql.engine.main.solver.SolverLib.tripleHasEmbTripleWithVars) Function(java.util.function.Function) NodeTupleTable(org.apache.jena.tdb.store.nodetupletable.NodeTupleTable) NodeId(org.apache.jena.tdb.store.NodeId) SolverRX4(org.apache.jena.sparql.engine.main.solver.SolverRX4) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable) Substitute(org.apache.jena.sparql.core.Substitute) Node(org.apache.jena.graph.Node) Quad(org.apache.jena.sparql.core.Quad) TupleFactory(org.apache.jena.atlas.lib.tuple.TupleFactory) Iter(org.apache.jena.atlas.iterator.Iter) InternalErrorException(org.apache.jena.atlas.lib.InternalErrorException) Tuple(org.apache.jena.atlas.lib.tuple.Tuple) ExecutionContext(org.apache.jena.sparql.engine.ExecutionContext) BindingFactory(org.apache.jena.sparql.engine.binding.BindingFactory) Iterator(java.util.Iterator) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable)

Aggregations

NodeTable (org.apache.jena.tdb.store.nodetable.NodeTable)27 NodeId (org.apache.jena.tdb.store.NodeId)12 Node (org.apache.jena.graph.Node)8 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)5 NodeTupleTable (org.apache.jena.tdb.store.nodetupletable.NodeTupleTable)5 Triple (org.apache.jena.graph.Triple)4 Quad (org.apache.jena.sparql.core.Quad)4 Binding (org.apache.jena.sparql.engine.binding.Binding)4 Predicate (java.util.function.Predicate)3 BaseTest (org.apache.jena.atlas.junit.BaseTest)3 TDBException (org.apache.jena.tdb.TDBException)3 DatasetGraphTDB (org.apache.jena.tdb.store.DatasetGraphTDB)3 NodeTableTrans (org.apache.jena.tdb.transaction.NodeTableTrans)3 Transaction (org.apache.jena.tdb.transaction.Transaction)3 Test (org.junit.Test)3 Iterator (java.util.Iterator)2 Function (java.util.function.Function)2 Iter (org.apache.jena.atlas.iterator.Iter)2 InternalErrorException (org.apache.jena.atlas.lib.InternalErrorException)2 TupleFactory (org.apache.jena.atlas.lib.tuple.TupleFactory)2