Interface KeyValueStore


  • public interface KeyValueStore
    An abstraction of a store that persists the nodes of a Patricia tree.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      byte[] get​(byte[] key)
      Gets the association of a key in this store.
      byte[] getRoot()
      Yields the hash of the root of the Patricia trie that this store supports.
      void put​(byte[] key, byte[] value)
      Persists an association of a key to a value in this store.
      void remove​(byte[] key)
      Deletes the association for the given key, that must exist in store.
      void setRoot​(byte[] root)
      Sets the hash of the root of the Patricia trie that this store supports.
    • Method Detail

      • getRoot

        byte[] getRoot()
        Yields the hash of the root of the Patricia trie that this store supports.
        Returns:
        the hash of the root; this might be null if this store supports the empty Patricia trie
      • setRoot

        void setRoot​(byte[] root)
        Sets the hash of the root of the Patricia trie that this store supports.
        Parameters:
        root - the hash of the root of the trie
      • put

        void put​(byte[] key,
                 byte[] value)
        Persists an association of a key to a value in this store. It replaces it if it was already present.
        Parameters:
        key - the key
        value - the value
      • remove

        void remove​(byte[] key)
        Deletes the association for the given key, that must exist in store.
        Parameters:
        key - the key
      • get

        byte[] get​(byte[] key)
            throws NoSuchElementException
        Gets the association of a key in this store.
        Parameters:
        key - the key
        Returns:
        the value associated with the key
        Throws:
        NoSuchElementException - if the key is not associated in this store