Search in sources :

Example 71 with ResultSet

use of org.apache.jena.query.ResultSet in project jena by apache.

the class TableBase method toResultSet.

@Override
public ResultSet toResultSet() {
    QueryIterator qIter = iterator(null);
    ResultSet rs = new ResultSetStream(getVarNames(), null, qIter);
    rs = ResultSetFactory.makeRewindable(rs);
    qIter.close();
    return rs;
}
Also used : QueryIterator(org.apache.jena.sparql.engine.QueryIterator) ResultSet(org.apache.jena.query.ResultSet) ResultSetStream(org.apache.jena.sparql.engine.ResultSetStream)

Example 72 with ResultSet

use of org.apache.jena.query.ResultSet in project jena by apache.

the class JSONInput method process.

// TODO Streaming version of JSON Result set processing
private SPARQLResult process(InputStream in, Model model) {
    parse(in);
    if (model == null)
        model = GraphFactory.makeJenaDefaultModel();
    if (rows != null) {
        QueryIterator qIter = new QueryIterPlainWrapper(rows.iterator());
        ResultSet rs = new ResultSetStream(Var.varNames(vars), model, qIter);
        super.set(rs);
    } else
        super.set(booleanResult);
    return this;
}
Also used : QueryIterPlainWrapper(org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper) QueryIterator(org.apache.jena.sparql.engine.QueryIterator) ResultSet(org.apache.jena.query.ResultSet) ResultSetStream(org.apache.jena.sparql.engine.ResultSetStream)

Example 73 with ResultSet

use of org.apache.jena.query.ResultSet in project jena by apache.

the class TestSolverTDB method solve_05.

@Test
public void solve_05() {
    ResultSet rs1 = exec("(project (?s ?y) (bgp (?s :p ?z) (?z :q ?y)))", graph);
    ResultSet rs2 = results("(row (?s :s) (?y :y))");
    equals(rs1, rs2);
}
Also used : ResultSet(org.apache.jena.query.ResultSet) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test) ConfigTest(org.apache.jena.tdb.ConfigTest)

Example 74 with ResultSet

use of org.apache.jena.query.ResultSet in project jena by apache.

the class TestSolverTDB method solve_01.

@Test
public void solve_01() {
    ResultSet rs1 = exec("(bgp (:s :p :o))", graph);
    ResultSet rs2 = results("unit");
    equals(rs1, rs2);
}
Also used : ResultSet(org.apache.jena.query.ResultSet) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test) ConfigTest(org.apache.jena.tdb.ConfigTest)

Example 75 with ResultSet

use of org.apache.jena.query.ResultSet in project jena by apache.

the class TestDatasetWithLuceneStoredLiterals method doTestSearchWithLiteralsMultiple.

protected List<Node> doTestSearchWithLiteralsMultiple(String turtle, String queryString, String expectedEntityURI) {
    List<Node> literals = new LinkedList<>();
    Model model = dataset.getDefaultModel();
    Reader reader = new StringReader(turtle);
    dataset.begin(ReadWrite.WRITE);
    model.read(reader, "", "TURTLE");
    dataset.commit();
    Query query = QueryFactory.create(queryString);
    dataset.begin(ReadWrite.READ);
    try (QueryExecution qexec = QueryExecutionFactory.create(query, dataset)) {
        ResultSet results = qexec.execSelect();
        int count;
        for (count = 0; results.hasNext(); count++) {
            QuerySolution soln = results.nextSolution();
            String entityURI = soln.getResource("s").getURI();
            assertEquals(expectedEntityURI, entityURI);
            Literal literal = soln.getLiteral("literal");
            assertNotNull(literal);
            literals.add(literal.asNode());
        }
    } finally {
        dataset.end();
    }
    return literals;
}
Also used : Query(org.apache.jena.query.Query) Node(org.apache.jena.graph.Node) Reader(java.io.Reader) StringReader(java.io.StringReader) LinkedList(java.util.LinkedList) QueryExecution(org.apache.jena.query.QueryExecution) QuerySolution(org.apache.jena.query.QuerySolution) Literal(org.apache.jena.rdf.model.Literal) Model(org.apache.jena.rdf.model.Model) StringReader(java.io.StringReader) ResultSet(org.apache.jena.query.ResultSet)

Aggregations

ResultSet (org.apache.jena.query.ResultSet)75 Test (org.junit.Test)43 BuilderResultSet (org.apache.jena.sparql.sse.builders.BuilderResultSet)33 BaseTest (org.apache.jena.atlas.junit.BaseTest)27 QueryExecution (org.apache.jena.query.QueryExecution)14 ByteArrayInputStream (java.io.ByteArrayInputStream)13 QuerySolution (org.apache.jena.query.QuerySolution)11 ResultSetRewindable (org.apache.jena.query.ResultSetRewindable)11 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)8 ResultSetStream (org.apache.jena.sparql.engine.ResultSetStream)8 ArrayList (java.util.ArrayList)7 Node (org.apache.jena.graph.Node)7 Query (org.apache.jena.query.Query)7 Model (org.apache.jena.rdf.model.Model)6 ConfigTest (org.apache.jena.tdb.ConfigTest)6 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)5 Var (org.apache.jena.sparql.core.Var)5 Binding (org.apache.jena.sparql.engine.binding.Binding)4 AbstractRegexpBasedTest (org.apache.jena.arq.AbstractRegexpBasedTest)3