Search in sources :

Example 6 with NodeTable

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

the class DataToTuples method action.

// Triples.
private void action() {
    coordinator = CoLib.newCoordinator();
    CoLib.add(coordinator, nodeTable);
    CoLib.start(coordinator);
    transaction = coordinator.begin(TxnType.WRITE);
    try {
        for (; ; ) {
            DataBlock data = input.take();
            if (data == DataBlock.END)
                break;
            if (data.triples != null) {
                List<Tuple<NodeId>> tuples = new ArrayList<>(data.triples.size());
                for (Triple t : data.triples) {
                    countTriples++;
                    accTuples(t, nodeTable, tuples);
                }
                dispatchTuples3(tuples);
            }
            if (data.quads != null) {
                List<Tuple<NodeId>> tuples = new ArrayList<>(data.quads.size());
                for (Quad q : data.quads) {
                    countQuads++;
                    accTuples(q, nodeTable, tuples);
                }
                dispatchTuples4(tuples);
            }
        }
        dispatchTuples3(LoaderConst.END_TUPLES);
        dispatchTuples4(LoaderConst.END_TUPLES);
        transaction.commit();
    } catch (Exception ex) {
        Log.error(this, "Exception during data loading", ex);
        transaction.abort();
    }
    transaction.end();
    CoLib.finish(coordinator);
    termination.release();
}
Also used : Triple(org.apache.jena.graph.Triple) Quad(org.apache.jena.sparql.core.Quad) ArrayList(java.util.ArrayList) Tuple(org.apache.jena.atlas.lib.tuple.Tuple) BulkLoaderException(org.apache.jena.tdb2.loader.BulkLoaderException)

Example 7 with NodeTable

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

the class DataToTuplesInlineSingle 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 8 with NodeTable

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

the class DataToTuplesInlineSingle method startBulk.

@Override
public void startBulk() {
    coordinator = CoLib.newCoordinator();
    CoLib.add(coordinator, nodeTable);
    // Prefixes
    NodeTupleTable p = prefixes.getNodeTupleTable();
    CoLib.add(coordinator, p.getNodeTable());
    CoLib.add(coordinator, p.getTupleTable().getIndexes());
    CoLib.start(coordinator);
    transaction = coordinator.begin(TxnType.WRITE);
}
Also used : NodeTupleTable(org.apache.jena.tdb2.store.nodetupletable.NodeTupleTable)

Example 9 with NodeTable

use of org.apache.jena.tdb2.store.nodetable.NodeTable 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 10 with NodeTable

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

Aggregations

NodeId (org.apache.jena.tdb2.store.NodeId)21 NodeTable (org.apache.jena.tdb2.store.nodetable.NodeTable)16 Node (org.apache.jena.graph.Node)14 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)6 Quad (org.apache.jena.sparql.core.Quad)6 NodeTupleTable (org.apache.jena.tdb2.store.nodetupletable.NodeTupleTable)6 ArrayList (java.util.ArrayList)5 Triple (org.apache.jena.graph.Triple)5 NodeTableTRDF (org.apache.jena.tdb2.store.nodetable.NodeTableTRDF)5 Iterator (java.util.Iterator)3 Predicate (java.util.function.Predicate)3 RecordFactory (org.apache.jena.dboe.base.record.RecordFactory)3 Index (org.apache.jena.dboe.index.Index)3 RangeIndex (org.apache.jena.dboe.index.RangeIndex)3 Binding (org.apache.jena.sparql.engine.binding.Binding)3 TupleIndex (org.apache.jena.tdb2.store.tupletable.TupleIndex)3 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