Class TxDecisionMaker<K,V>

java.lang.Object
org.h2.mvstore.MVMap.DecisionMaker<VersionedValue<V>>
org.h2.mvstore.tx.TxDecisionMaker<K,V>
Direct Known Subclasses:
TxDecisionMaker.LockDecisionMaker, TxDecisionMaker.PutIfAbsentDecisionMaker

class TxDecisionMaker<K,V> extends MVMap.DecisionMaker<VersionedValue<V>>
Class TxDecisionMaker is a base implementation of MVMap.DecisionMaker to be used for TransactionMap modification.
  • Field Details

    • mapId

      private final int mapId
      Map to decide upon
    • key

      protected K key
      Key for the map entry to decide upon
    • value

      private V value
      Value for the map entry
    • transaction

      private final Transaction transaction
      Transaction we are operating within
    • undoKey

      private long undoKey
      Id for the undo log entry created for this modification
    • lastOperationId

      private long lastOperationId
      Id of the last operation, we decided to MVMap.Decision.REPEAT.
    • blockingTransaction

      private Transaction blockingTransaction
    • decision

      private MVMap.Decision decision
    • lastValue

      private V lastValue
  • Constructor Details

    • TxDecisionMaker

      TxDecisionMaker(int mapId, Transaction transaction)
  • Method Details

    • initialize

      void initialize(K key, V value)
    • decide

      public MVMap.Decision decide(VersionedValue<V> existingValue, VersionedValue<V> providedValue)
      Description copied from class: MVMap.DecisionMaker
      Makes a decision about how to proceed with the update.
      Specified by:
      decide in class MVMap.DecisionMaker<VersionedValue<V>>
      Parameters:
      existingValue - value currently exists in the map
      providedValue - 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.DecisionMaker
      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.
      Overrides:
      reset in class MVMap.DecisionMaker<VersionedValue<V>>
    • selectValue

      public <T extends VersionedValue<V>> T selectValue(T existingValue, T providedValue)
      Description copied from class: MVMap.DecisionMaker
      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.
      Overrides:
      selectValue in class MVMap.DecisionMaker<VersionedValue<V>>
      Type Parameters:
      T - value type
      Parameters:
      existingValue - value currently exists in the map
      providedValue - original input value
      Returns:
      value to be used by insert/update
    • getNewValue

      V getNewValue(VersionedValue<V> existingValue)
      Get the new value. This implementation always return the current value (ignores the parameter).
      Parameters:
      existingValue - the parameter value
      Returns:
      the current value.
    • logAndDecideToPut

      MVMap.Decision logAndDecideToPut(VersionedValue<V> valueToLog, V lastValue)
      Create undo log entry and record for future references MVMap.Decision.PUT decision along with last known committed value
      Parameters:
      valueToLog - previous value to be logged
      lastValue - last known committed value
      Returns:
      MVMap.Decision.PUT
    • decideToAbort

      final MVMap.Decision decideToAbort(V lastValue)
    • allowNonRepeatableRead

      final boolean allowNonRepeatableRead()
    • getDecision

      final MVMap.Decision getDecision()
    • getBlockingTransaction

      final Transaction getBlockingTransaction()
    • getLastValue

      final V 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 to MVMap.Decision.REPEAT
      Returns:
      true if the same as last operation id, false otherwise
    • setDecision

      final MVMap.Decision setDecision(MVMap.Decision decision)
      Record for future references specified value as a decision that has been made.
      Parameters:
      decision - made
      Returns:
      argument provided
    • toString

      public final String toString()
      Overrides:
      toString in class Object