What you need to remember is that query execution is streaming lazy evaluation. 
So each time you call hasNext()/next() the minimum amount of work needed to 
compute the next answer, If any, is done. When you convert the ResultSet into a 
list you’re doing all that work up front once. When you iterate over the copied 
Data it is just a static list of the previously computed results. Iterating 
over a static list has very little overhead computationally, the downside is 
that it may have a lot of memory overhead if you have a extremely large 
results. This is a standard space time trade-off and you have to decide what 
makes sense in your applications context.

 Rob

On 28/02/2017 16:19, "George News" <[email protected]> wrote:

    
    On 28/02/2017 16:59, Andy Seaborne wrote:
    > 
    > [... snip ...]
    >> In this sense, one option for including in Jena could be to enable the
    >> option to create a QueryExecution with transaction included, in order to
    >> avoid some issues like that.
    > 
    > That's what ResultSetFormatter.toList or ResultSetFactory.copyResults do.
    
    +1 but I don't want to iterate twice over the same list of data.
    Although at the end I think it would be the easiest way to do it and
    avoid extra issues ;)
    
    
    >     Andy
    > 
    




Reply via email to