Search in sources :

Example 31 with RowSet

use of org.apache.jena.sparql.exec.RowSet in project jena by apache.

the class TestThriftResultSet method test.

private static ResultSetRewindable test(ResultSetRewindable resultSet) {
    resultSet.reset();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ResultSetFormatter.output(out, resultSet, ResultSetLang.RS_Thrift);
    resultSet.reset();
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    RowSet rs$ = ThriftRDF.readRowSet(in);
    ResultSetRewindable resultSet2 = ResultSetFactory.makeRewindable(rs$);
    // Includes bnode labels.
    ResultSetCompare.equalsExact(resultSet, resultSet2);
    resultSet.reset();
    resultSet2.reset();
    return resultSet2;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RowSet(org.apache.jena.sparql.exec.RowSet) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ResultSetRewindable(org.apache.jena.query.ResultSetRewindable)

Example 32 with RowSet

use of org.apache.jena.sparql.exec.RowSet in project jena by apache.

the class RowSetReaderCSV method csvResult.

/**
 * Expect either a RowSet or a boolean
 */
private static QueryExecResult csvResult(InputStream in) {
    CSVParser parser = CSVParser.create(in);
    final List<Var> vars = vars(parser);
    if (isBooleanResult(vars)) {
        boolean booleanResult = booleanFromCSV(parser);
        return new QueryExecResult(booleanResult);
    }
    RowSet resultSet = resultSetFromCSV(vars, parser);
    return new QueryExecResult(resultSet);
}
Also used : Var(org.apache.jena.sparql.core.Var) CSVParser(org.apache.jena.atlas.csv.CSVParser) QueryExecResult(org.apache.jena.sparql.exec.QueryExecResult) RowSet(org.apache.jena.sparql.exec.RowSet)

Example 33 with RowSet

use of org.apache.jena.sparql.exec.RowSet in project jena by apache.

the class TestSolverTDB method solve_03.

@Test
public void solve_03() {
    // Above everything.
    RowSet rs1 = exec("(bgp (:zzzz :p 999999))");
    RowSet rs2 = results("empty");
    equals(rs1, rs2);
}
Also used : RowSet(org.apache.jena.sparql.exec.RowSet) ConfigTest(org.apache.jena.tdb2.ConfigTest) Test(org.junit.Test)

Example 34 with RowSet

use of org.apache.jena.sparql.exec.RowSet in project jena by apache.

the class TestSolverTDB method solve_06.

@Test
public void solve_06() {
    RowSet rs1 = exec("(bgp (:s ?p ?o))");
    RowSet rs2 = results("(row (?p :p) (?o :o))", "(row (?p :p) (?o 10))", "(row (?p :p) (?o :x))");
    equals(rs1, rs2);
}
Also used : RowSet(org.apache.jena.sparql.exec.RowSet) ConfigTest(org.apache.jena.tdb2.ConfigTest) Test(org.junit.Test)

Example 35 with RowSet

use of org.apache.jena.sparql.exec.RowSet in project jena by apache.

the class TestSolverTDB method solve_07.

@Test
public void solve_07() {
    // JENA-1428, JENA-1529
    String x = "(sequence  (table (vars ?X) (row [?X 'NotPresent']))  (bgp (triple :s :p ?o)))";
    RowSet rs1 = exec(x);
    assertTrue(rs1.hasNext());
    // Executing without stack trace is enough.
    rs1.materialize();
}
Also used : RowSet(org.apache.jena.sparql.exec.RowSet) ConfigTest(org.apache.jena.tdb2.ConfigTest) Test(org.junit.Test)

Aggregations

RowSet (org.apache.jena.sparql.exec.RowSet)43 Test (org.junit.Test)36 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)12 EnvTest (org.apache.jena.test.conn.EnvTest)10 QueryExec (org.apache.jena.sparql.exec.QueryExec)9 RDFLink (org.apache.jena.rdflink.RDFLink)7 ConfigTest (org.apache.jena.tdb.ConfigTest)7 ConfigTest (org.apache.jena.tdb2.ConfigTest)7 Binding (org.apache.jena.sparql.engine.binding.Binding)6 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 HttpRequestModifier (org.apache.jena.http.sys.HttpRequestModifier)2 ResultSetRewindable (org.apache.jena.query.ResultSetRewindable)2 Quad (org.apache.jena.sparql.core.Quad)2 Var (org.apache.jena.sparql.core.Var)2 QueryExecResult (org.apache.jena.sparql.exec.QueryExecResult)2 HttpClient (java.net.http.HttpClient)1 CSVParser (org.apache.jena.atlas.csv.CSVParser)1 HttpException (org.apache.jena.atlas.web.HttpException)1