Interface Revisions
-
- All Known Implementing Classes:
MemoryStoreRevisions
,ReadOnlyRevisions
,TarRevisions
public interface Revisions
Revisions
instances provide read and write access to the current head state. Implementations are thread safe and all setters act atomically.This is a low level API and it is the callers and implementors responsibility to ensure all record id passed to or returned from methods of this interface are the ids of node states.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Revisions.Option
Implementation specific options for thesetHead
methods.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @NotNull RecordId
getHead()
Returns the record id of the head state.@NotNull RecordId
getPersistedHead()
Returns the persisted to disk record id of the head state.RecordId
setHead(@NotNull Function<RecordId,RecordId> newHead, @NotNull Revisions.Option... options)
Atomically set the record id of the current head state to the value returned from thenewHead
function when called with the record id of the current head.boolean
setHead(@NotNull RecordId expected, @NotNull RecordId head, @NotNull Revisions.Option... options)
Atomically set the record id of the current head state to the givenhead
state if the current head state matches theexpected
value.
-
-
-
Method Detail
-
getHead
@NotNull @NotNull RecordId getHead()
Returns the record id of the head state. The returned id is a valid id for aSegmentNodeState
.- Returns:
- id of the head state
-
getPersistedHead
@NotNull @NotNull RecordId getPersistedHead()
Returns the persisted to disk record id of the head state. The returned id is a valid id for aSegmentNodeState
.- Returns:
- id of the head state
-
setHead
boolean setHead(@NotNull @NotNull RecordId expected, @NotNull @NotNull RecordId head, @NotNull @NotNull Revisions.Option... options)
Atomically set the record id of the current head state to the givenhead
state if the current head state matches theexpected
value.All record ids must be valid ids for
SegmentNodeState
s.The locking behaviour of this method regarding implementation specific.
- Parameters:
expected
- the expected head for the update to take placehead
- the new head to update tooptions
- implementation specific options- Returns:
true
if the current head was successfully updated,false
otherwise.
-
setHead
RecordId setHead(@NotNull @NotNull Function<RecordId,RecordId> newHead, @NotNull @NotNull Revisions.Option... options) throws InterruptedException
Atomically set the record id of the current head state to the value returned from thenewHead
function when called with the record id of the current head.All record ids must be valid ids for
SegmentNodeState
s.The behaviour of this method regarding locking and handling
null
values returned bynewHead
is implementation specific.- Parameters:
newHead
- function mapping an record id to the record id to which the current head id should be set.options
- implementation specific options- Returns:
- the record id of the root node if the current head was successfully
updated,
null
otherwise. - Throws:
InterruptedException
- Blocking implementations may throw this exception whe interrupted.
-
-