Dataquay::Connection Class Reference
Connection provides a connection interface to TransactionalStore, allowing it to be used in a convenient manner familiar to programmers working with SQL databases. More...
#include <dataquay/Connection.h>

Public Slots | |
| void | commit () |
| Commit the outstanding Transaction, if any. | |
| ChangeSet | commitAndObtain () |
| Commit the outstanding Transaction, if any, and return the changes committed. | |
| void | rollback () |
| Roll back the outstanding Transaction, if any, and prepare to begin a new Transaction the next time a modifying function is called. | |
Signals | |
| void | transactionCommitted (const ChangeSet &) |
| Forwarded from TransactionalStore. | |
| void | transactionCommitted () |
| Forwarded from TransactionalStore. | |
Public Member Functions | |
| Connection (TransactionalStore *ts) | |
| Construct a Connection to the given TransactionalStore, through which a series of transactions may be made in a single processing thread. | |
| ~Connection () | |
| Destroy the Connection, first committing any outstanding transaction. | |
| 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. | |
| Uri | getUniqueUri (QString prefix) const |
| Get a new URI, starting with the given prefix (e.g. | |
| Node | addBlankNode () |
| Create and return a new blank node. | |
| Uri | expand (QString uri) const |
| Expand the given URI (which may use local namespaces) and prefix-expand it, returning the result as a Uri. | |
| void | save (QString filename) const |
| Export the store to an RDF/TTL file with the given filename. | |
Detailed Description
Connection provides a connection interface to TransactionalStore, allowing it to be used in a convenient manner familiar to programmers working with SQL databases.
Each processing thread may construct a Connection to a central TransactionalStore. The Connection will start a new Transaction on the store when the first modifying function (add, remove, change or revert) is called and will continue to use this Transaction for all accesses to the store until either commit() or rollback() is called on the Connection.
Any read-only functions called on this class between a commit() or rollback() and the next modifying function will be passed directly to the store without any transaction. Read-only functions called while a transaction is in progress will be passed through the current transaction, and so will read the effective state of the store with the partial transaction in force.
The Connection commits any active Transaction when it is deleted. To avoid this, call rollback() before deletion. No other auto-commit functionality is provided -- if you want auto-commit, use the TransactionalStore's own interface in AutoTransaction mode.
Each Connection should be used in a single processing thread only. Connection is not thread-safe.
Definition at line 74 of file Connection.h.
Constructor & Destructor Documentation
| Dataquay::Connection::Connection | ( | TransactionalStore * | ts | ) |
Construct a Connection to the given TransactionalStore, through which a series of transactions may be made in a single processing thread.
Definition at line 215 of file Connection.cpp.
References transactionCommitted().
| Dataquay::Connection::~Connection | ( | ) |
Destroy the Connection, first committing any outstanding transaction.
If you do not want any outstanding transaction to be committed, call rollback() first.
Definition at line 225 of file Connection.cpp.
Member Function Documentation
| bool Dataquay::Connection::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. (Dataquay does not permit duplicate triples in a store.) Throw RDFException if the triple can not be added for some other reason.
Implements Dataquay::Store.
Definition at line 231 of file Connection.cpp.
| bool Dataquay::Connection::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 237 of file Connection.cpp.
| void Dataquay::Connection::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 243 of file Connection.cpp.
| void Dataquay::Connection::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 249 of file Connection.cpp.
| bool Dataquay::Connection::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 255 of file Connection.cpp.
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 261 of file Connection.cpp.
| ResultSet Dataquay::Connection::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 267 of file Connection.cpp.
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 273 of file Connection.cpp.
| Node Dataquay::Connection::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 279 of file Connection.cpp.
| Uri Dataquay::Connection::getUniqueUri | ( | QString | prefix | ) | const [virtual] |
Get a new URI, starting with the given prefix (e.g.
":event_"), that does not currently exist within this store. The URI will be prefix expanded.
Implements Dataquay::Store.
Definition at line 285 of file Connection.cpp.
| Node Dataquay::Connection::addBlankNode | ( | ) | [virtual] |
Create and return a new blank node.
This node can only be referred to using the given Node object, and only during its lifetime within this instance of the store.
Implements Dataquay::Store.
Definition at line 291 of file Connection.cpp.
| Uri Dataquay::Connection::expand | ( | QString | uri | ) | const [virtual] |
Expand the given URI (which may use local namespaces) and prefix-expand it, returning the result as a Uri.
(The Uri class cannot be used to store URIs that have unexpanded namespace prefixes.)
The set of available prefixes for expansion depends on the subclass implementation. See, for example, BasicStore::addPrefix.
Implements Dataquay::Store.
Definition at line 297 of file Connection.cpp.
| void Dataquay::Connection::save | ( | QString | filename | ) | const [virtual] |
Export the store to an RDF/TTL file with the given filename.
If the file already exists, it will if possible be overwritten.
Implements Dataquay::Store.
Definition at line 303 of file Connection.cpp.
| void Dataquay::Connection::commit | ( | ) | [slot] |
Commit the outstanding Transaction, if any.
Definition at line 309 of file Connection.cpp.
| ChangeSet Dataquay::Connection::commitAndObtain | ( | ) | [slot] |
Commit the outstanding Transaction, if any, and return the changes committed.
Definition at line 315 of file Connection.cpp.
| void Dataquay::Connection::rollback | ( | ) | [slot] |
Roll back the outstanding Transaction, if any, and prepare to begin a new Transaction the next time a modifying function is called.
Definition at line 321 of file Connection.cpp.
| void Dataquay::Connection::transactionCommitted | ( | const ChangeSet & | ) | [signal] |
Forwarded from TransactionalStore.
| void Dataquay::Connection::transactionCommitted | ( | ) | [signal] |
Forwarded from TransactionalStore.
Referenced by Connection().
The documentation for this class was generated from the following files:
Generated on Thu May 17 22:54:21 2012 for Dataquay by
1.6.3