You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by George News <ge...@gmx.net> on 2018/01/12 11:37:34 UTC

Transactions on RDFConnection

Hi,

I would like to know how transactions are handle over an RDFConnection
to a local dataset.

When using directly the dataset, you pointed that it doesn't matter if
you user a static instance or not for storing the dataset, as Txn
internally manages and handle everything. In this sense you recommended
using a static instance. Is it the same for RDFConnection or are
transactions linked to the instance?

The issue here is if 1) and 2) behaves similarly when multitheaded calls
to Txn are done. Are both methods blocking access to the dataset? Or is
case 1) only blocking on the instance of the connection and multiple
simultaneous call will led to error?

Thanks for your help
Jorge

1) Per call connection
try ( RDFConnection conn = RDFConnectionFactory.connect(...) ) {
    Txn.execWrite(conn, ()-> {
	// Whatever
    }) ;
}

2) Static instance

public static RDFConnection conn = RDFConnectionFactory.connect(...);

// ....

// In a method
Txn.execWrite(conn, ()-> {
   // Whatever
}) ;



Re: Transactions when using SPARQL update

Posted by Andy Seaborne <an...@apache.org>.

On 18/02/18 19:16, Andrew U Frank wrote:
> I have read the discussion on transactions, especially the hint
> "Transactions are whatever the dataset provides - for TDB that's 
> multiple read-and-singlewriter (MR+SW) all at the same time. " (by andy 
> ssaborne).
> 
> i use TDB but store data using the SPARQL update functions (INSERT DATA 
> especially). is it correct that each such SPARQL http call is a 
> transaction on the TDB database?

Yes

Every Fuseki request is a transaction - the request is to a TDB dataset, 
the TDB transaction mechanism is used.

     Andy

> 
> thank you for a very powerful tool!
> andrew

Re: Transactions when using SPARQL update

Posted by Andrew U Frank <fr...@geoinfo.tuwien.ac.at>.
I have read the discussion on transactions, especially the hint
"Transactions are whatever the dataset provides - for TDB that's 
multiple read-and-singlewriter (MR+SW) all at the same time. " (by andy 
ssaborne).

i use TDB but store data using the SPARQL update functions (INSERT DATA 
especially). is it correct that each such SPARQL http call is a 
transaction on the TDB database?

thank you for a very powerful tool!
andrew

Re: Transactions on RDFConnection

Posted by Andy Seaborne <an...@apache.org>.

On 12/01/18 11:37, George News wrote:
> Hi,
> 
> I would like to know how transactions are handle over an RDFConnection
> to a local dataset.

Jena ships with source code.

You can read the source code and/or write a little app and trace its 
execution.

> When using directly the dataset, you pointed that it doesn't matter if
> you user a static instance or not for storing the dataset, as Txn
> internally manages and handle everything. In this sense you recommended
> using a static instance. Is it the same for RDFConnection or are
> transactions linked to the instance?

RDFConnectionLocal uses Txn on the dataset it is wrapping.

It depends on the dataset, not the RDFConenction which is pure code (and 
an unused member).

> The issue here is if 1) and 2) behaves similarly when multitheaded calls
> to Txn are done. Are both methods blocking access to the dataset? Or is
> case 1) only blocking on the instance of the connection and multiple
> simultaneous call will led to error?

Transactions are whatever the dataset provides - for TDB that's multiple 
read-and-singlewriter (MR+SW) all at the same time.

> 
> Thanks for your help
> Jorge
> 
> 1) Per call connection
> try ( RDFConnection conn = RDFConnectionFactory.connect(...) ) {
>      Txn.execWrite(conn, ()-> {
> 	// Whatever
>      }) ;
> }
> 
> 2) Static instance
> 
> public static RDFConnection conn = RDFConnectionFactory.connect(...);
> 
> // ....
> 
> // In a method
> Txn.execWrite(conn, ()-> {
>     // Whatever
> }) ;
> 
>