Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-2302

RowSetReaderJSON is not streaming

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Implemented
    • Jena 4.5.0
    • Jena 4.5.0
    • ARQ
    • None

    Description

      Retrieving all data from our TDB2 endpoint with jena 4.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)

      public class RowSetReaderJson {
              private void parse(InputStream in) {
                  JsonObject obj = JSON.parse(in); // !!! Loads everything !!!
      
                  // Boolean?
                  if ( obj.hasKey(kBoolean) ) { ... }
          }
      }
      

      Streaming works when switching the to RS_XML in the example below:

      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");
          }
      }
      

      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"
      

      Attachments

        Issue Links

          Activity

            People

              Aklakan Claus Stadler
              Aklakan Claus Stadler
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: