Package org.eclipse.rdf4j.sail.base
Class Changeset
- java.lang.Object
-
- org.eclipse.rdf4j.sail.base.Changeset
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,ModelFactory
,SailClosable
,SailSink
@InternalUseOnly public abstract class Changeset extends java.lang.Object implements SailSink, ModelFactory
Set of changes applied to anSailSourceBranch
awaiting to be flushed into its backingSailSource
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Changeset.AdderBasedReadWriteLock
static class
Changeset.SimpleStatementPattern
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.String>
addedNamespaces
Additional namespaces added.private Model
approved
Statements that have been added as part of a transaction, but has not yet been committed.private java.util.Set<Resource>
approvedContexts
Set of contexts of theapproved
statements.private boolean
approvedEmpty
private boolean
closed
private Model
deprecated
Explicit statements that have been removed as part of a transaction, but have not yet been committed.private java.util.Set<Resource>
deprecatedContexts
Set of contexts that were passed toclear(Resource...)
.private boolean
deprecatedEmpty
private boolean
namespaceCleared
If all namespaces were removed, other thanaddedNamespaces
.private java.util.Set<Changeset.SimpleStatementPattern>
observed
When inIsolationLevels.SERIALIZABLE
this contains all the observedStatementPattern
s that were observed byObservingSailDataset
.private java.util.Set<Changeset>
prepend
Changeset
s that have beenSailSink.flush()
ed to the sameSailSourceBranch
, since this object wasSailSink.flush()
ed.(package private) java.util.concurrent.Semaphore
prependLock
(package private) Changeset.AdderBasedReadWriteLock
readWriteLock
private java.util.List<SailDatasetImpl>
refbacks
(package private) Changeset.AdderBasedReadWriteLock
refBacksReadWriteLock
private java.util.Set<java.lang.String>
removedPrefixes
Namespace prefixes that were removed.private boolean
statementCleared
If all statements were removed, other thanapproved
.
-
Constructor Summary
Constructors Constructor Description Changeset()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addRefback(SailDatasetImpl dataset)
void
approve(Resource subj, IRI pred, Value obj, Resource ctx)
Adds a statement to the store.void
approve(Statement statement)
Adds a statement to the store.void
approveAll(java.util.Set<Statement> approve, java.util.Set<Resource> approveContexts)
void
clear(Resource... contexts)
Removes all statements from the specified/all contexts.void
clearNamespaces()
Removes all namespace declarations from thisSailSource
.private <T> java.util.Set<T>
cloneSet(java.util.Set<T> set)
void
close()
Closes this resource, relinquishing any underlying resources.void
deprecate(Statement statement)
Removes a statement.void
deprecateAll(java.util.Set<Statement> deprecate)
java.util.Map<java.lang.String,java.lang.String>
getAddedNamespaces()
java.util.Set<Resource>
getApprovedContexts()
(package private) java.util.List<Statement>
getApprovedStatements()
(package private) java.lang.Iterable<Statement>
getApprovedStatements(Resource subj, IRI pred, Value obj, Resource[] contexts)
(package private) java.lang.Iterable<Triple>
getApprovedTriples(Resource subj, IRI pred, Value obj)
java.util.Set<Resource>
getDeprecatedContexts()
(package private) java.util.List<Statement>
getDeprecatedStatements()
java.util.Set<StatementPattern>
getObservations()
Deprecated.Use getObserved() instead!java.util.Set<Changeset.SimpleStatementPattern>
getObserved()
java.util.Set<java.lang.String>
getRemovedPrefixes()
(package private) boolean
hasApproved()
(package private) boolean
hasApproved(Resource subj, IRI pred, Value obj, Resource[] contexts)
boolean
hasDeprecated()
(package private) boolean
hasDeprecated(Resource subj, IRI pred, Value obj, Resource[] contexts)
(package private) boolean
hasDeprecated(Statement statement)
(package private) boolean
isChanged()
boolean
isNamespaceCleared()
boolean
isRefback()
boolean
isStatementCleared()
void
observe(Resource subj, IRI pred, Value obj, Resource context)
Called to indicate matching statements have been observed and must not change their state until after thisSailSink
is committed, iff this was opened in an isolation level compatible withIsolationLevels.SERIALIZABLE
.void
observe(Resource subj, IRI pred, Value obj, Resource... contexts)
Called to indicate matching statements have been observed and must not change their state until after thisSailSink
is committed, iff this was opened in an isolation level compatible withIsolationLevels.SERIALIZABLE
.void
observeAll(java.util.Set<Changeset.SimpleStatementPattern> observed)
void
prepare()
Checks if thisSailSink
is consistent with the isolation level it was created with.void
prepend(Changeset changeset)
(package private) void
removeApproved(Statement next)
void
removeNamespace(java.lang.String prefix)
Removes a namespace declaration by removing the association between a prefix and a namespace name.void
removeRefback(SailDatasetImpl dataset)
protected void
setChangeset(Changeset from)
void
setNamespace(java.lang.String prefix, java.lang.String name)
Sets the prefix for a namespace.Changeset
shallowClone()
Create a shallow clone of this Changeset.(package private) void
sinkApproved(SailSink sink)
(package private) void
sinkDeprecated(SailSink sink)
void
sinkObserved(SailSink sink)
java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.rdf4j.model.ModelFactory
createEmptyModel
-
Methods inherited from interface org.eclipse.rdf4j.sail.base.SailSink
deprecate, deprecateByQuery, flush, supportsDeprecateByQuery
-
-
-
-
Field Detail
-
readWriteLock
Changeset.AdderBasedReadWriteLock readWriteLock
-
refBacksReadWriteLock
Changeset.AdderBasedReadWriteLock refBacksReadWriteLock
-
prependLock
java.util.concurrent.Semaphore prependLock
-
refbacks
private java.util.List<SailDatasetImpl> refbacks
-
prepend
private java.util.Set<Changeset> prepend
Changeset
s that have beenSailSink.flush()
ed to the sameSailSourceBranch
, since this object wasSailSink.flush()
ed.
-
observed
private volatile java.util.Set<Changeset.SimpleStatementPattern> observed
When inIsolationLevels.SERIALIZABLE
this contains all the observedStatementPattern
s that were observed byObservingSailDataset
.
-
approved
private volatile Model approved
Statements that have been added as part of a transaction, but has not yet been committed.DO NOT EXPOSE THE MODEL OUTSIDE OF THIS CLASS BECAUSE IT IS NOT THREAD-SAFE
-
approvedEmpty
private volatile boolean approvedEmpty
-
deprecated
private volatile Model deprecated
Explicit statements that have been removed as part of a transaction, but have not yet been committed.DO NOT EXPOSE THE MODEL OUTSIDE OF THIS CLASS BECAUSE IT IS NOT THREAD-SAFE
-
deprecatedEmpty
private volatile boolean deprecatedEmpty
-
approvedContexts
private java.util.Set<Resource> approvedContexts
Set of contexts of theapproved
statements.
-
deprecatedContexts
private volatile java.util.Set<Resource> deprecatedContexts
Set of contexts that were passed toclear(Resource...)
.
-
addedNamespaces
private java.util.Map<java.lang.String,java.lang.String> addedNamespaces
Additional namespaces added.
-
removedPrefixes
private java.util.Set<java.lang.String> removedPrefixes
Namespace prefixes that were removed.
-
namespaceCleared
private volatile boolean namespaceCleared
If all namespaces were removed, other thanaddedNamespaces
.
-
statementCleared
private volatile boolean statementCleared
If all statements were removed, other thanapproved
.
-
closed
private boolean closed
-
-
Method Detail
-
close
public void close() throws SailException
Description copied from interface:SailClosable
Closes this resource, relinquishing any underlying resources.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceSailClosable
- Throws:
SailException
- if this resource cannot be closed
-
prepare
public void prepare() throws SailException
Description copied from interface:SailSink
Checks if thisSailSink
is consistent with the isolation level it was created with. If this Sink was created with aIsolationLevels.SERIALIZABLE
and another conflictingSailSink
has already beenSailSink.flush()
ed, this method will throw aSailConflictException
.- Specified by:
prepare
in interfaceSailSink
- Throws:
SailException
-
addRefback
public void addRefback(SailDatasetImpl dataset)
-
removeRefback
public void removeRefback(SailDatasetImpl dataset)
-
isRefback
public boolean isRefback()
-
prepend
public void prepend(Changeset changeset)
-
setNamespace
public void setNamespace(java.lang.String prefix, java.lang.String name)
Description copied from interface:SailSink
Sets the prefix for a namespace.- Specified by:
setNamespace
in interfaceSailSink
- Parameters:
prefix
- The new prefix, or an empty string in case of the default namespace.name
- The namespace name that the prefix maps to.
-
removeNamespace
public void removeNamespace(java.lang.String prefix)
Description copied from interface:SailSink
Removes a namespace declaration by removing the association between a prefix and a namespace name.- Specified by:
removeNamespace
in interfaceSailSink
- Parameters:
prefix
- The namespace prefix, or an empty string in case of the default namespace.
-
clearNamespaces
public void clearNamespaces()
Description copied from interface:SailSink
Removes all namespace declarations from thisSailSource
.- Specified by:
clearNamespaces
in interfaceSailSink
-
observe
public void observe(Resource subj, IRI pred, Value obj, Resource... contexts) throws SailConflictException
Description copied from interface:SailSink
Called to indicate matching statements have been observed and must not change their state until after thisSailSink
is committed, iff this was opened in an isolation level compatible withIsolationLevels.SERIALIZABLE
.- Specified by:
observe
in interfaceSailSink
- Parameters:
subj
- A Resource specifying the subject, or null for a wildcard.pred
- A IRI specifying the predicate, or null for a wildcard.obj
- A Value specifying the object, or null for a wildcard.contexts
- The context(s) of the observed statements. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on all contexts.- Throws:
SailConflictException
-
observe
public void observe(Resource subj, IRI pred, Value obj, Resource context) throws SailConflictException
Description copied from interface:SailSink
Called to indicate matching statements have been observed and must not change their state until after thisSailSink
is committed, iff this was opened in an isolation level compatible withIsolationLevels.SERIALIZABLE
.- Specified by:
observe
in interfaceSailSink
- Parameters:
subj
- A Resource specifying the subject, or null for a wildcard.pred
- A IRI specifying the predicate, or null for a wildcard.obj
- A Value specifying the object, or null for a wildcard.context
- The context of the observed statements.- Throws:
SailConflictException
-
observeAll
public void observeAll(java.util.Set<Changeset.SimpleStatementPattern> observed)
- Specified by:
observeAll
in interfaceSailSink
-
clear
public void clear(Resource... contexts)
Description copied from interface:SailSink
Removes all statements from the specified/all contexts. If no contexts are specified the method operates on the entire repository.- Specified by:
clear
in interfaceSailSink
- Parameters:
contexts
- The context(s) from which to remove the statements. Note that this parameter is a vararg and as such is optional. If no contexts are specified the method operates on the entire repository. A null value can be used to match context-less statements.
-
approve
public void approve(Statement statement)
Description copied from interface:SailSink
Adds a statement to the store.
-
approve
public void approve(Resource subj, IRI pred, Value obj, Resource ctx) throws SailException
Description copied from interface:SailSink
Adds a statement to the store.- Specified by:
approve
in interfaceSailSink
- Parameters:
subj
- The subject of the statement to add.pred
- The predicate of the statement to add.obj
- The object of the statement to add.ctx
- The context to add the statement to.- Throws:
SailException
- If the statement could not be added, for example because no transaction is active.
-
deprecate
public void deprecate(Statement statement)
Description copied from interface:SailSink
Removes a statement.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
setChangeset
protected void setChangeset(Changeset from)
-
shallowClone
public Changeset shallowClone()
Create a shallow clone of this Changeset. The shallow clone does not clone the underlying data structures, this means that any changes made to the original will potentially be reflected in the clone and vice versa.- Returns:
- a new Changeset that is a shallow clone of the current Changeset.
-
getObserved
public java.util.Set<Changeset.SimpleStatementPattern> getObserved()
-
getObservations
@Deprecated public java.util.Set<StatementPattern> getObservations()
Deprecated.Use getObserved() instead!
-
getApprovedContexts
public java.util.Set<Resource> getApprovedContexts()
-
getDeprecatedContexts
public java.util.Set<Resource> getDeprecatedContexts()
-
isStatementCleared
public boolean isStatementCleared()
-
getAddedNamespaces
public java.util.Map<java.lang.String,java.lang.String> getAddedNamespaces()
-
getRemovedPrefixes
public java.util.Set<java.lang.String> getRemovedPrefixes()
-
isNamespaceCleared
public boolean isNamespaceCleared()
-
hasDeprecated
public boolean hasDeprecated()
-
isChanged
boolean isChanged()
-
getDeprecatedStatements
java.util.List<Statement> getDeprecatedStatements()
-
getApprovedStatements
java.util.List<Statement> getApprovedStatements()
-
hasDeprecated
boolean hasDeprecated(Statement statement)
-
hasApproved
boolean hasApproved()
-
getApprovedStatements
java.lang.Iterable<Statement> getApprovedStatements(Resource subj, IRI pred, Value obj, Resource[] contexts)
-
getApprovedTriples
java.lang.Iterable<Triple> getApprovedTriples(Resource subj, IRI pred, Value obj)
-
removeApproved
void removeApproved(Statement next)
-
cloneSet
private <T> java.util.Set<T> cloneSet(java.util.Set<T> set)
-
sinkApproved
void sinkApproved(SailSink sink)
-
sinkDeprecated
void sinkDeprecated(SailSink sink)
-
sinkObserved
public void sinkObserved(SailSink sink)
-
approveAll
public void approveAll(java.util.Set<Statement> approve, java.util.Set<Resource> approveContexts)
- Specified by:
approveAll
in interfaceSailSink
-
deprecateAll
public void deprecateAll(java.util.Set<Statement> deprecate)
- Specified by:
deprecateAll
in interfaceSailSink
-
-