|
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! |
|
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. |

