Search in sources :

Example 11 with NodeId

use of org.apache.jena.tdb2.store.NodeId in project jena by apache.

the class LoaderOps method copyIndex.

/**
 * Copy a stream to several indexes (sequential version)
 */
public static void copyIndex(Iterator<Tuple<NodeId>> srcIter, TupleIndex[] destIndexes, ProgressMonitor monitor) {
    long counter = 0;
    for (; srcIter.hasNext(); ) {
        counter++;
        Tuple<NodeId> tuple = srcIter.next();
        monitor.tick();
        for (TupleIndex destIdx : destIndexes) {
            if (destIdx != null)
                destIdx.add(tuple);
        }
    }
}
Also used : NodeId(org.apache.jena.tdb2.store.NodeId) TupleIndex(org.apache.jena.tdb2.store.tupletable.TupleIndex)

Example 12 with NodeId

use of org.apache.jena.tdb2.store.NodeId in project jena by apache.

the class DataToTuplesInline method nodes.

private static Tuple<NodeId> nodes(NodeTable nt, Triple triple) {
    NodeId s = idForNode(nt, triple.getSubject());
    NodeId p = idForNode(nt, triple.getPredicate());
    NodeId o = idForNode(nt, triple.getObject());
    return TupleFactory.tuple(s, p, o);
}
Also used : NodeId(org.apache.jena.tdb2.store.NodeId)

Example 13 with NodeId

use of org.apache.jena.tdb2.store.NodeId in project jena by apache.

the class Indexer method startBulk.

/**
 * Start the threads that will do the indexing
 */
@Override
public void startBulk() {
    for (int i = 0; i < N; i++) {
        TupleIndex idx = indexes[i];
        BlockingQueue<List<Tuple<NodeId>>> pipe = pipesTripleIndexers[i];
        new Thread(() -> stageIndex(pipe, idx)).start();
    }
}
Also used : NodeId(org.apache.jena.tdb2.store.NodeId) List(java.util.List) TupleIndex(org.apache.jena.tdb2.store.tupletable.TupleIndex)

Example 14 with NodeId

use of org.apache.jena.tdb2.store.NodeId 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.tdb2.store.NodeId) NodeTable(org.apache.jena.tdb2.store.nodetable.NodeTable)

Example 15 with NodeId

use of org.apache.jena.tdb2.store.NodeId in project jena by apache.

the class SolverLibTDB method graphNames.

/**
 * Find all the graph names in the quads table.
 */
static QueryIterator graphNames(DatasetGraphTDB ds, Node graphNode, QueryIterator input, Predicate<Tuple<NodeId>> filter, ExecutionContext execCxt) {
    List<Abortable> killList = new ArrayList<>();
    Iterator<Tuple<NodeId>> iter1 = ds.getQuadTable().getNodeTupleTable().find(NodeId.NodeIdAny, NodeId.NodeIdAny, NodeId.NodeIdAny, NodeId.NodeIdAny);
    if (filter != null)
        iter1 = Iter.filter(iter1, filter);
    Iterator<NodeId> iter2 = Iter.map(iter1, t -> t.get(0));
    // Project is cheap - don't brother wrapping iter1
    iter2 = makeAbortable(iter2, killList);
    Iterator<NodeId> iter3 = Iter.distinct(iter2);
    iter3 = makeAbortable(iter3, killList);
    Iterator<Node> iter4 = NodeLib.nodes(ds.getQuadTable().getNodeTupleTable().getNodeTable(), iter3);
    final Var var = Var.alloc(graphNode);
    Iterator<Binding> iterBinding = Iter.map(iter4, node -> BindingFactory.binding(var, node));
    return new QueryIterAbortable(iterBinding, killList, input, execCxt);
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) QueryIterAbortable(org.apache.jena.sparql.engine.iterator.QueryIterAbortable) Var(org.apache.jena.sparql.core.Var) Node(org.apache.jena.graph.Node) QueryIterAbortable(org.apache.jena.sparql.engine.iterator.QueryIterAbortable) SolverLib.makeAbortable(org.apache.jena.sparql.engine.main.solver.SolverLib.makeAbortable) Abortable(org.apache.jena.sparql.engine.iterator.Abortable) NodeId(org.apache.jena.tdb2.store.NodeId) Tuple(org.apache.jena.atlas.lib.tuple.Tuple)

Aggregations

NodeId (org.apache.jena.tdb2.store.NodeId)47 Node (org.apache.jena.graph.Node)24 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)16 TDBException (org.apache.jena.tdb2.TDBException)12 NodeTable (org.apache.jena.tdb2.store.nodetable.NodeTable)11 Quad (org.apache.jena.sparql.core.Quad)7 ArrayList (java.util.ArrayList)6 Var (org.apache.jena.sparql.core.Var)6 Triple (org.apache.jena.graph.Triple)5 NodeTupleTable (org.apache.jena.tdb2.store.nodetupletable.NodeTupleTable)5 Iterator (java.util.Iterator)4 Binding (org.apache.jena.sparql.engine.binding.Binding)4 StatsCollectorNodeId (org.apache.jena.tdb2.solver.stats.StatsCollectorNodeId)4 Predicate (java.util.function.Predicate)3 Iter (org.apache.jena.atlas.iterator.Iter)3 Record (org.apache.jena.dboe.base.record.Record)3 TupleIndex (org.apache.jena.tdb2.store.tupletable.TupleIndex)3 Test (org.junit.Test)3 List (java.util.List)2 Function (java.util.function.Function)2