Search in sources :

Example 1 with SolverRX4

use of org.apache.jena.sparql.engine.main.solver.SolverRX4 in project jena by apache.

the class SolverRX method find.

private static Iterator<BindingNodeId> find(BindingNodeId bnid, NodeTupleTable nodeTupleTable, Node xGraphNode, Triple xPattern, boolean anyGraph, Predicate<Tuple<NodeId>> filter, ExecutionContext execCxt) {
    NodeTable nodeTable = nodeTupleTable.getNodeTable();
    Binding input = bnid.isEmpty() ? BindingFactory.empty() : new BindingTDB(bnid, nodeTable);
    Triple tPattern = Substitute.substitute(xPattern, input);
    Node graphNode = Substitute.substitute(xGraphNode, input);
    Node tGraphNode = anyGraph ? Quad.unionGraph : graphNode;
    // graphNode is ANY for union graph and null for default graph.
    // Var to ANY, Triple Term to ANY.
    Node g = (graphNode == null) ? null : nodeTopLevel(graphNode);
    Node s = nodeTopLevel(tPattern.getSubject());
    Node p = nodeTopLevel(tPattern.getPredicate());
    Node o = nodeTopLevel(tPattern.getObject());
    Tuple<Node> patternTuple = (g == null) ? TupleFactory.create3(s, p, o) : TupleFactory.create4(g, s, p, o);
    Iterator<Quad> dsgIter = accessData(patternTuple, nodeTupleTable, anyGraph, filter, execCxt);
    Iterator<Binding> matched = Iter.iter(dsgIter).map(dQuad -> SolverRX4.matchQuad(input, dQuad, tGraphNode, tPattern)).removeNulls();
    return convFromBinding(matched, nodeTable);
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) SolverLibTDB.convFromBinding(org.apache.jena.tdb2.solver.SolverLibTDB.convFromBinding) Triple(org.apache.jena.graph.Triple) Binding(org.apache.jena.sparql.engine.binding.Binding) Iterator(java.util.Iterator) Predicate(java.util.function.Predicate) NodeId(org.apache.jena.tdb2.store.NodeId) SolverLib.nodeTopLevel(org.apache.jena.sparql.engine.main.solver.SolverLib.nodeTopLevel) Triple(org.apache.jena.graph.Triple) SolverLib.tripleHasEmbTripleWithVars(org.apache.jena.sparql.engine.main.solver.SolverLib.tripleHasEmbTripleWithVars) NodeTupleTable(org.apache.jena.tdb2.store.nodetupletable.NodeTupleTable) Function(java.util.function.Function) NodeTable(org.apache.jena.tdb2.store.nodetable.NodeTable) SolverRX4(org.apache.jena.sparql.engine.main.solver.SolverRX4) Substitute(org.apache.jena.sparql.core.Substitute) Node(org.apache.jena.graph.Node) Quad(org.apache.jena.sparql.core.Quad) TupleLib(org.apache.jena.tdb2.lib.TupleLib) TupleFactory(org.apache.jena.atlas.lib.tuple.TupleFactory) SolverLibTDB.convFromBinding(org.apache.jena.tdb2.solver.SolverLibTDB.convFromBinding) 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) Quad(org.apache.jena.sparql.core.Quad) Node(org.apache.jena.graph.Node) NodeTable(org.apache.jena.tdb2.store.nodetable.NodeTable)

Example 2 with SolverRX4

use of org.apache.jena.sparql.engine.main.solver.SolverRX4 in project jena by apache.

the class SolverRX method find.

private static Iterator<BindingNodeId> find(BindingNodeId bnid, NodeTupleTable nodeTupleTable, Node xGraphNode, Triple xPattern, boolean anyGraph, Predicate<Tuple<NodeId>> filter, ExecutionContext execCxt) {
    NodeTable nodeTable = nodeTupleTable.getNodeTable();
    Binding input = bnid.isEmpty() ? BindingFactory.empty() : new BindingTDB(bnid, nodeTable);
    Triple tPattern = Substitute.substitute(xPattern, input);
    Node graphNode = Substitute.substitute(xGraphNode, input);
    Node tGraphNode = anyGraph ? Quad.unionGraph : graphNode;
    // graphNode is ANY for union graph and null for default graph.
    // Var to ANY, Triple Term to ANY.
    Node g = (graphNode == null) ? null : nodeTopLevel(graphNode);
    Node s = nodeTopLevel(tPattern.getSubject());
    Node p = nodeTopLevel(tPattern.getPredicate());
    Node o = nodeTopLevel(tPattern.getObject());
    Tuple<Node> patternTuple = (g == null) ? TupleFactory.create3(s, p, o) : TupleFactory.create4(g, s, p, o);
    Iterator<Quad> dsgIter = accessData(patternTuple, nodeTupleTable, anyGraph, filter, execCxt);
    Iterator<Binding> matched = Iter.iter(dsgIter).map(dQuad -> SolverRX4.matchQuad(input, dQuad, tGraphNode, tPattern)).removeNulls();
    return convFromBinding(matched, nodeTable);
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) SolverLibTDB.convFromBinding(org.apache.jena.tdb.solver.SolverLibTDB.convFromBinding) Triple(org.apache.jena.graph.Triple) 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) Quad(org.apache.jena.sparql.core.Quad) Node(org.apache.jena.graph.Node) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable)

Aggregations

Iterator (java.util.Iterator)2 Function (java.util.function.Function)2 Predicate (java.util.function.Predicate)2 Iter (org.apache.jena.atlas.iterator.Iter)2 InternalErrorException (org.apache.jena.atlas.lib.InternalErrorException)2 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)2 TupleFactory (org.apache.jena.atlas.lib.tuple.TupleFactory)2 Node (org.apache.jena.graph.Node)2 Triple (org.apache.jena.graph.Triple)2 Quad (org.apache.jena.sparql.core.Quad)2 Substitute (org.apache.jena.sparql.core.Substitute)2 ExecutionContext (org.apache.jena.sparql.engine.ExecutionContext)2 Binding (org.apache.jena.sparql.engine.binding.Binding)2 BindingFactory (org.apache.jena.sparql.engine.binding.BindingFactory)2 SolverLib.nodeTopLevel (org.apache.jena.sparql.engine.main.solver.SolverLib.nodeTopLevel)2 SolverLib.tripleHasEmbTripleWithVars (org.apache.jena.sparql.engine.main.solver.SolverLib.tripleHasEmbTripleWithVars)2 SolverRX4 (org.apache.jena.sparql.engine.main.solver.SolverRX4)2 TupleLib (org.apache.jena.tdb.lib.TupleLib)1 SolverLibTDB.convFromBinding (org.apache.jena.tdb.solver.SolverLibTDB.convFromBinding)1 NodeId (org.apache.jena.tdb.store.NodeId)1