Top Description Inners Fields Constructors Methods
org.h2.mvstore.tx

pack-priv Class TxDecisionMaker<K, V>

extends MVMap.DecisionMaker<VersionedValue<V>>
Class Inheritance
Known Direct Subclasses
org.h2.mvstore.tx.TxDecisionMaker.PutIfAbsentDecisionMaker, org.h2.mvstore.tx.TxDecisionMaker.LockDecisionMaker
Imports
java.util.function.Function, org.h2.mvstore.DataUtils, .MVMap, .MVMap.Decision, org.h2.mvstore.type.DataType, org.h2.value.VersionedValue

Class TxDecisionMaker is a base implementation of MVMap.DecisionMaker to be used for TransactionMap modification.
Author
Andrei Tokar

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class

Field Summary

Modifier and TypeField and Description
private Transaction
private MVMap.Decision
protected K
key

Key for the map entry to decide upon

private long
lastOperationId

Id of the last operation, we decided to org.h2.mvstore.MVMap.Decision#REPEAT.

private V
private final int
mapId

Map to decide upon

private final Transaction
transaction

Transaction we are operating within

private long
undoKey

Id for the undo log entry created for this modification

private V
value

Value for the map entry

Inherited from org.h2.mvstore.MVMap.DecisionMaker:
DEFAULTPUTREMOVE

Constructor Summary

AccessConstructor and Description
pack-priv
TxDecisionMaker(int mapId, Transaction transaction)

Method Summary

Modifier and TypeMethod and Description
pack-priv final boolean
public MVMap.Decision
decide(VersionedValue<V>
value currently exists in the map
existingValue
,
VersionedValue<V>
original input value
providedValue
)

Implements abstract org.h2.mvstore.MVMap.DecisionMaker.decide.

Makes a decision about how to proceed with the update.

pack-priv final MVMap.Decision
decideToAbort(V lastValue)

pack-priv final Transaction
pack-priv final MVMap.Decision
pack-priv final V
pack-priv V

Returns:

the current value.
getNewValue
(VersionedValue<V>
the parameter value
existingValue
)

Get the new value.

pack-priv void
initialize(K key, V value)

pack-priv final boolean

Returns:

true if transaction should be considered as committed, false otherwise
isCommitted
(int
to use
transactionId
)

Determine whether specified id corresponds to a logically committed transaction.

pack-priv final boolean

Returns:

true if the same as last operation id, false otherwise
isRepeatedOperation
(long
for the operation we decided to org.h2.mvstore.MVMap.Decision#REPEAT
id
)

Store operation id provided, but before that, compare it against last stored one.

pack-priv final boolean

Returns:

true it it is "current" transaction's id, false otherwise
isThisTransaction
(int
to check
transactionId
)

Check whether specified transaction id belongs to "current" transaction (transaction we are acting within).

pack-priv MVMap.Decision
logAndDecideToPut(VersionedValue<V>
previous value to be logged
valueToLog
,
V
last known committed value
lastValue
)

Create undo log entry and record for future references org.h2.mvstore.MVMap.Decision#PUT decision along with last known committed value

public final void
reset()

Overrides org.h2.mvstore.MVMap.DecisionMaker.reset.

Resets internal state (if any) of a this DecisionMaker to it's initial state.

public <T extends VersionedValue<V>> T
selectValue(T
value currently exists in the map
existingValue
,
T
original input value
providedValue
)

Overrides org.h2.mvstore.MVMap.DecisionMaker.selectValue.

Provides revised value for insert/update based on original input value and value currently existing in the map.

pack-priv final MVMap.Decision

Returns:

argument provided
setDecision
(MVMap.Decision
made
decision
)

Record for future references specified value as a decision that has been made.

public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.h2.mvstore.MVMap.DecisionMaker:
decide

Field Detail

blockingTransactionback to summary
private Transaction blockingTransaction
decisionback to summary
private MVMap.Decision decision
keyback to summary
protected K key

Key for the map entry to decide upon

lastOperationIdback to summary
private long lastOperationId

Id of the last operation, we decided to org.h2.mvstore.MVMap.Decision#REPEAT.

lastValueback to summary
private V lastValue
mapIdback to summary
private final int mapId

Map to decide upon

transactionback to summary
private final Transaction transaction

Transaction we are operating within

undoKeyback to summary
private long undoKey

Id for the undo log entry created for this modification

valueback to summary
private V value

Value for the map entry

Constructor Detail

TxDecisionMakerback to summary
pack-priv TxDecisionMaker(int mapId, Transaction transaction)

Method Detail

allowNonRepeatableReadback to summary
pack-priv final boolean allowNonRepeatableRead()
decideback to summary
public MVMap.Decision decide(VersionedValue<V> existingValue, VersionedValue<V> providedValue)

Implements abstract org.h2.mvstore.MVMap.DecisionMaker.decide.

Doc from org.h2.mvstore.MVMap.DecisionMaker.decide.

Makes a decision about how to proceed with the update.

Parameters
existingValue:VersionedValue<V>

value currently exists in the map

providedValue:VersionedValue<V>

original input value

Returns:MVMap.Decision

PUT if a new value need to replace existing one or a new value to be inserted if there is none REMOVE if existing value should be deleted ABORT if update operation should be aborted or repeated later REPEAT if update operation should be repeated immediately

Annotations
@Override
decideToAbortback to summary
pack-priv final MVMap.Decision decideToAbort(V lastValue)
getBlockingTransactionback to summary
pack-priv final Transaction getBlockingTransaction()
getDecisionback to summary
pack-priv final MVMap.Decision getDecision()
getLastValueback to summary
pack-priv final V getLastValue()
getNewValueback to summary
pack-priv V getNewValue(VersionedValue<V> existingValue)

Get the new value. This implementation always return the current value (ignores the parameter).

Parameters
existingValue:VersionedValue<V>

the parameter value

Returns:V

the current value.

initializeback to summary
pack-priv void initialize(K key, V value)
isCommittedback to summary
pack-priv final boolean isCommitted(int transactionId)

Determine whether specified id corresponds to a logically committed transaction. In case of pending transaction, reference to actual Transaction object (if any) is preserved for future use.

Parameters
transactionId:int

to use

Returns:boolean

true if transaction should be considered as committed, false otherwise

isRepeatedOperationback to summary
pack-priv final boolean isRepeatedOperation(long id)

Store operation id provided, but before that, compare it against last stored one. This is to prevent an infinite loop in case of uncommitted "leftover" entry (one without a corresponding undo log entry, most likely as a result of unclean shutdown).

Parameters
id:long

for the operation we decided to org.h2.mvstore.MVMap.Decision#REPEAT

Returns:boolean

true if the same as last operation id, false otherwise

isThisTransactionback to summary
pack-priv final boolean isThisTransaction(int transactionId)

Check whether specified transaction id belongs to "current" transaction (transaction we are acting within).

Parameters
transactionId:int

to check

Returns:boolean

true it it is "current" transaction's id, false otherwise

logAndDecideToPutback to summary
pack-priv MVMap.Decision logAndDecideToPut(VersionedValue<V> valueToLog, V lastValue)

Create undo log entry and record for future references org.h2.mvstore.MVMap.Decision#PUT decision along with last known committed value

Parameters
valueToLog:VersionedValue<V>

previous value to be logged

lastValue:V

last known committed value

Returns:MVMap.Decision

org.h2.mvstore.MVMap.Decision#PUT

resetback to summary
public final void reset()

Overrides org.h2.mvstore.MVMap.DecisionMaker.reset.

Doc from org.h2.mvstore.MVMap.DecisionMaker.reset.

Resets internal state (if any) of a this DecisionMaker to it's initial state. This method is invoked whenever concurrent update failure is encountered, so we can re-start update process.

Annotations
@Override
selectValueback to summary
public <T extends VersionedValue<V>> T selectValue(T existingValue, T providedValue)

Overrides org.h2.mvstore.MVMap.DecisionMaker.selectValue.

Doc from org.h2.mvstore.MVMap.DecisionMaker.selectValue.

Provides revised value for insert/update based on original input value and value currently existing in the map. This method is only invoked after call to decide(), if it returns PUT.

Parameters
<T>
value type
existingValue:T

value currently exists in the map

providedValue:T

original input value

Returns:T

value to be used by insert/update

Annotations
@SuppressWarnings:unchecked
@Override
setDecisionback to summary
pack-priv final MVMap.Decision setDecision(MVMap.Decision decision)

Record for future references specified value as a decision that has been made.

Parameters
decision:MVMap.Decision

made

Returns:MVMap.Decision

argument provided

toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.h2.mvstore.tx back to summary

public Class TxDecisionMaker.LockDecisionMaker<K, V>

extends TxDecisionMaker<K, V>
Class Inheritance
Known Direct Subclasses
org.h2.mvstore.tx.TxDecisionMaker.RepeatableReadLockDecisionMaker

Field Summary

Inherited from org.h2.mvstore.tx.TxDecisionMaker:
key

Constructor Summary

AccessConstructor and Description
pack-priv
LockDecisionMaker(int mapId, Transaction transaction)

Method Summary

Modifier and TypeMethod and Description
public MVMap.Decision
decide(VersionedValue<V>
value currently exists in the map
existingValue
,
VersionedValue<V>
original input value
providedValue
)

Overrides org.h2.mvstore.tx.TxDecisionMaker.decide.

Makes a decision about how to proceed with the update.

pack-priv V
getNewValue(VersionedValue<V>
the parameter value
existingValue
)

Overrides org.h2.mvstore.tx.TxDecisionMaker.getNewValue.

Get the new value.

Inherited from org.h2.mvstore.tx.TxDecisionMaker:
allowNonRepeatableReaddecideToAbortgetBlockingTransactiongetDecisiongetLastValueinitializeisCommittedisRepeatedOperationisThisTransactionlogAndDecideToPutresetselectValuesetDecisiontoString

Constructor Detail

LockDecisionMakerback to summary
pack-priv LockDecisionMaker(int mapId, Transaction transaction)

Method Detail

decideback to summary
public MVMap.Decision decide(VersionedValue<V> existingValue, VersionedValue<V> providedValue)

Overrides org.h2.mvstore.tx.TxDecisionMaker.decide.

Doc from org.h2.mvstore.MVMap.DecisionMaker.decide.

Makes a decision about how to proceed with the update.

Parameters
existingValue:VersionedValue<V>

value currently exists in the map

providedValue:VersionedValue<V>

original input value

Returns:MVMap.Decision

PUT if a new value need to replace existing one or a new value to be inserted if there is none REMOVE if existing value should be deleted ABORT if update operation should be aborted or repeated later REPEAT if update operation should be repeated immediately

Annotations
@Override
getNewValueback to summary
pack-priv V getNewValue(VersionedValue<V> existingValue)

Overrides org.h2.mvstore.tx.TxDecisionMaker.getNewValue.

Doc from org.h2.mvstore.tx.TxDecisionMaker.getNewValue.

Get the new value. This implementation always return the current value (ignores the parameter).

Parameters
existingValue:VersionedValue<V>

the parameter value

Returns:V

the current value.

Annotations
@Override
org.h2.mvstore.tx back to summary

public final Class TxDecisionMaker.PutIfAbsentDecisionMaker<K, V>

extends TxDecisionMaker<K, V>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Function<K, V>
Inherited from org.h2.mvstore.tx.TxDecisionMaker:
key

Constructor Summary

AccessConstructor and Description
pack-priv
PutIfAbsentDecisionMaker(int mapId, Transaction transaction, Function<K, V> oldValueSupplier)

Method Summary

Modifier and TypeMethod and Description
public MVMap.Decision
decide(VersionedValue<V>
value currently exists in the map
existingValue
,
VersionedValue<V>
original input value
providedValue
)

Overrides org.h2.mvstore.tx.TxDecisionMaker.decide.

Makes a decision about how to proceed with the update.

private V
Inherited from org.h2.mvstore.tx.TxDecisionMaker:
allowNonRepeatableReaddecideToAbortgetBlockingTransactiongetDecisiongetLastValuegetNewValueinitializeisCommittedisRepeatedOperationisThisTransactionlogAndDecideToPutresetselectValuesetDecisiontoString

Field Detail

oldValueSupplierback to summary
private final Function<K, V> oldValueSupplier

Constructor Detail

PutIfAbsentDecisionMakerback to summary
pack-priv PutIfAbsentDecisionMaker(int mapId, Transaction transaction, Function<K, V> oldValueSupplier)

Method Detail

decideback to summary
public MVMap.Decision decide(VersionedValue<V> existingValue, VersionedValue<V> providedValue)

Overrides org.h2.mvstore.tx.TxDecisionMaker.decide.

Doc from org.h2.mvstore.MVMap.DecisionMaker.decide.

Makes a decision about how to proceed with the update.

Parameters
existingValue:VersionedValue<V>

value currently exists in the map

providedValue:VersionedValue<V>

original input value

Returns:MVMap.Decision

PUT if a new value need to replace existing one or a new value to be inserted if there is none REMOVE if existing value should be deleted ABORT if update operation should be aborted or repeated later REPEAT if update operation should be repeated immediately

Annotations
@Override
getValueInSnapshotback to summary
private V getValueInSnapshot()
org.h2.mvstore.tx back to summary

public final Class TxDecisionMaker.RepeatableReadLockDecisionMaker<K, V>

extends TxDecisionMaker.LockDecisionMaker<K, V>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Function<K, V>
private final DataType<VersionedValue<V>>

Constructor Summary

AccessConstructor and Description
pack-priv
RepeatableReadLockDecisionMaker(int mapId, Transaction transaction, DataType<VersionedValue<V>> valueType, Function<K, V> snapshotValueSupplier)

Method Summary

Modifier and TypeMethod and Description
pack-priv MVMap.Decision
logAndDecideToPut(VersionedValue<V>
previous value to be logged
valueToLog
,
V
last known committed value
value
)

Overrides org.h2.mvstore.tx.TxDecisionMaker.logAndDecideToPut.

Create undo log entry and record for future references org.h2.mvstore.MVMap.Decision#PUT decision along with last known committed value

Inherited from org.h2.mvstore.tx.TxDecisionMaker.LockDecisionMaker:
decidegetNewValue

Field Detail

snapshotValueSupplierback to summary
private final Function<K, V> snapshotValueSupplier
valueTypeback to summary
private final DataType<VersionedValue<V>> valueType

Constructor Detail

RepeatableReadLockDecisionMakerback to summary
pack-priv RepeatableReadLockDecisionMaker(int mapId, Transaction transaction, DataType<VersionedValue<V>> valueType, Function<K, V> snapshotValueSupplier)

Method Detail

logAndDecideToPutback to summary
pack-priv MVMap.Decision logAndDecideToPut(VersionedValue<V> valueToLog, V value)

Overrides org.h2.mvstore.tx.TxDecisionMaker.logAndDecideToPut.

Doc from org.h2.mvstore.tx.TxDecisionMaker.logAndDecideToPut.

Create undo log entry and record for future references org.h2.mvstore.MVMap.Decision#PUT decision along with last known committed value

Parameters
valueToLog:VersionedValue<V>

previous value to be logged

value:V

last known committed value

Returns:MVMap.Decision

org.h2.mvstore.MVMap.Decision#PUT

Annotations
@Override