Search in sources :

Example 76 with Node

use of org.apache.jena.graph.Node in project jena by apache.

the class listIndex method findIndexMember.

private static QueryIterator findIndexMember(Graph graph, Binding binding, Node listNode, Var varIndex, Var varMember, ExecutionContext execCxt) {
    // Iterate over list
    List<Node> members = GraphList.members(new GNode(graph, listNode));
    List<Binding> bindings = new ArrayList<>();
    for (int i = 0; i < members.size(); i++) {
        Node idx = NodeFactoryExtra.intToNode(i);
        Node member = members.get(i);
        BindingMap b = BindingFactory.create(binding);
        b.add(varIndex, idx);
        b.add(varMember, member);
        bindings.add(b);
    }
    return new QueryIterPlainWrapper(bindings.iterator(), execCxt);
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) QueryIterPlainWrapper(org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper) GNode(org.apache.jena.sparql.util.graph.GNode) Node(org.apache.jena.graph.Node) GNode(org.apache.jena.sparql.util.graph.GNode) ArrayList(java.util.ArrayList) BindingMap(org.apache.jena.sparql.engine.binding.BindingMap)

Example 77 with Node

use of org.apache.jena.graph.Node in project jena by apache.

the class PathEngine1 method doMultiLengthPath.

@Override
protected void doMultiLengthPath(Path pathStep, Node node, long min1, long max1, Collection<Node> output) {
    if (min1 == P_Mod.UNSET)
        // {,N}
        min1 = 0;
    // do 0-min1 steps, not collecting.
    Collection<Node> collectStartPoints = collector();
    if (min1 > 0)
        doFixedLengthPath(pathStep, node, min1, collectStartPoints);
    else
        collectStartPoints.add(node);
    // System.out.println("Start points: "+collectStartPoints) ;
    // {N,M} = {N} then {0,M-N}
    int length = (int) (max1 - min1);
    Collection<Node> visited = collector();
    for (Node n : collectStartPoints) doMultiLengthPath(pathStep, n, length, visited, output);
}
Also used : Node(org.apache.jena.graph.Node)

Example 78 with Node

use of org.apache.jena.graph.Node in project jena by apache.

the class PathEngineN method ALP.

// This is the worker function for path*
private void ALP(Node node, Path path, Set<Node> visited, Collection<Node> output) {
    if (visited.contains(node))
        return;
    // "visited" is nodes on this path (see the matching .remove).
    if (!output.add(node))
        return;
    visited.add(node);
    Iterator<Node> iter1 = eval(path, node);
    // For each step, add to results and recurse.
    for (; iter1.hasNext(); ) {
        Node n1 = iter1.next();
        ALP(n1, path, visited, output);
    }
    visited.remove(node);
}
Also used : Node(org.apache.jena.graph.Node)

Example 79 with Node

use of org.apache.jena.graph.Node in project jena by apache.

the class TestNodeAllocator method allocOneScope3.

@Test
public void allocOneScope3() {
    LabelToNode alloc = SyntaxLabels.createLabelToNode();
    Node b1 = alloc.get(gragh1, "xyz");
    Node b2 = alloc.get(gragh2, "xyz");
    // SAME
    assertEquals(b1, b2);
}
Also used : LabelToNode(org.apache.jena.riot.lang.LabelToNode) Node(org.apache.jena.graph.Node) LabelToNode(org.apache.jena.riot.lang.LabelToNode) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 80 with Node

use of org.apache.jena.graph.Node in project jena by apache.

the class TestNodeAllocator method allocOneScope4.

@Test
public void allocOneScope4() {
    LabelToNode alloc = SyntaxLabels.createLabelToNode();
    Node b1 = alloc.get(null, "xyz");
    Node b2 = alloc.get(gragh2, "xyz");
    // SAME
    assertEquals(b1, b2);
}
Also used : LabelToNode(org.apache.jena.riot.lang.LabelToNode) Node(org.apache.jena.graph.Node) LabelToNode(org.apache.jena.riot.lang.LabelToNode) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Aggregations

Node (org.apache.jena.graph.Node)681 Test (org.junit.Test)191 Triple (org.apache.jena.graph.Triple)98 BaseTest (org.apache.jena.atlas.junit.BaseTest)85 Var (org.apache.jena.sparql.core.Var)84 ArrayList (java.util.ArrayList)55 Graph (org.apache.jena.graph.Graph)46 Binding (org.apache.jena.sparql.engine.binding.Binding)40 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)36 Quad (org.apache.jena.sparql.core.Quad)35 LabelToNode (org.apache.jena.riot.lang.LabelToNode)28 RDFNode (org.apache.jena.rdf.model.RDFNode)25 HashMap (java.util.HashMap)22 Model (org.apache.jena.rdf.model.Model)18 BindingMap (org.apache.jena.sparql.engine.binding.BindingMap)18 NodeId (org.apache.jena.tdb.store.NodeId)18 NodeWritable (org.apache.jena.hadoop.rdf.types.NodeWritable)16 Token (org.apache.jena.riot.tokens.Token)16 BasicPattern (org.apache.jena.sparql.core.BasicPattern)16 NodeValue (org.apache.jena.sparql.expr.NodeValue)16