On 12/12/17 23:04, George News wrote:
On 2017-12-12 23:58, Andy Seaborne wrote:


On 12/12/17 22:54, George News wrote:
I'm planning on changing the class/methods call hierarchy in order to
use transactions only on the upper levels, so this way I will be only
opening one transaction and handle everything within it. The problem is
that this is a major change, and will remove the autonomy from each
class, but if this is the price to make the code stable I will have to
do so.
Txn and explicit control will bite you.
Then from your comment above, and this one (which I hope code doesn't
bite ;)) I will be changing the code to remove references to begin/end
and try to use Txn as much as possible.

However, I cannot do for every part of the code, as the ResultSet is
handle in different functions (one begin() transaction, another
presents/adapts results and end transaction()). The main problem is that
this transaction is the outer one.

try(QueryExecution qExec = ...) {
    ResultSet rs = ResultSetFactory.copyResults(qExec.exexSelect());
    return rs;
}

Once copied, the result set is not dependent dataset and so not
dependent on the transaction.

I know that, but some of the resultsets are 10Mb-50Mb or more in size,
and I don't know what is the impact in performance in case many request
arrives at the system.

Currently I'm directly streaming the ResultSet using StreamingOuput. I
convert each row in the Accept format and sent it. This way I don't have
anything in memory.

But, just one question concerning copyResults and keeping the original
resultset. Is the original ResultSet data kept in cache? I mean the
whole lot of results, or just one.

The copy is a materialization of the results set plus a new ArrayList to hold the bindings in.

So data is not in a (TDB) cache.

You can also write code that passes algorithms from class to class and have the result set processing happen inside try-resource:

Argument: Consumer<ResultSet> action;

try(QueryExecution qExec = ...) {
    action.accept(qExec.exexSelect());
}

Java8 lambdas open up a lot of possibilities.

    Andy



     Andy

Reply via email to