[ 
https://issues.apache.org/jira/browse/JENA-2302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17502552#comment-17502552
 ] 

Claus Stadler commented on JENA-2302:
-------------------------------------

I have hacked up an initial approach using GSON - in order to deal with headers 
anywhere in the stream there is the BufferedRowSet header which buffers 
bindings until it encounters a header.

[RowSetJson|https://github.com/Scaseco/jenax/blob/57ba3b044d98d716ace6db62f23b7b678a0726f7/jenax-io-parent/jenax-io-core/src/main/java/org/aksw/jenax/io/json/RowSetJson.java#L39]

[BufferedRowSet|https://github.com/Scaseco/jenax/blob/57ba3b044d98d716ace6db62f23b7b678a0726f7/jenax-io-parent/jenax-io-core/src/main/java/org/aksw/jenax/io/json/BufferedRowSet.java#L32]

I still need to do testing and add all the additional validation of the 
original RowSetJSON
And of course I need to check how hard it is to switch to any of the other JSON 
APIs - but overall its a first working solution.





> 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 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)
> {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: 
> {code:bash}
> curl --data-urlencode "query=select * { ?s ?p ?o }"  
> "http://moin.aksw.org/sparql";
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to