You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Claus Stadler (Jira)" <ji...@apache.org> on 2022/03/07 14:26:00 UTC
[jira] [Updated] (JENA-2302) RowSetReaderJSON is not streaming
[ https://issues.apache.org/jira/browse/JENA-2302?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Stadler updated JENA-2302:
--------------------------------
Description:
Retrieving all data from out TDB2 endpoint with jena 2.5.0-SNAPSHOT is no longer streaming for the JSON format. I tracked the issue to RowSetReaderJson which reads everything into in memory (and then checks whether it is a SPARQL ASK result)
{code:java}
public class RowSetReaderJson {
private void parse(InputStream in) {
JsonObject obj = JSON.parse(in); // !!! Loads everything !!!
// Boolean?
if ( obj.hasKey(kBoolean) ) { ... }
}
}
{code}
Streaming works when switching the to RS_XML in the example below:
{code:java}
public class Main {
public static void main(String[] args) {
System.out.println("Test Started");
try (QueryExecution qe = QueryExecutionHTTP.create()
.acceptHeader(ResultSetLang.RS_JSON.getContentType().getContentTypeStr())
.endpoint("http://moin.aksw.org/sparql").queryString("SELECT * { ?s ?p ?o }").build()) {
qe.execSelect().forEachRemaining(System.out::println);
}
System.out.println("Done");
}
}
{code}
For completeness, I can rule out any problem with TDB2 because streaming of JSON works just fine with:
curl --data-urlencode "query=select * { ?s ?p ?o }" "http://moin.aksw.org/sparql"
was:
Retrieving all data from out TDB2 endpoint with jena 2.5.0-SNAPSHOT is no longer streaming for the JSON format. I tracked the issue to RowSetReaderJson which reads everything into in memory (and then checks whether it is a SPARQL ASK result)
{code:java}
public class RowSetReaderJson {
private void parse(InputStream in) {
JsonObject obj = JSON.parse(in); // !!! Loads everything !!!
// Boolean?
if ( obj.hasKey(kBoolean) ) { ... }
}
}
{code:java}
Streaming works when switching the to RS_XML in the example below:
{code:java}
public class Main {
public static void main(String[] args) {
System.out.println("Test Started");
try (QueryExecution qe = QueryExecutionHTTP.create()
.acceptHeader(ResultSetLang.RS_JSON.getContentType().getContentTypeStr())
.endpoint("http://moin.aksw.org/sparql").queryString("SELECT * { ?s ?p ?o }").build()) {
qe.execSelect().forEachRemaining(System.out::println);
}
System.out.println("Done");
}
}
{code}
For completeness, I can rule out any problem with TDB2 because streaming of JSON works just fine with:
curl --data-urlencode "query=select * { ?s ?p ?o }" "http://moin.aksw.org/sparql"
> RowSetReaderJSON is not streaming
> ---------------------------------
>
> Key: JENA-2302
> URL: https://issues.apache.org/jira/browse/JENA-2302
> Project: Apache Jena
> Issue Type: Bug
> Components: ARQ
> Affects Versions: Jena 4.5.0
> Reporter: Claus Stadler
> Priority: Major
>
> Retrieving all data from out TDB2 endpoint with jena 2.5.0-SNAPSHOT is no longer streaming for the JSON format. I tracked the issue to RowSetReaderJson which reads everything into in memory (and then checks whether it is a SPARQL ASK result)
> {code:java}
> public class RowSetReaderJson {
> private void parse(InputStream in) {
> JsonObject obj = JSON.parse(in); // !!! Loads everything !!!
> // Boolean?
> if ( obj.hasKey(kBoolean) ) { ... }
> }
> }
> {code}
> Streaming works when switching the to RS_XML in the example below:
> {code:java}
> public class Main {
> public static void main(String[] args) {
> System.out.println("Test Started");
> try (QueryExecution qe = QueryExecutionHTTP.create()
> .acceptHeader(ResultSetLang.RS_JSON.getContentType().getContentTypeStr())
> .endpoint("http://moin.aksw.org/sparql").queryString("SELECT * { ?s ?p ?o }").build()) {
> qe.execSelect().forEachRemaining(System.out::println);
> }
> System.out.println("Done");
> }
> }
> {code}
> For completeness, I can rule out any problem with TDB2 because streaming of JSON works just fine with:
> curl --data-urlencode "query=select * { ?s ?p ?o }" "http://moin.aksw.org/sparql"
--
This message was sent by Atlassian Jira
(v8.20.1#820001)