Class SailSourceBranch
java.lang.Object
org.eclipse.rdf4j.sail.base.SailSourceBranch
- All Implemented Interfaces:
AutoCloseable, SailClosable, SailSource
An
SailSource that keeps a delta of its state from a backing SailSource.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanIf thisSailSourceshould be flushed to the backingSailSourcewhen it is not in use.private final SailSourceThe underlySailSourcethisSailSourceis derived from.private final ArrayDeque<Changeset> The difference between thisSailSourceand the backingSailSource.private static final org.slf4j.Loggerprivate final ModelFactoryTheModelinstances that should be used to storeSailSink.approve(Resource, IRI, Value, Resource)andSailSink.deprecate(Resource, IRI, Value, Resource)statements.private final Collection<SailDataset> Set of openSailDatasetfor thisSailSource.private SailSinkprivate final ReentrantLockUsed to prevent changes to this object's field from multiple threads.private SailSinkNon-null when inIsolationLevels.SERIALIZABLE(or higher) mode.private SailDatasetNon-null when inIsolationLevels.SNAPSHOT(or higher) mode. -
Constructor Summary
ConstructorsConstructorDescriptionSailSourceBranch(SailSource backingSource) Creates a new in-memorySailSourcederived from the givenSailSource.SailSourceBranch(SailSource backingSource, ModelFactory modelFactory) Creates a newSailSourcederived from the givenSailSource.SailSourceBranch(SailSource backingSource, ModelFactory modelFactory, boolean autoFlush) Creates a newSailSourcederived from the givenSailSourceand ifautoFlushis true, will automatically callflush()when not in use. -
Method Summary
Modifier and TypeMethodDescription(package private) voidvoidclose()Closes this resource, relinquishing any underlying resources.(package private) voidcloseChangeset(Changeset changeset) (package private) voiddataset(IsolationLevel level) Create an observableSailDatasetof the current state of thisSailSource.private SailDatasetprivate SailDatasetvoidflush()Apply all the changes to this branch to the backingSailSource, if applicable.private voidprivate voidfork()Creates a new branch of this source.booleanprivate boolean(package private) voidvoidprepare()Check the consistency of this branch and throws aSailConflictExceptionifSailSource.flush()ing this branch would cause the backingSailSourceto be inconsistent, if applicable.private voidprivate void(package private) voidpreparedChangeset(Changeset changeset) sink(IsolationLevel level) Create aSailSinkthat when when itsSailSource.flush()is called, the changes are applied to this source.toString()
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
semaphore
Used to prevent changes to this object's field from multiple threads. -
changes
The difference between thisSailSourceand the backingSailSource. -
pending
-
observers
Set of openSailDatasetfor thisSailSource. -
backingSource
The underlySailSourcethisSailSourceis derived from. -
modelFactory
TheModelinstances that should be used to storeSailSink.approve(Resource, IRI, Value, Resource)andSailSink.deprecate(Resource, IRI, Value, Resource)statements. -
autoFlush
private final boolean autoFlushIf thisSailSourceshould be flushed to the backingSailSourcewhen it is not in use. -
snapshot
Non-null when inIsolationLevels.SNAPSHOT(or higher) mode. -
serializable
Non-null when inIsolationLevels.SERIALIZABLE(or higher) mode. -
prepared
-
-
Constructor Details
-
SailSourceBranch
Creates a new in-memorySailSourcederived from the givenSailSource.- Parameters:
backingSource-
-
SailSourceBranch
Creates a newSailSourcederived from the givenSailSource.- Parameters:
backingSource-modelFactory-
-
SailSourceBranch
Creates a newSailSourcederived from the givenSailSourceand ifautoFlushis true, will automatically callflush()when not in use.- Parameters:
backingSource-modelFactory-autoFlush-
-
-
Method Details
-
close
Description copied from interface:SailClosableCloses this resource, relinquishing any underlying resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSailClosable- Throws:
SailException- if this resource cannot be closed
-
sink
Description copied from interface:SailSourceCreate aSailSinkthat when when itsSailSource.flush()is called, the changes are applied to this source.- Specified by:
sinkin interfaceSailSource- Parameters:
level- If this level is compatible withIsolationLevels.SERIALIZABLEthen aSailSink.prepare()can throw aSailConflictException.- Returns:
- Newly created
SailSink - Throws:
SailException
-
dataset
Description copied from interface:SailSourceCreate an observableSailDatasetof the current state of thisSailSource. Repeatedly calling with methods withIsolationLevels.SNAPSHOT(or higher) isolation levels will result inSailDatasets that are all derived from the same state of the backingSailSource(if applicable), that is the only difference between the states of theSailDatasetwill be from changes using thisSailSource.sink(IsolationLevel).- Specified by:
datasetin interfaceSailSource- Parameters:
level- If this is compatible withIsolationLevels.SNAPSHOT_READthe resultingSailDatasetwill observe a single state of thisSailSource.- Returns:
- an
SailDatasetof the current state - Throws:
SailException
-
fork
Description copied from interface:SailSourceCreates a new branch of this source. When it'sSailSource.flush()is called the changes are applied to this backing source.- Specified by:
forkin interfaceSailSource- Returns:
- a branched
SailSource.
-
prepare
Description copied from interface:SailSourceCheck the consistency of this branch and throws aSailConflictExceptionifSailSource.flush()ing this branch would cause the backingSailSourceto be inconsistent, if applicable. If this is the final backingSailSourcecalling this method has no effect.- Specified by:
preparein interfaceSailSource- Throws:
SailException
-
flush
Description copied from interface:SailSourceApply all the changes to this branch to the backingSailSource, if applicable. If this is the final backingSailSourcecalling this method has no effect.- Specified by:
flushin interfaceSailSource- Throws:
SailException
-
isChanged
public boolean isChanged() -
toString
-
preparedChangeset
-
merge
-
compressChanges
void compressChanges() -
closeChangeset
-
autoFlush
- Throws:
SailException
-
isChanged
-
derivedFromSerializable
- Throws:
SailException
-
derivedFromSnapshot
- Throws:
SailException
-
prepare
- Throws:
SailException
-
prepare
- Throws:
SailException
-
flush
- Throws:
SailException
-
flush
- Throws:
SailException
-