Dataquay::TransactionalStore Class Reference

RDF data store implementing the Store interface, providing transaction support as a wrapper around a non-transactional store such as a BasicStore. More...

#include <dataquay/TransactionalStore.h>

Inherits Dataquay::Store.

List of all members.

Classes

class  TSTransaction

Public Types

enum  DirectWriteBehaviour { NoAutoTransaction, AutoTransaction }
 DirectWriteBehaviour controls how TransactionalStore responds when called directly (not through a Transaction) for a write operation (add, remove, change, or revert). More...

Signals

void transactionCommitted ()

Public Member Functions

 TransactionalStore (Store *store, DirectWriteBehaviour dwb=NoAutoTransaction)
 Create a TransactionalStore operating on the given (presumably non-transactional) data store.
 ~TransactionalStore ()
TransactionstartTransaction ()
 Start a transaction and obtain a Transaction through which to carry out its operations.
bool add (Triple t)
 Add a triple to the store.
bool remove (Triple t)
 Remove a triple from the store.
void change (ChangeSet changes)
 Atomically apply the sequence of add/remove changes described in the given ChangeSet.
void revert (ChangeSet changes)
 Atomically apply the sequence of add/remove changes described in the given ChangeSet, in reverse (ie removing adds and adding removes, in reverse order).
bool contains (Triple t) const
 Return true if the store contains the given triple, false otherwise.
Triples match (Triple t) const
 Return all triples matching the given wildcard triple.
ResultSet query (QString sparql) const
 Run a SPARQL query against the store and return its results.
Triple matchFirst (Triple t) const
 Return the first triple to match the given wildcard triple.
Node queryFirst (QString sparql, QString bindingName) const
 Run a SPARQL query against the store and return the node of the first result for the given query binding.
QUrl getUniqueUri (QString prefix) const
 Get a new URI, starting with the given prefix, that does not currently exist within this store.
QUrl expand (QString uri) const
 Expand the given URI (which may use local namespaces) and prefix-expand it, returning the result as a QUrl.


Detailed Description

RDF data store implementing the Store interface, providing transaction support as a wrapper around a non-transactional store such as a BasicStore.

Write access to the store is permitted only in the context of a transaction. If you call a modifying function directly on TransactionalStore, the store will either throw RDFException (if set to NoAutoTransaction) or create a single-use Transaction object for the duration of that modification (if set to AutoTransaction). Note that the latter behaviour will deadlock if a transaction is in progress already.

Read access may be carried out through a Transaction, in which case the read state will reflect the changes made so far in the pending transaction, or directly on the TransactionalStore, in which case the read will be isolated from any pending transaction.

Call startTransaction to obtain a new Transaction object and start its transaction; use the Transaction's Store interface for all accesses associated with that transaction; delete the Transaction object once done, to finish and commit the transaction; or call Transaction::rollback() if you decide you do not wish to commit it.

TransactionalStore is thread-safe.

Definition at line 70 of file TransactionalStore.h.


Member Enumeration Documentation

DirectWriteBehaviour controls how TransactionalStore responds when called directly (not through a Transaction) for a write operation (add, remove, change, or revert).

NoAutoTransaction (the default) means that an RDF exception will be thrown whenever a write is attempted without a transaction.

AutoTransaction means that a Transaction object will be created, used for the single access, and then closed. This may cause a deadlock if another transaction is already ongoing elsewhere.

Enumerator:
NoAutoTransaction 
AutoTransaction 

Definition at line 89 of file TransactionalStore.h.


Constructor & Destructor Documentation

Dataquay::TransactionalStore::TransactionalStore ( Store store,
DirectWriteBehaviour  dwb = NoAutoTransaction 
)

Create a TransactionalStore operating on the given (presumably non-transactional) data store.

Nothing in the code prevents the given _underlying_ store being used non-transactionally elsewhere at the same time. Don't do that: once you have set up a transactional store, you should use it for all routine accesses to the underlying store.

Definition at line 501 of file TransactionalStore.cpp.

Dataquay::TransactionalStore::~TransactionalStore (  ) 

Definition at line 506 of file TransactionalStore.cpp.


Member Function Documentation

Transaction * Dataquay::TransactionalStore::startTransaction (  ) 

Start a transaction and obtain a Transaction through which to carry out its operations.

Once the transaction is complete, you must delete the Transaction object to finish the transaction.

Definition at line 512 of file TransactionalStore.cpp.

Referenced by add(), change(), remove(), and revert().

bool Dataquay::TransactionalStore::add ( Triple  t  )  [virtual]

Add a triple to the store.

Prefix expansion is performed on URI nodes in the triple. Return false if the triple was already in the store. (Although Redland permits duplicate triples in a store, Dataquay doesn't.) Throw RDFException if the triple can not be added for some other reason.

Implements Dataquay::Store.

Definition at line 518 of file TransactionalStore.cpp.

References startTransaction().

bool Dataquay::TransactionalStore::remove ( Triple  t  )  [virtual]

Remove a triple from the store.

Prefix expansion is performed on URI nodes in the triple. If some nodes in the triple are Nothing nodes, remove all matching triples. Return false if no matching triple was found in the store. Throw RDFException if removal failed for some other reason.

Implements Dataquay::Store.

Definition at line 529 of file TransactionalStore.cpp.

References startTransaction().

void Dataquay::TransactionalStore::change ( ChangeSet  changes  )  [virtual]

Atomically apply the sequence of add/remove changes described in the given ChangeSet.

Throw RDFException if any operation fails for any reason (including duplication etc).

Implements Dataquay::Store.

Definition at line 539 of file TransactionalStore.cpp.

References startTransaction().

void Dataquay::TransactionalStore::revert ( ChangeSet  changes  )  [virtual]

Atomically apply the sequence of add/remove changes described in the given ChangeSet, in reverse (ie removing adds and adding removes, in reverse order).

Throw RDFException if any operation fails for any reason (including duplication etc).

Implements Dataquay::Store.

Definition at line 549 of file TransactionalStore.cpp.

References startTransaction().

bool Dataquay::TransactionalStore::contains ( Triple  t  )  const [virtual]

Return true if the store contains the given triple, false otherwise.

Prefix expansion is performed on URI nodes in the triple. Throw RDFException if the triple is not complete or if the test failed for any other reason.

Implements Dataquay::Store.

Definition at line 559 of file TransactionalStore.cpp.

Triples Dataquay::TransactionalStore::match ( Triple  t  )  const [virtual]

Return all triples matching the given wildcard triple.

A node of type Nothing in any part of the triple matches any node in the data store. Prefix expansion is performed on URI nodes in the triple. Return an empty list if there are no matches; may throw RDFException if matching fails in some other way.

Implements Dataquay::Store.

Definition at line 567 of file TransactionalStore.cpp.

ResultSet Dataquay::TransactionalStore::query ( QString  sparql  )  const [virtual]

Run a SPARQL query against the store and return its results.

Any prefixes added previously using addQueryPrefix will be available in this query without needing to be declared in the SPARQL given here (equivalent to writing "PREFIX prefix: <uri>" for each prefix,uri pair set with addPrefix).

May throw RDFException.

Note that the RDF store must have an absolute base URI (rather than the default "#") in order to perform queries, as relative URIs in the query will be interpreted relative to the query base rather than the store and without a proper base URI there is no way to override that internally.

Implements Dataquay::Store.

Definition at line 575 of file TransactionalStore.cpp.

Triple Dataquay::TransactionalStore::matchFirst ( Triple  t  )  const [virtual]

Return the first triple to match the given wildcard triple.

A node of type Nothing in any part of the triple matches any node in the data store. Prefix expansion is performed on URI nodes in the triple. Return an empty triple (three Nothing nodes) if there are no matches. May throw RDFException.

Implements Dataquay::Store.

Definition at line 583 of file TransactionalStore.cpp.

Node Dataquay::TransactionalStore::queryFirst ( QString  sparql,
QString  bindingName 
) const [virtual]

Run a SPARQL query against the store and return the node of the first result for the given query binding.

This is a shorthand for use with queries that are only expected to have one result. May throw RDFException.

Implements Dataquay::Store.

Definition at line 591 of file TransactionalStore.cpp.

QUrl Dataquay::TransactionalStore::getUniqueUri ( QString  prefix  )  const [virtual]

Get a new URI, starting with the given prefix, that does not currently exist within this store.

The URI will be prefix expanded.

Implements Dataquay::Store.

Definition at line 599 of file TransactionalStore.cpp.

QUrl Dataquay::TransactionalStore::expand ( QString  uri  )  const [virtual]

Expand the given URI (which may use local namespaces) and prefix-expand it, returning the result as a QUrl.

(The QUrl class is not suitable for storing URIs that use namespaces, particularly local ones.)

Implements Dataquay::Store.

Definition at line 607 of file TransactionalStore.cpp.

void Dataquay::TransactionalStore::transactionCommitted (  )  [signal]


The documentation for this class was generated from the following files:

Generated on Thu Sep 24 23:19:49 2009 for Dataquay by  doxygen 1.5.7.1