Package org.h2.mvstore.tx
Class TxDecisionMaker<K,V>
- Direct Known Subclasses:
TxDecisionMaker.LockDecisionMaker,TxDecisionMaker.PutIfAbsentDecisionMaker
Class TxDecisionMaker is a base implementation of MVMap.DecisionMaker
to be used for TransactionMap modification.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic final classstatic final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Transactionprivate MVMap.Decisionprotected KKey for the map entry to decide uponprivate longId of the last operation, we decided toMVMap.Decision.REPEAT.private Vprivate final intMap to decide uponprivate final TransactionTransaction we are operating withinprivate longId for the undo log entry created for this modificationprivate VValue for the map entryFields inherited from class org.h2.mvstore.MVMap.DecisionMaker
DEFAULT, PUT, REMOVE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) final booleandecide(VersionedValue<V> existingValue, VersionedValue<V> providedValue) Makes a decision about how to proceed with the update.(package private) final MVMap.DecisiondecideToAbort(V lastValue) (package private) final Transaction(package private) final MVMap.Decision(package private) final V(package private) VgetNewValue(VersionedValue<V> existingValue) Get the new value.(package private) voidinitialize(K key, V value) (package private) final booleanisCommitted(int transactionId) Determine whether specified id corresponds to a logically committed transaction.(package private) final booleanisRepeatedOperation(long id) Store operation id provided, but before that, compare it against last stored one.(package private) final booleanisThisTransaction(int transactionId) Check whether specified transaction id belongs to "current" transaction (transaction we are acting within).(package private) MVMap.DecisionlogAndDecideToPut(VersionedValue<V> valueToLog, V lastValue) Create undo log entry and record for future referencesMVMap.Decision.PUTdecision along with last known committed valuefinal voidreset()Resets internal state (if any) of a this DecisionMaker to it's initial state.<T extends VersionedValue<V>>
TselectValue(T existingValue, T providedValue) Provides revised value for insert/update based on original input value and value currently existing in the map.(package private) final MVMap.DecisionsetDecision(MVMap.Decision decision) Record for future references specified value as a decision that has been made.final StringtoString()Methods inherited from class org.h2.mvstore.MVMap.DecisionMaker
decide
-
Field Details
-
mapId
private final int mapIdMap to decide upon -
key
Key for the map entry to decide upon -
value
Value for the map entry -
transaction
Transaction we are operating within -
undoKey
private long undoKeyId for the undo log entry created for this modification -
lastOperationId
private long lastOperationIdId of the last operation, we decided toMVMap.Decision.REPEAT. -
blockingTransaction
-
decision
-
lastValue
-
-
Constructor Details
-
TxDecisionMaker
TxDecisionMaker(int mapId, Transaction transaction)
-
-
Method Details
-
initialize
-
decide
Description copied from class:MVMap.DecisionMakerMakes a decision about how to proceed with the update.- Specified by:
decidein classMVMap.DecisionMaker<VersionedValue<V>>- Parameters:
existingValue- value currently exists in the mapprovidedValue- original input value- Returns:
- 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
-
reset
public final void reset()Description copied from class:MVMap.DecisionMakerResets 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.- Overrides:
resetin classMVMap.DecisionMaker<VersionedValue<V>>
-
selectValue
Description copied from class:MVMap.DecisionMakerProvides 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.- Overrides:
selectValuein classMVMap.DecisionMaker<VersionedValue<V>>- Type Parameters:
T- value type- Parameters:
existingValue- value currently exists in the mapprovidedValue- original input value- Returns:
- value to be used by insert/update
-
getNewValue
Get the new value. This implementation always return the current value (ignores the parameter).- Parameters:
existingValue- the parameter value- Returns:
- the current value.
-
logAndDecideToPut
Create undo log entry and record for future referencesMVMap.Decision.PUTdecision along with last known committed value- Parameters:
valueToLog- previous value to be loggedlastValue- last known committed value- Returns:
MVMap.Decision.PUT
-
decideToAbort
-
allowNonRepeatableRead
final boolean allowNonRepeatableRead() -
getDecision
-
getBlockingTransaction
-
getLastValue
-
isThisTransaction
final boolean isThisTransaction(int transactionId) Check whether specified transaction id belongs to "current" transaction (transaction we are acting within).- Parameters:
transactionId- to check- Returns:
- true it it is "current" transaction's id, false otherwise
-
isCommitted
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- to use- Returns:
- true if transaction should be considered as committed, false otherwise
-
isRepeatedOperation
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- for the operation we decided toMVMap.Decision.REPEAT- Returns:
- true if the same as last operation id, false otherwise
-
setDecision
Record for future references specified value as a decision that has been made.- Parameters:
decision- made- Returns:
- argument provided
-
toString
-