Class MVMap.DecisionMaker<V>

  • Type Parameters:
    V - value type of the map
    Direct Known Subclasses:
    CommitDecisionMaker, MVMap.EqualsDecisionMaker, MVMap.RewriteDecisionMaker, RollbackDecisionMaker, TxDecisionMaker
    Enclosing class:
    MVMap<K,​V>

    public abstract static class MVMap.DecisionMaker<V>
    extends java.lang.Object
    Class DecisionMaker provides callback interface (and should become a such in Java 8) for MVMap.operate method. It provides control logic to make a decision about how to proceed with update at the point in execution when proper place and possible existing value for insert/update/delete key is found. Revised value for insert/update is also provided based on original input value and value currently existing in the map.
    • Constructor Summary

      Constructors 
      Constructor Description
      DecisionMaker()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract MVMap.Decision decide​(V existingValue, V providedValue)
      Makes a decision about how to proceed with the update.
      MVMap.Decision decide​(V existingValue, V providedValue, CursorPos<?,​?> tip)
      Makes a decision about how to proceed with the update.
      void reset()
      Resets internal state (if any) of a this DecisionMaker to it's initial state.
      <T extends V>
      T
      selectValue​(T existingValue, T providedValue)
      Provides revised value for insert/update based on original input value and value currently existing in the map.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT

        public static final MVMap.DecisionMaker<java.lang.Object> DEFAULT
        Decision maker for transaction rollback.
      • REMOVE

        public static final MVMap.DecisionMaker<java.lang.Object> REMOVE
        Decision maker for remove().
      • IF_ABSENT

        static final MVMap.DecisionMaker<java.lang.Object> IF_ABSENT
        Decision maker for putIfAbsent() key/value.
      • IF_PRESENT

        static final MVMap.DecisionMaker<java.lang.Object> IF_PRESENT
        Decision maker for replace().
    • Constructor Detail

      • DecisionMaker

        public DecisionMaker()
    • Method Detail

      • decide

        public MVMap.Decision decide​(V existingValue,
                                     V providedValue,
                                     CursorPos<?,​?> tip)
        Makes a decision about how to proceed with the update.
        Parameters:
        existingValue - the old value
        providedValue - the new value
        tip - the cursor position
        Returns:
        the decision
      • decide

        public abstract MVMap.Decision decide​(V existingValue,
                                              V providedValue)
        Makes a decision about how to proceed with the update.
        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
      • selectValue

        public <T extends V> T selectValue​(T existingValue,
                                           T providedValue)
        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.
        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
      • reset

        public void 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.