Search in sources :

Example 1 with OpTable

use of org.apache.jena.sparql.algebra.op.OpTable in project jena by apache.

the class TestTable method table_02.

// JENA-1468: Table, no rows , with declared variables.
@Test
public void table_02() {
    Table table = TableFactory.create();
    table.getVars().add(Var.alloc("a"));
    Op opTable = OpTable.create(table);
    String x = str(opTable);
    assertEquals("(table (vars ?a))", x);
}
Also used : WriterOp(org.apache.jena.sparql.sse.writers.WriterOp) OpTable(org.apache.jena.sparql.algebra.op.OpTable) Test(org.junit.Test)

Example 2 with OpTable

use of org.apache.jena.sparql.algebra.op.OpTable in project jena by apache.

the class TestTable method table_03.

@Test
public void table_03() {
    Table table = TableFactory.create();
    Binding b = BindingFactory.empty();
    table.addBinding(b);
    Op opTable = OpTable.create(table);
    String x = str(opTable);
    assertEquals("(table (vars) (row) )", x);
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) WriterOp(org.apache.jena.sparql.sse.writers.WriterOp) OpTable(org.apache.jena.sparql.algebra.op.OpTable) Test(org.junit.Test)

Example 3 with OpTable

use of org.apache.jena.sparql.algebra.op.OpTable 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) OpTable(org.apache.jena.sparql.algebra.op.OpTable) Var(org.apache.jena.sparql.core.Var) TableN(org.apache.jena.sparql.algebra.table.TableN)

Example 4 with OpTable

use of org.apache.jena.sparql.algebra.op.OpTable in project jena by apache.

the class TestTransformFilters method nested_02.

@Test
public void nested_02() {
    Transform tableChanger = new TransformCopy() {

        @Override
        public Op transform(OpTable opTable) {
            // Always a new object
            return OpTable.create(opTable.getTable());
        }
    };
    testOp("(filter (?A) (filter (?B) (table unit)))", tableChanger, "(filter (exprlist ?B ?A) (table unit))");
}
Also used : TransformCopy(org.apache.jena.sparql.algebra.TransformCopy) OpTable(org.apache.jena.sparql.algebra.op.OpTable) Transform(org.apache.jena.sparql.algebra.Transform) Test(org.junit.Test)

Example 5 with OpTable

use of org.apache.jena.sparql.algebra.op.OpTable in project jena by apache.

the class TestTable method table_01.

@Test
public void table_01() {
    Table table = TableFactory.createEmpty();
    Op opTable = OpTable.create(table);
    String x = str(opTable);
    assertEquals("(table empty)", x);
}
Also used : WriterOp(org.apache.jena.sparql.sse.writers.WriterOp) OpTable(org.apache.jena.sparql.algebra.op.OpTable) Test(org.junit.Test)

Aggregations

OpTable (org.apache.jena.sparql.algebra.op.OpTable)5 Test (org.junit.Test)4 WriterOp (org.apache.jena.sparql.sse.writers.WriterOp)3 Binding (org.apache.jena.sparql.engine.binding.Binding)2 Table (org.apache.jena.sparql.algebra.Table)1 Transform (org.apache.jena.sparql.algebra.Transform)1 TransformCopy (org.apache.jena.sparql.algebra.TransformCopy)1 TableN (org.apache.jena.sparql.algebra.table.TableN)1 Var (org.apache.jena.sparql.core.Var)1