Class InMemoryTrie<T>

    • Constructor Detail

      • InMemoryTrie

        public InMemoryTrie​(BufferType bufferType)
    • Method Detail

      • discardBuffers

        public void discardBuffers()
      • apply

        public <U> void apply​(Trie<U> mutation,
                              InMemoryTrie.UpsertTransformer<T,​U> transformer)
                       throws InMemoryTrie.SpaceExhaustedException
        Modify this trie to apply the mutation given in the form of a trie. Any content in the mutation will be resolved with the given function before being placed in this trie (even if there's no pre-existing content in this trie).
        Parameters:
        mutation - the mutation to be applied, given in the form of a trie. Note that its content can be of type different than the element type for this memtable trie.
        transformer - a function applied to the potentially pre-existing value for the given key, and the new value. Applied even if there's no pre-existing value in the memtable trie.
        Throws:
        InMemoryTrie.SpaceExhaustedException
      • putSingleton

        public <R> void putSingleton​(ByteComparable key,
                                     R value,
                                     InMemoryTrie.UpsertTransformer<T,​? super R> transformer)
                              throws InMemoryTrie.SpaceExhaustedException
        Map-like put method, using the apply machinery above which cannot run into stack overflow. When the correct position in the trie has been reached, the value will be resolved with the given function before being placed in the trie (even if there's no pre-existing content in this trie).
        Parameters:
        key - the trie path/key for the given value.
        value - the value being put in the memtable trie. Note that it can be of type different than the element type for this memtable trie. It's up to the transformer to return the final value that will stay in the memtable trie.
        transformer - a function applied to the potentially pre-existing value for the given key, and the new value (of a potentially different type), returning the final value that will stay in the memtable trie. Applied even if there's no pre-existing value in the memtable trie.
        Throws:
        InMemoryTrie.SpaceExhaustedException
      • putRecursive

        public <R> void putRecursive​(ByteComparable key,
                                     R value,
                                     InMemoryTrie.UpsertTransformer<T,​R> transformer)
                              throws InMemoryTrie.SpaceExhaustedException
        Map-like put method, using a fast recursive implementation through the key bytes. May run into stack overflow if the trie becomes too deep. When the correct position in the trie has been reached, the value will be resolved with the given function before being placed in the trie (even if there's no pre-existing content in this trie).
        Parameters:
        key - the trie path/key for the given value.
        value - the value being put in the memtable trie. Note that it can be of type different than the element type for this memtable trie. It's up to the transformer to return the final value that will stay in the memtable trie.
        transformer - a function applied to the potentially pre-existing value for the given key, and the new value (of a potentially different type), returning the final value that will stay in the memtable trie. Applied even if there's no pre-existing value in the memtable trie.
        Throws:
        InMemoryTrie.SpaceExhaustedException
      • reachedAllocatedSizeThreshold

        public boolean reachedAllocatedSizeThreshold()
        Returns true if the allocation threshold has been reached. To be called by the the writing thread (ideally, just after the write completes). When this returns true, the user should switch to a new trie as soon as feasible. The trie expects up to 10% growth above this threshold. Any growth beyond that may be done inefficiently, and the trie will fail altogether when the size grows beyond 2G - 256 bytes.
      • sizeOffHeap

        public long sizeOffHeap()
        Returns the off heap size of the memtable trie itself, not counting any space taken by referenced content.
      • sizeOnHeap

        public long sizeOnHeap()
        Returns the on heap size of the memtable trie itself, not counting any space taken by referenced content.
      • valuesUnordered

        public java.lang.Iterable<T> valuesUnordered()
        Description copied from class: Trie
        Returns the values in any order. For some tries this is much faster than the ordered iterable.
        Overrides:
        valuesUnordered in class Trie<T>
      • valuesCount

        public int valuesCount()
      • unusedReservedMemory

        public long unusedReservedMemory()