Class TreeSession


  • public class TreeSession
    extends Object
    A session that allows reading and writing keys and values in a tree store.
    • Constructor Detail

      • TreeSession

        public TreeSession()
      • TreeSession

        public TreeSession​(Store store)
    • Method Detail

      • getFileNameRegex

        public static String getFileNameRegex()
      • setMaxRoots

        public void setMaxRoots​(int maxRoots)
        Set the maximum number of roots.
        Parameters:
        maxRoots - the new value
      • getMaxRoots

        public int getMaxRoots()
      • getFileReadCount

        public long getFileReadCount()
        Get the number of files read from the cache or storage.
        Returns:
        the result
      • init

        public void init()
        Initialize the storage, creating a new root if needed.
      • get

        public String get​(String key)
        Get an entry.
        Parameters:
        key - the key
        Returns:
        the value, or null
      • put

        public void put​(String key,
                        String value)
        Put a value. To remove an entry, the value needs to be null.
        Parameters:
        key - the key
        value - the value
      • mergeRoots

        public void mergeRoots​(int max)
        Merge a number of roots. Merging will create a new root, which contains the data of the previous roots. If there are less roots, this method returns without merging.
        Parameters:
        max - the number of roots to merge (Integer.MAX_VALUE for all)
      • getRootCount

        public int getRootCount()
        Get the number of roots.
        Returns:
        the number of roots
      • checkpoint

        public void checkpoint()
        Make the current tree read-only and switch to a new root. If there are already too many roots, then they will be merged. All changes are flushed to storage.
      • flush

        public void flush()
        Flush all changes to storage.
      • iterator

        public Iterator<Map.Entry<String,​String>> iterator()
        Get all entries. Do not add or move entries while iterating.
        Returns:
        the result
      • iterator

        public Iterator<Map.Entry<String,​String>> iterator​(String largerThan)
        Get all entries. Do not add or move entries while iterating.
        Parameters:
        largerThan - all returned keys are larger than this; null to start at the beginning
        Returns:
        the result
      • keys

        public Iterable<String> keys()
        Return all keys in sorted order. Roots don't need to be merged.
        Returns:
        all keys
      • keys

        public Iterable<String> keys​(String largerThan)
        Return all keys in sorted order.
        Parameters:
        largerThan - all returned keys are larger than this; null to start at the beginning
        Returns:
        the keys
      • runGC

        public void runGC()
      • getInfo

        public String getInfo()
      • getMinKey

        public String getMinKey()
      • getMaxKey

        public String getMaxKey()