public abstract class ForwardingTripleTransaction extends ForwardingObject implements TripleTransaction
This class provides a starting point for implementing the decorator pattern on top of the
TripleTransaction interface. Subclasses must implement method delegate()
and
override the methods of TripleTransaction they want to decorate.
Constructor and Description |
---|
ForwardingTripleTransaction() |
Modifier and Type | Method and Description |
---|---|
void |
add(Iterable<? extends org.openrdf.model.Statement> statements)
Adds all the RDF statements in the
Iterable specified to the triple store. |
protected abstract TripleTransaction |
delegate() |
void |
end(boolean commit)
Ends the transaction, either committing or rolling back its changes (if any).
|
info.aduna.iteration.CloseableIteration<? extends org.openrdf.model.Statement,? extends Exception> |
get(org.openrdf.model.Resource subject,
org.openrdf.model.URI predicate,
org.openrdf.model.Value object,
org.openrdf.model.Resource context)
Returns a Sesame
CloseableIteration over all the RDF statements matching the
(optional) subject, predicate, object, context supplied. |
void |
infer(Handler<? super org.openrdf.model.Statement> handler)
Performs inference, materializing the logical closure of the RDF statements contained in
the triple store.
|
info.aduna.iteration.CloseableIteration<org.openrdf.query.BindingSet,org.openrdf.query.QueryEvaluationException> |
query(SelectQuery query,
org.openrdf.query.BindingSet bindings,
Long timeout)
Evaluates the supplied SPARQL SELECT query, returning a Sesame
CloseableIteration
over its solutions. |
void |
remove(Iterable<? extends org.openrdf.model.Statement> statements)
Removes all the RDF statements in the
Iterable specified from the triple store. |
toString
protected abstract TripleTransaction delegate()
delegate
in class ForwardingObject
public info.aduna.iteration.CloseableIteration<? extends org.openrdf.model.Statement,? extends Exception> get(@Nullable org.openrdf.model.Resource subject, @Nullable org.openrdf.model.URI predicate, @Nullable org.openrdf.model.Value object, @Nullable org.openrdf.model.Resource context) throws IOException, IllegalStateException
TripleTransaction
CloseableIteration
over all the RDF statements matching the
(optional) subject, predicate, object, context supplied. Null values are used as wildcard.
Implementations are designed to perform high throughput statement extraction (likely more
efficient than doing a SPARQL query).get
in interface TripleTransaction
subject
- the subject to match, null to match any subjectpredicate
- the predicate to match, null to match any predicateobject
- the object to match, null to match any objectcontext
- the context to match, null to match any contextIOException
- in case some IO error occursIllegalStateException
- if the TripleTransaction
has been already endedpublic info.aduna.iteration.CloseableIteration<org.openrdf.query.BindingSet,org.openrdf.query.QueryEvaluationException> query(SelectQuery query, @Nullable org.openrdf.query.BindingSet bindings, @Nullable Long timeout) throws IOException, UnsupportedOperationException
TripleTransaction
CloseableIteration
over its solutions. The method accepts an optional BindingSet object, providing
bindings for variables in the query; it can be used to instantiate parametric queries,
similarly to PreparedStatements in JDBC.query
in interface TripleTransaction
query
- the SPARQL SELECT query to evaluatebindings
- optional bindings for variables in the query;timeout
- optional timeout in milliseconds for the queryIOException
- in case some IO error occursUnsupportedOperationException
- in case the query, while being valid according to SPARQL, uses a construct,
function or feature that is not supported by the triple store implementation
(refer to the implementation documentation for unsupported features)public void infer(@Nullable Handler<? super org.openrdf.model.Statement> handler) throws IOException, IllegalStateException
TripleTransaction
Handler
inferred statements can be
notified to, allowing for their additional processing by external code.infer
in interface TripleTransaction
handler
- an optional handler inferred RDF statements can be notified toIOException
- in case some IO error occurs, with no guarantee that the TripleStore
is
left in the same state if was when the method was called; note that this
exception may trigger a rollback on the caller sideIllegalStateException
- if the TripleTransaction
has been already ended, or if it is read-onlypublic void add(Iterable<? extends org.openrdf.model.Statement> statements) throws IOException, IllegalStateException
TripleTransaction
Iterable
specified to the triple store.
Implementations are designed to perform high throughput insertion. They are also allowed to
buffer part or all of the operation, successfully returning before specified triples have
been completely modified; in this case, it must be however guaranteed that subsequent calls
to #query(SelectQuery, BindingSet)
will 'see' all the triples added.add
in interface TripleTransaction
statements
- the statements to addIOException
- in case some IO error occurs, with no guarantee that the TripleStore
is
left in the same state if was when the method was called; note that this
exception may trigger a rollback on the caller sideIllegalStateException
- if the TripleTransaction
has been already ended, or if it is read-onlypublic void remove(Iterable<? extends org.openrdf.model.Statement> statements) throws IOException, IllegalStateException
TripleTransaction
Iterable
specified from the triple store.
Implementations are designed to perform high throughput deletion. They are also allowed to
return before specified triples have been completely removed; in this case, it must be
however guaranteed that subsequent calls to #query(SelectQuery, BindingSet)
will
not 'see' any of the triples removed.remove
in interface TripleTransaction
statements
- the statements to removeIOException
- in case some IO error occurs, with no guarantee that the TripleStore
is
left in the same state if was when the method was called; note that this
exception may trigger a rollback on the caller sideIllegalStateException
- if the TripleTransaction
has been already ended, or if it is read-onlypublic void end(boolean commit) throws IOException
TripleTransaction
IOException
is thrown. If it is not possible either to
commit or rollback, then the TripleStore
is possibly left in an unknown state and a
DataCorruptedException
is thrown to signal a data corruption situation that cannot
be automatically recovered (apart from calling TripleStore.reset()
and repopulating
the TripleStore
).end
in interface TripleTransaction
commit
- true in case changes made by the transaction should be committedIOException
- in case some IO error occurs or the commit request cannot be satisfied for any
reason; it is however guaranteed that a forced rollback has been performedDataCorruptedException
- in case it was not possible either to commit or rollback, which implies the
state of the TripleStore
is unknown and automatic recovery is not
possible (hence, data is corrupted)Copyright © 2015–2016 FBK-irst. All rights reserved.