Class Node<K,V>
java.lang.Object
tools.refinery.store.map.internal.state.Node<K,V>
- Direct Known Subclasses:
ImmutableNode,MutableNode
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intprotected static final intstatic final intstatic final intstatic final intprotected static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckIntegrity(ContinuousHashProvider<? super K> hashProvider, V defaultValue, int depth) abstract longgetSize()abstract VgetValue(K key, ContinuousHashProvider<? super K> hashProvider, V defaultValue, int hash, int depth) protected static inthashDepth(int depth) Calculates the index for the continuous hash.protected static inthashFragment(int hash, int shiftDepth) Selects a segments from a complete hash for a given depth.protected intincrementDepth(int depth) Increments the depth of the search in the tree.protected abstract MutableNode<K, V> protected intnewHash(ContinuousHashProvider<? super K> hashProvider, K key, int hash, int depth) Returns the hash code for a given depth.abstract voidprettyPrint(StringBuilder builder, int depth, int code) putValue(K key, V value, OldValueBox<V> old, ContinuousHashProvider<? super K> hashProvider, V defaultValue, int hash, int depth) protected static intshiftDepth(int depth) Calculates the which segment of a single hash should be used.abstract ImmutableNode<K, V> toImmutable(Map<Node<K, V>, ImmutableNode<K, V>> cache) toString()
-
Field Details
-
BRANCHING_FACTOR_BITS
public static final int BRANCHING_FACTOR_BITS- See Also:
-
FACTOR
public static final int FACTOR- See Also:
-
NUMBER_OF_FACTORS
protected static final int NUMBER_OF_FACTORS- See Also:
-
FACTOR_MASK
protected static final int FACTOR_MASK- See Also:
-
EFFECTIVE_BITS
public static final int EFFECTIVE_BITS- See Also:
-
FACTOR_SELECTION_BITS
public static final int FACTOR_SELECTION_BITS -
FACTOR_SELECTION_MASK
public static final int FACTOR_SELECTION_MASK -
INCREMENT_BIG_STEP
public static final int INCREMENT_BIG_STEP
-
-
Constructor Details
-
Node
public Node()
-
-
Method Details
-
incrementDepth
protected int incrementDepth(int depth) Increments the depth of the search in the tree. The depth parameter has two components: the least few bits selects the fragment of the hashcode, the other part selects the continuous hash.- Parameters:
depth- parameter encoding the fragment and the depth- Returns:
- new depth.
-
hashDepth
protected static int hashDepth(int depth) Calculates the index for the continuous hash.- Parameters:
depth- The depth of the node in the tree.- Returns:
- The index of the continuous hash.
-
shiftDepth
protected static int shiftDepth(int depth) Calculates the which segment of a single hash should be used.- Parameters:
depth- The depth of the node in the tree.- Returns:
- The segment of a hash code.
-
hashFragment
protected static int hashFragment(int hash, int shiftDepth) Selects a segments from a complete hash for a given depth.- Parameters:
hash- A complete hash.shiftDepth- The index of the segment.- Returns:
- The segment as an integer.
-
newHash
Returns the hash code for a given depth. It may calculate new hash code, or reuse a hash code calculated for depth-1.- Parameters:
key- The key.hash- Hash code for depth-1depth- The depth.- Returns:
- The new hash code.
-
getValue
public abstract V getValue(K key, ContinuousHashProvider<? super K> hashProvider, V defaultValue, int hash, int depth) -
putValue
public abstract Node<K,V> putValue(K key, V value, OldValueBox<V> old, ContinuousHashProvider<? super K> hashProvider, V defaultValue, int hash, int depth) -
getSize
public abstract long getSize() -
toImmutable
-
isMutable
-
prettyPrint
-
toString
-
checkIntegrity
public void checkIntegrity(ContinuousHashProvider<? super K> hashProvider, V defaultValue, int depth)
-