Search in sources :

Example 1 with Table

use of org.apache.jena.sparql.algebra.Table in project jena by apache.

the class TableBase method equals.

@Override
public boolean equals(Object other) {
    if (this == other)
        return true;
    if (!(other instanceof Table))
        return false;
    Table table = (Table) other;
    if (table.size() != this.size())
        return false;
    QueryIterator qIter1 = iterator(null);
    QueryIterator qIter2 = table.iterator(null);
    try {
        for (; qIter1.hasNext(); ) {
            Binding bind1 = qIter1.nextBinding();
            Binding bind2 = qIter2.nextBinding();
            if (!BindingBase.equals(bind1, bind2))
                return false;
        }
        return true;
    } finally {
        qIter1.close();
        qIter2.close();
    }
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) Table(org.apache.jena.sparql.algebra.Table) QueryIterator(org.apache.jena.sparql.engine.QueryIterator)

Example 2 with Table

use of org.apache.jena.sparql.algebra.Table in project jena by apache.

the class AbstractTestJoin method executeTestJoin.

protected void executeTestJoin(String msg, JoinKey joinKey, Table left, Table right, ExprList conditions, Table expectedResults) {
    Table x1 = joinMaterialize(joinKey, left, right, conditions);
    assertNotNull("Null table from join (" + msg + ")", x1);
    if (false)
        print(msg, joinKey, left, right, conditions, expectedResults, x1);
    check("Results not equal (" + msg + ")", joinKey, left, right, conditions, expectedResults, x1);
}
Also used : Table(org.apache.jena.sparql.algebra.Table)

Example 3 with Table

use of org.apache.jena.sparql.algebra.Table in project jena by apache.

the class AbstractTestLeftJoin method leftjoin_condition_02.

@Test
public void leftjoin_condition_02() {
    Table tableD3_LJc = parseTableInt("(table", "   (row (?d 8) (?a 0))", "   (row (?a 1) (?c 9) (?b 2))", "   (row (?a 1) (?c 9) (?b 2))", ")");
    testJoin("a", tableD2(), tableD1(), "((= ?a 1) (= ?b 2))", tableD3_LJc);
}
Also used : Table(org.apache.jena.sparql.algebra.Table) Test(org.junit.Test)

Example 4 with Table

use of org.apache.jena.sparql.algebra.Table in project jena by apache.

the class AbstractTestLeftJoin method leftjoin_condition_01.

// Conditions.
@Test
public void leftjoin_condition_01() {
    Table tableD1c = parseTableInt("(table", "   (row (?a 1) (?b 3))", ")");
    testJoin("a", table1(), tableD1(), "((= ?b 3))", tableD1c);
}
Also used : Table(org.apache.jena.sparql.algebra.Table) Test(org.junit.Test)

Example 5 with Table

use of org.apache.jena.sparql.algebra.Table in project jena by apache.

the class OpRewriter method visit.

@Override
public void visit(OpTable opTable) {
    Table tbl = opTable.getTable();
    boolean process = false;
    for (Var v : tbl.getVars()) {
        process = process | values.keySet().contains(v);
    }
    if (!process) {
        push(opTable);
    } else {
        TableN retTbl = new TableN(tbl.getVars());
        Iterator<Binding> iter = tbl.rows();
        while (iter.hasNext()) {
            retTbl.addBinding(rewrite(iter.next()));
        }
        push(OpTable.create(retTbl));
    }
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) Table(org.apache.jena.sparql.algebra.Table) TableN(org.apache.jena.sparql.algebra.table.TableN)

Aggregations

Table (org.apache.jena.sparql.algebra.Table)37 Var (org.apache.jena.sparql.core.Var)4 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)4 Binding (org.apache.jena.sparql.engine.binding.Binding)4 Node (org.apache.jena.graph.Node)3 Op (org.apache.jena.sparql.algebra.Op)3 Graph (org.apache.jena.graph.Graph)2 ARQInternalErrorException (org.apache.jena.sparql.ARQInternalErrorException)2 OpGraph (org.apache.jena.sparql.algebra.op.OpGraph)2 TableEmpty (org.apache.jena.sparql.algebra.table.TableEmpty)2 BasicPattern (org.apache.jena.sparql.core.BasicPattern)2 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)2 ExecutionContext (org.apache.jena.sparql.engine.ExecutionContext)2 Test (org.junit.Test)2 InternalErrorException (org.apache.jena.atlas.lib.InternalErrorException)1 Triple (org.apache.jena.graph.Triple)1 OpBGP (org.apache.jena.sparql.algebra.op.OpBGP)1 OpTable (org.apache.jena.sparql.algebra.op.OpTable)1 TableN (org.apache.jena.sparql.algebra.table.TableN)1 QueryIterConcat (org.apache.jena.sparql.engine.iterator.QueryIterConcat)1