Package org.h2.mvstore
Class MVMap.DecisionMaker<V>
- java.lang.Object
-
- org.h2.mvstore.MVMap.DecisionMaker<V>
-
- Type Parameters:
V- value type of the map
public abstract static class MVMap.DecisionMaker<V> extends java.lang.ObjectClass 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 Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <K> CursorPos<K,V>decide(CursorPos<K,V> tip, K key, V providedValue)Makes a page-level decision about how to proceed with the operation.abstract MVMap.Decisiondecide(V existingValue, V providedValue)Makes a decision about how to proceed with the update.MVMap.Decisiondecide(V existingValue, V providedValue, CursorPos<?,?> tip)Makes entry-level decision about how to proceed with the update.static <V> MVMap.DecisionMaker<V>defaultDecision()Decision maker for transaction rollback.static <V> MVMap.DecisionMaker<V>ifAbsentDecision()Decision maker for putIfAbsent() key/value.static <V> MVMap.DecisionMaker<V>ifPresentDecision()Decision maker for replace().voidonPageReplaced()DecisionMaker gets notified when proposed updated page was successfully injected into the B-tree to provide opportunity for internal state maintenance.static <V> MVMap.DecisionMaker<V>putDecision()Decision maker for put().static <V> MVMap.DecisionMaker<V>removeDecision()Decision maker for remove().voidreset()Resets internal state (if any) of this DecisionMaker to it's initial state.<T extends V>
TselectValue(T existingValue, T providedValue)Provides revised value for insert/update based on original input value and value currently existing in the map.
-
-
-
Method Detail
-
defaultDecision
public static <V> MVMap.DecisionMaker<V> defaultDecision()
Decision maker for transaction rollback.- Type Parameters:
V- value type of the map- Returns:
- decision maker
-
putDecision
public static <V> MVMap.DecisionMaker<V> putDecision()
Decision maker for put().- Type Parameters:
V- value type of the map- Returns:
- decision maker
-
removeDecision
public static <V> MVMap.DecisionMaker<V> removeDecision()
Decision maker for remove().- Type Parameters:
V- value type of the map- Returns:
- decision maker
-
ifAbsentDecision
public static <V> MVMap.DecisionMaker<V> ifAbsentDecision()
Decision maker for putIfAbsent() key/value.- Type Parameters:
V- value type of the map- Returns:
- decision maker
-
ifPresentDecision
public static <V> MVMap.DecisionMaker<V> ifPresentDecision()
Decision maker for replace().- Type Parameters:
V- value type of the map- Returns:
- decision maker
-
decide
public <K> CursorPos<K,V> decide(CursorPos<K,V> tip, K key, V providedValue)
Makes a page-level decision about how to proceed with the operation. This default implementation delegates decision to entry-level calldecide(Object, Object, CursorPos)- Type Parameters:
K- type of the key- Parameters:
tip- path from the leaf page, which is targeted by this operation - contains specified key or holds it's positionkey- for the operationprovidedValue- value for the operation- Returns:
- up to three attributes, which are contained within CursorPos object.
Possible values are:
- null, if operation should be re-tried;
- original tip, if operation should be aborted without any changes;
- path from an updated page to tree root, where index attribute (irrelevant in this context) is reused as memory size adjustment for an updated page;
-
decide
public MVMap.Decision decide(V existingValue, V providedValue, CursorPos<?,?> tip)
Makes entry-level decision about how to proceed with the update.- Parameters:
existingValue- the old valueprovidedValue- the new valuetip- 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 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
-
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 mapprovidedValue- original input value- Returns:
- value to be used by insert/update
-
reset
public void reset()
Resets internal state (if any) of this DecisionMaker to it's initial state. This method is invoked whenever concurrent update failure is encountered, so we can re-start update process.
-
onPageReplaced
public void onPageReplaced()
DecisionMaker gets notified when proposed updated page was successfully injected into the B-tree to provide opportunity for internal state maintenance.
-
-