I've been reading through the Jena concurrency HOWTO ( http://jena.apache.org/documentation/notes/concurrency-howto.html ) and wanted to know a bit about how it applies to TDB and SDB.

Let's say I have two Models, MyJenaModel1 and MyJenaModel2. My understanding is that if these are memory models (collected together in a dataset, say), I need to ensure multiple reader or single writer access, or I'll run into issues. Presumably if I want to do a SPARQL query that could get data from either of the models, I also need to read lock them both.

My questions are about how this applies to TDB and SDB. In TDB, each thread creates its own dataset as below:

Dataset dataset = TDBFactory.createDataset(location) ;

If Thread1 and Thread2 each access MyJenaModel1 through their datasets, are the model objects I get back the same? I.E. do I need to ensure MRSW on the model, or is that unnecessary? My assumption is that I don't, given the content of the TDB transactions page, but I wanted to be sure.

The same question goes for SDB - if I use connectNamedModel to MyJenaModel1 in different threads, am I getting back different model objects, and thus free from having to enforce MRSW?

Finally, a slightly different question. If I have a set of operations that I want to perform inside one transaction that involves creating/deleting a bunch of different named graphs, what's the best way to do that in a running SDB system without doing separate writes for each named graph (and thus presumably having a lot of round trips to the DB)? Can I do this using SPARQL Update, or is it achievable using the bulk loader?

Thanks a lot for your time!

asked 08 Dec '12, 11:56

knightni's gravatar image

accept rate: 0%

edited 08 Dec '12, 11:58

For TDB and SDB, you need to manage any multithreaded concurrency within a transaction but if you are manipulating models in different transactions, the transactions take care of concurrency issues.

In SDB, SPARQL Update will be no more efficient than API calls but you can use the bulk loader.

It is normal to have one thread per transaction (and some databases insist on this so it affects SDB). It is often cleaner with one thread - one transaction.

permanent link

answered 12 Dec '12, 14:08

AndyS's gravatar image

AndyS ♦
accept rate: 33%

Thanks, that's very helpful!

(13 Dec '12, 03:52) knightni knightni's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 08 Dec '12, 11:56

question was seen: 978 times

last updated: 13 Dec '12, 03:52