On 10/04/13 15:23, "Dr. André Lanka" wrote:
Dear Jena community,
we didn't find a way (in the original Jena API 2.10) to completely
detach a result set from the underlying model. It's possible to detach
it from the QueryExecution by using ResultSetFactory.copyResults but the
bindings still point to the TDB backed model.
By this we encountered some issues as we store results sets for a long
time and the read transaction that created the results stays alive (even
if we calls commit or end). Having this read transaction opened leads to
problems when you have many writers after that (stack usage, huge
journal files, ...).
We finally found a way to convert TDB backed result set to a completely
detached ResultSetRewindable. If you find this useful, it's attached below.
Cheers
André
Good point - it's a bit of a tradeoff. The result sets API supports
mixing SPARQL with other Jena API calls:
Resource r = row.getResource("var") ;
r.listProperties() ;
to do that "r" needs to know the model.
To break the connection,
1/ use ResultSet.nextBinding() which returns the low level, unconnected
graph Nodes.
2/ Much like your code - you could use ResultSetStream itself, create a
QueryIterator of the Bindings passing in a memory model to the
constructor of ResultSetStream.
I'll change ResultSetStream to take a Iterator<binding> in place of
QueryIterator (which implements Iterator<binding>) to make it easier.
3/ Processing style - consume the ResultSet inside the transaction and
pass a different datastructure passed end(). You'll need to use up the
query results anyway.
Andy