Package org.eclipse.rdf4j.sail.memory
Class MemorySailStore.MemorySailSink
- java.lang.Object
-
- org.eclipse.rdf4j.sail.memory.MemorySailStore.MemorySailSink
-
- All Implemented Interfaces:
java.lang.AutoCloseable,SailClosable,SailSink
- Enclosing class:
- MemorySailStore
private final class MemorySailStore.MemorySailSink extends java.lang.Object implements SailSink
-
-
Field Summary
Fields Modifier and Type Field Description private booleanclosedprivate booleanexplicitprivate intnextSnapshotprivate java.util.Set<StatementPattern>observationsprivate booleanrequireCleanupprivate MemorySailStore.SnapshotMonitor.ReservedSnapshotreservedSnapshotprivate intserializableprivate booleantxnLock
-
Constructor Summary
Constructors Constructor Description MemorySailSink(boolean explicit, boolean serializable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidacquireExclusiveTransactionLock()private MemStatementaddStatement(Resource subj, IRI pred, Value obj, Resource context, boolean explicit)voidapprove(Resource subj, IRI pred, Value obj, Resource ctx)Adds a statement to the store.voidapproveAll(java.util.Set<Statement> approved, java.util.Set<Resource> approvedContexts)voidclear(Resource... contexts)Removes all statements from the specified/all contexts.voidclearNamespaces()Removes all namespace declarations from thisSailSource.voidclose()Closes this resource, relinquishing any underlying resources.voiddeprecate(Statement statement)Removes a statement.voiddeprecateAll(java.util.Set<Statement> deprecated)booleandeprecateByQuery(Resource subj, IRI pred, Value obj, Resource[] contexts)Removes all statements with the specified subject, predicate, object, and context.voidflush()Once this method returns successfully, changes that were made to thisSailSinkwill be visible to subsequentSailSource.dataset(IsolationLevel).private MemStatementListgetSmallestMemStatementList(MemResource memSubj, MemIRI memPred, MemValue memObj, MemResource memContext)private voidinnerDeprecate(Statement statement, int nextSnapshot)voidobserve(Resource subj, IRI pred, Value obj, Resource... contexts)Called to indicate matching statements have been observed and must not change their state until after thisSailSinkis committed, iff this was opened in an isolation level compatible withIsolationLevels.SERIALIZABLE.voidprepare()Checks if thisSailSinkis consistent with the isolation level it was created with.private voidreleaseLock()voidremoveNamespace(java.lang.String prefix)Removes a namespace declaration by removing the association between a prefix and a namespace name.voidsetNamespace(java.lang.String prefix, java.lang.String name)Sets the prefix for a namespace.private booleanstatementAlreadyExists(boolean explicit, MemResource memSubj, MemIRI memPred, MemValue memObj, MemResource memContext, int nextSnapshot)java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.rdf4j.sail.base.SailSink
approve, deprecate, observe, observeAll, supportsDeprecateByQuery
-
-
-
-
Field Detail
-
closed
private volatile boolean closed
-
explicit
private final boolean explicit
-
serializable
private final int serializable
-
reservedSnapshot
private final MemorySailStore.SnapshotMonitor.ReservedSnapshot reservedSnapshot
-
nextSnapshot
private int nextSnapshot
-
observations
private java.util.Set<StatementPattern> observations
-
txnLock
private volatile boolean txnLock
-
requireCleanup
private boolean requireCleanup
-
-
Constructor Detail
-
MemorySailSink
public MemorySailSink(boolean explicit, boolean serializable) throws SailException- Throws:
SailException
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
prepare
public void prepare() throws SailExceptionDescription copied from interface:SailSinkChecks if thisSailSinkis consistent with the isolation level it was created with. If this Sink was created with aIsolationLevels.SERIALIZABLEand another conflictingSailSinkhas already beenSailSink.flush()ed, this method will throw aSailConflictException.- Specified by:
preparein interfaceSailSink- Throws:
SailException
-
flush
public void flush() throws SailExceptionDescription copied from interface:SailSinkOnce this method returns successfully, changes that were made to thisSailSinkwill be visible to subsequentSailSource.dataset(IsolationLevel).- Specified by:
flushin interfaceSailSink- Throws:
SailException
-
close
public void close()
Description copied from interface:SailClosableCloses this resource, relinquishing any underlying resources.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceSailClosable
-
releaseLock
private void releaseLock()
-
setNamespace
public void setNamespace(java.lang.String prefix, java.lang.String name)Description copied from interface:SailSinkSets the prefix for a namespace.- Specified by:
setNamespacein 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:SailSinkRemoves a namespace declaration by removing the association between a prefix and a namespace name.- Specified by:
removeNamespacein interfaceSailSink- Parameters:
prefix- The namespace prefix, or an empty string in case of the default namespace.
-
clearNamespaces
public void clearNamespaces()
Description copied from interface:SailSinkRemoves all namespace declarations from thisSailSource.- Specified by:
clearNamespacesin interfaceSailSink
-
observe
public void observe(Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException
Description copied from interface:SailSinkCalled to indicate matching statements have been observed and must not change their state until after thisSailSinkis committed, iff this was opened in an isolation level compatible withIsolationLevels.SERIALIZABLE.- Specified by:
observein 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:
SailException- If the triple source failed to observe these statements.
-
clear
public void clear(Resource... contexts)
Description copied from interface:SailSinkRemoves all statements from the specified/all contexts. If no contexts are specified the method operates on the entire repository.- Specified by:
clearin 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(Resource subj, IRI pred, Value obj, Resource ctx)
Description copied from interface:SailSinkAdds a statement to the store.
-
approveAll
public void approveAll(java.util.Set<Statement> approved, java.util.Set<Resource> approvedContexts)
- Specified by:
approveAllin interfaceSailSink
-
deprecateAll
public void deprecateAll(java.util.Set<Statement> deprecated)
- Specified by:
deprecateAllin interfaceSailSink
-
deprecate
public void deprecate(Statement statement) throws SailException
Description copied from interface:SailSinkRemoves a statement.- Specified by:
deprecatein interfaceSailSink- Parameters:
statement- The statement that should be removed- Throws:
SailException- If the statement could not be removed, for example because no transaction is active.
-
innerDeprecate
private void innerDeprecate(Statement statement, int nextSnapshot)
-
acquireExclusiveTransactionLock
private void acquireExclusiveTransactionLock() throws SailException- Throws:
SailException
-
addStatement
private MemStatement addStatement(Resource subj, IRI pred, Value obj, Resource context, boolean explicit) throws SailException, java.lang.InterruptedException
- Throws:
SailExceptionjava.lang.InterruptedException
-
statementAlreadyExists
private boolean statementAlreadyExists(boolean explicit, MemResource memSubj, MemIRI memPred, MemValue memObj, MemResource memContext, int nextSnapshot) throws java.lang.InterruptedException- Throws:
java.lang.InterruptedException
-
getSmallestMemStatementList
private MemStatementList getSmallestMemStatementList(MemResource memSubj, MemIRI memPred, MemValue memObj, MemResource memContext)
-
deprecateByQuery
public boolean deprecateByQuery(Resource subj, IRI pred, Value obj, Resource[] contexts)
Description copied from interface:SailSinkRemoves all statements with the specified subject, predicate, object, and context. All four parameters may be null.- Specified by:
deprecateByQueryin interfaceSailSink
-
-