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

knightni
153
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.

link

answered 12 Dec '12, 14:08

AndyS's gravatar image

AndyS ♦
13.3k37
accept rate: 32%

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

By RSS:

Answers

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

Tags:

×62
×19

Asked: 08 Dec '12, 11:56

Seen: 962 times

Last updated: 13 Dec '12, 03:52