On 06/08/15 21:15, Евгений =) wrote:
And I accept this error and I already use method that Andy Seaborne writes
herehttps://issues.apache.org/jira/browse/JENA-1006
Iterator<Triple> iter = graph.find(...).toList().iterator();

But looks like this method "hungry for memory" and I'm look for efficient
way(low memory consumption) method to do this stuff.

Your example is small. So I assume you are not actually describing your real use case. Your example is already keeping everything in memory. TDB in-memory, which is for testing mainly, uses a RAM disk for exact semantics with the disk version, and has multiple copies of data.

Maybe similar questions can explain more then me(sorry for links to other
sources):
http://stackoverflow.com/questions/10165096/jena-tdb-nested-transactions
http://answers.semanticweb.com/questions/15852/jena-tdb-nested-transactions

And sorry for my bad english=(

There are several choices:

1/ Increase the heap size.

2/ (if we're really talking about a large disk database). Do a scan through the results of graph.find and keep the subjects in a separate datastructure. Do a second loop over the retained subjects to do the updates. This works well when there are a significant smaller number of places to update than the whole find() locates.

3/ If the updates are going to be huge, and the database is really a larger-than-RAM persistent one, (total number of updates is compararable or larger than RAM) then you are asking for an operation that is fundamentally expensive. Write the updates to a file; in the loop then add the file into the database.

4/ If it's a one off maintance task, dump to N-triples and use perl/ruby/... to fix the backup and reload.

See also large transaction support.
http://mail-archives.apache.org/mod_mbox/jena-users/201507.mbox/%3CCAPTxtVOZRzyPxN1njh3WVggsJEUNxeXDJhNvx%2BG4WcRtExxPxg%40mail.gmail.com%3E

        Andy

Reply via email to