public abstract class ForwardingDataTransaction extends ForwardingObject implements DataTransaction
DataTransaction
forwarding all its method calls to another DataTransaction
.
This class provides a starting point for implementing the decorator pattern on top of the
DataTransaction
interface. Subclasses must implement method delegate()
and
override the methods of DataTransaction
they want to decorate.
Constructor and Description |
---|
ForwardingDataTransaction() |
Modifier and Type | Method and Description |
---|---|
long |
count(org.openrdf.model.URI type,
XPath condition)
Counts the records having the type and matching the optional condition specified.
|
protected abstract DataTransaction |
delegate() |
void |
delete(org.openrdf.model.URI type,
org.openrdf.model.URI id)
Deletes the record stored in the
DataStore with the ID specified.A record may or
may not be stored for the specified ID; in case it exists, it is deleted by the operation. |
void |
end(boolean commit)
Ends the transaction, either committing or rolling back its changes (if any).
|
Stream<Record> |
lookup(org.openrdf.model.URI type,
Set<? extends org.openrdf.model.URI> ids,
Set<? extends org.openrdf.model.URI> properties)
Returns a stream of records having the type and IDs specified.
|
Stream<Record> |
match(Map<org.openrdf.model.URI,XPath> conditions,
Map<org.openrdf.model.URI,Set<org.openrdf.model.URI>> ids,
Map<org.openrdf.model.URI,Set<org.openrdf.model.URI>> properties)
Evaluates a
match request with the parameters supplied. |
Stream<Record> |
retrieve(org.openrdf.model.URI type,
XPath condition,
Set<? extends org.openrdf.model.URI> properties)
Returns a stream of records having the type and matching the optional condition specified.
|
void |
store(org.openrdf.model.URI type,
Record record)
Stores a record in the
DataStore . |
toString
protected abstract DataTransaction delegate()
delegate
in class ForwardingObject
public Stream<Record> lookup(org.openrdf.model.URI type, Set<? extends org.openrdf.model.URI> ids, @Nullable Set<? extends org.openrdf.model.URI> properties) throws IOException, IllegalArgumentException, IllegalStateException
DataTransaction
lookup
in interface DataTransaction
type
- the URI of the type of records to returnids
- a set with the IDs of the records to return, not to be modified by the methodproperties
- a set with the properties to return for matching records, not modified by the
method; if null, all the available properties must be returnedIOException
- in case some IO error occursIllegalArgumentException
- in case the type specified is not supportedIllegalStateException
- if the DataTransaction
has been already endedpublic Stream<Record> retrieve(org.openrdf.model.URI type, @Nullable XPath condition, @Nullable Set<? extends org.openrdf.model.URI> properties) throws IOException, IllegalArgumentException, IllegalStateException
DataTransaction
retrieve
in interface DataTransaction
type
- the URI of the type of records to returncondition
- an optional condition to be satisfied by matching records; if null, no condition
must be checkedproperties
- a set with the properties to return for matching records, not modified by the
method; if null, all the available properties must be returnedIOException
- in case some IO error occursIllegalArgumentException
- in case the type specified is not supportedIllegalStateException
- if the DataTransaction
has been already endedpublic long count(org.openrdf.model.URI type, @Nullable XPath condition) throws IOException, IllegalArgumentException, IllegalStateException
DataTransaction
DataTransaction.retrieve(URI, XPath, Set)
, but returns only the
number of matching instances instead of retrieving the corresponding Record
objects.count
in interface DataTransaction
type
- the URI of the type of records to returncondition
- an optional condition to be satisfied by matching records; if null, no condition
must be checkedIOException
- in case some IO error occursIllegalArgumentException
- in case the type specified is not supportedIllegalStateException
- if the DataTransaction
has been already endedpublic Stream<Record> match(Map<org.openrdf.model.URI,XPath> conditions, Map<org.openrdf.model.URI,Set<org.openrdf.model.URI>> ids, Map<org.openrdf.model.URI,Set<org.openrdf.model.URI>> properties) throws IOException, IllegalStateException
DataTransaction
match
request with the parameters supplied. The operation:
<resource, mention, entity, axiom>
such that
mention
KS.MENTION_OF
resource
;mention
KS.REFERS_TO
entity
(optional if no condition or
projection on entities);mention
KS.EXPRESSES
axiom
(optional if no condition or
projection on axioms).conditions
/ ids
selections
on resource, mention, entity and axiom components are satisfied.properties.keySet()
, returning for each component the
subset of properties of properties.get(component_type_URI)
.KS.RESOURCE
, KS.MENTION
, KS.ENTITY
and KS.AXIOM
.match
in interface DataTransaction
conditions
- a non-null map with optional component conditions, indexed by the component type
URI; note the map may be possibly empty or contain conditions only for a subset
of componentsids
- a non-null map with optional ID selections for different components, indexed by
the component type URI; note the map may be possibly empty or contain selections
only for a subset of componentsproperties
- a non-null, non-empty map with the properties to return for different
components, indexed by the component type URI; if the set of property URIs
mapped to a component is null or empty, then all the properties of the component
should be returned; if a component is not referenced in the map, then it must
not be returnedStream
of combination recordsIOException
- in case some IO error occursIllegalStateException
- if the DataTransaction
has been already endedpublic void store(org.openrdf.model.URI type, Record record) throws IOException, IllegalStateException
DataTransaction
DataStore
. A record may or may not exist for the same ID; in
case it exists, it is replaced by the newly specified record. In case the method call
returns successfully, there is no guarantee that the write operation completed (e.g.,
because of internal buffering); however, it is guaranteed (e.g., via internal flushing)
that read operations called subsequently will see the result of the modification. In case
the method call fails with an IOException
, there is no guarantee that the
DataStore
is left in the same state it was at the time of calling.store
in interface DataTransaction
type
- the URI of the type of record to store, not nullrecord
- the record to store, not nullIOException
- in case the operation failed, with no guarantee that the DataStore
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 DataTransaction
has been already ended, or if it is read-onlypublic void delete(org.openrdf.model.URI type, org.openrdf.model.URI id) throws IOException, IllegalStateException
DataTransaction
DataStore
with the ID specified.A record may or
may not be stored for the specified ID; in case it exists, it is deleted by the operation.
In case the method call returns successfully, there is no guarantee that the write
operation completed (e.g., because of internal buffering); however, it is guaranteed (e.g.,
via internal flushing) that read operations called subsequently will see the result of the
modification. In case the method call fails with an IOException
, there is no
guarantee that the DataStore
is left in the same state it was at the time of
calling.delete
in interface DataTransaction
type
- the URI of the type of record to store, not nullid
- the ID of the record to delete, not nullIOException
- in case the operation failed, with no guarantee that the DataStore
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 DataTransaction
has been already ended, or if it is read-onlypublic void end(boolean commit) throws IOException, IllegalStateException
DataTransaction
IOException
is thrown. If it is not possible either to
commit or rollback, then the DataStore
is possibly left in an unknown state and a
DataCorruptedException
is thrown to signal a data corruption situation that cannot
be automatically recovered.end
in interface DataTransaction
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 DataStore
is unknown and automatic recovery is not
possible (hence, data is corrupted)IllegalStateException
- if the DataTransaction
has been already endedCopyright © 2015–2016 FBK-irst. All rights reserved.