Search in sources :

Example 6 with NodeId

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

the class StageGeneratorDirectTDB method execute.

@Override
public QueryIterator execute(BasicPattern pattern, QueryIterator input, ExecutionContext execCxt) {
    // --- In case this isn't for TDB2
    Graph g = execCxt.getActiveGraph();
    if (g instanceof GraphViewSwitchable) {
        GraphViewSwitchable gvs = (GraphViewSwitchable) g;
        g = gvs.getBaseGraph();
    }
    if (!(g instanceof GraphTDB))
        // Not us - bounce up the StageGenerator chain
        return above.execute(pattern, input, execCxt);
    GraphTDB graph = (GraphTDB) g;
    Predicate<Tuple<NodeId>> filter = QC2.getFilter(execCxt.getContext());
    return PatternMatchTDB2.execute(graph, pattern, input, filter, execCxt);
}
Also used : Graph(org.apache.jena.graph.Graph) GraphViewSwitchable(org.apache.jena.tdb2.store.GraphViewSwitchable) GraphTDB(org.apache.jena.tdb2.store.GraphTDB) Tuple(org.apache.jena.atlas.lib.tuple.Tuple)

Example 7 with NodeId

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

the class NodeIdFactory method create.

private static NodeId create(int v1, long v2) {
    if (!BitsInt.isSet(v1, 32))
        return createPtrLong(v1, v2);
    int t = v1 >> 24;
    NodeIdType type = NodeIdType.intToEnum(t);
    if (type == NodeIdType.SPECIAL)
        throw new TDBException(String.format("Attempt to create a special from a long: 0x%016", v2));
    return createNew(type, 0, v2);
}
Also used : TDBException(org.apache.jena.tdb2.TDBException)

Example 8 with NodeId

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

the class NodeIdFactory method create64.

// ---- Create from binary.
// 64 bit create
private static NodeId create64(long value2) {
    if (!BitsLong.isSet(value2, 63))
        return createPtr(value2);
    // Inline.
    long v2 = value2;
    if (BitsLong.isSet(v2, 62)) {
        // XSD_DOUBLE
        v2 = DoubleNode62.removeType(v2);
        return NodeId.createRaw(NodeIdType.XSD_DOUBLE, v2);
    }
    // 7 bits
    int t = (int) BitsLong.unpack(v2, 56, 63);
    v2 = BitsLong.clear(v2, 56, 64);
    NodeIdType type = NodeIdType.intToEnum(t);
    if (type == NodeIdType.SPECIAL)
        throw new TDBException(String.format("Attempt to create a special from a long: 0x%016", v2));
    return NodeId.createRaw(type, v2);
}
Also used : TDBException(org.apache.jena.tdb2.TDBException)

Example 9 with NodeId

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

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

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