Package org.eclipse.rdf4j.sail.base
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 boolean
If thisSailSource
should be flushed to the backingSailSource
when it is not in use.private final SailSource
The underlySailSource
thisSailSource
is derived from.private final ArrayDeque
<Changeset> The difference between thisSailSource
and the backingSailSource
.private static final org.slf4j.Logger
private final ModelFactory
TheModel
instances that should be used to storeSailSink.approve(Resource, IRI, Value, Resource)
andSailSink.deprecate(Resource, IRI, Value, Resource)
statements.private final Collection
<SailDataset> Set of openSailDataset
for thisSailSource
.private SailSink
private final ReentrantLock
Used to prevent changes to this object's field from multiple threads.private SailSink
Non-null when inIsolationLevels.SERIALIZABLE
(or higher) mode.private SailDataset
Non-null when inIsolationLevels.SNAPSHOT
(or higher) mode. -
Constructor Summary
ConstructorsConstructorDescriptionSailSourceBranch
(SailSource backingSource) Creates a new in-memorySailSource
derived from the givenSailSource
.SailSourceBranch
(SailSource backingSource, ModelFactory modelFactory) Creates a newSailSource
derived from the givenSailSource
.SailSourceBranch
(SailSource backingSource, ModelFactory modelFactory, boolean autoFlush) Creates a newSailSource
derived from the givenSailSource
and ifautoFlush
is true, will automatically callflush()
when not in use. -
Method Summary
Modifier and TypeMethodDescription(package private) void
void
close()
Closes this resource, relinquishing any underlying resources.(package private) void
closeChangeset
(Changeset changeset) (package private) void
dataset
(IsolationLevel level) Create an observableSailDataset
of the current state of thisSailSource
.private SailDataset
private SailDataset
void
flush()
Apply all the changes to this branch to the backingSailSource
, if applicable.private void
private void
fork()
Creates a new branch of this source.boolean
private boolean
(package private) void
void
prepare()
Check the consistency of this branch and throws aSailConflictException
ifSailSource.flush()
ing this branch would cause the backingSailSource
to be inconsistent, if applicable.private void
private void
(package private) void
preparedChangeset
(Changeset changeset) sink
(IsolationLevel level) Create aSailSink
that 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 thisSailSource
and the backingSailSource
. -
pending
-
observers
Set of openSailDataset
for thisSailSource
. -
backingSource
The underlySailSource
thisSailSource
is derived from. -
modelFactory
TheModel
instances that should be used to storeSailSink.approve(Resource, IRI, Value, Resource)
andSailSink.deprecate(Resource, IRI, Value, Resource)
statements. -
autoFlush
private final boolean autoFlushIf thisSailSource
should be flushed to the backingSailSource
when 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-memorySailSource
derived from the givenSailSource
.- Parameters:
backingSource
-
-
SailSourceBranch
Creates a newSailSource
derived from the givenSailSource
.- Parameters:
backingSource
-modelFactory
-
-
SailSourceBranch
Creates a newSailSource
derived from the givenSailSource
and ifautoFlush
is true, will automatically callflush()
when not in use.- Parameters:
backingSource
-modelFactory
-autoFlush
-
-
-
Method Details
-
close
Description copied from interface:SailClosable
Closes this resource, relinquishing any underlying resources.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSailClosable
- Throws:
SailException
- if this resource cannot be closed
-
sink
Description copied from interface:SailSource
Create aSailSink
that when when itsSailSource.flush()
is called, the changes are applied to this source.- Specified by:
sink
in interfaceSailSource
- Parameters:
level
- If this level is compatible withIsolationLevels.SERIALIZABLE
then aSailSink.prepare()
can throw aSailConflictException
.- Returns:
- Newly created
SailSink
- Throws:
SailException
-
dataset
Description copied from interface:SailSource
Create an observableSailDataset
of the current state of thisSailSource
. Repeatedly calling with methods withIsolationLevels.SNAPSHOT
(or higher) isolation levels will result inSailDataset
s that are all derived from the same state of the backingSailSource
(if applicable), that is the only difference between the states of theSailDataset
will be from changes using thisSailSource.sink(IsolationLevel)
.- Specified by:
dataset
in interfaceSailSource
- Parameters:
level
- If this is compatible withIsolationLevels.SNAPSHOT_READ
the resultingSailDataset
will observe a single state of thisSailSource
.- Returns:
- an
SailDataset
of the current state - Throws:
SailException
-
fork
Description copied from interface:SailSource
Creates a new branch of this source. When it'sSailSource.flush()
is called the changes are applied to this backing source.- Specified by:
fork
in interfaceSailSource
- Returns:
- a branched
SailSource
.
-
prepare
Description copied from interface:SailSource
Check the consistency of this branch and throws aSailConflictException
ifSailSource.flush()
ing this branch would cause the backingSailSource
to be inconsistent, if applicable. If this is the final backingSailSource
calling this method has no effect.- Specified by:
prepare
in interfaceSailSource
- Throws:
SailException
-
flush
Description copied from interface:SailSource
Apply all the changes to this branch to the backingSailSource
, if applicable. If this is the final backingSailSource
calling this method has no effect.- Specified by:
flush
in 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
-