Interface KeyValueStorage<K,​V>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void clear()
      Remove all element from index
      KeyValueStorage clone​(int newSegment)
      Create clone of current index with new segmentId
      KeyValueStorage cloneHeader​(int newSegment)
      Clone only header of current index with new segmentId
      void close()
      Close index (sync and clear caches)
      boolean contains​(long key)
      Test if index contain specified key
      boolean contains​(String key)
      Test if index contain specified key
      void dropCaches()
      Drop all cache without store write cache to disk
      Set<Map.Entry<K,​V>> entrySet()
      Get entry set from index
      void evict()
      Advice to XMDB (put all data from caches to files, but no sync fdatasync call).
      byte[] get​(long key)
      Get value by long key
      byte[] get​(String key)
      Get value by String key
      ITreeCache getCache()
      Get internal index cache (same as database cache)
      int getSegment()
      Get segment id of index
      Set<? extends Object> keySet()
      Get keys set (clone all keys from index into new set)
      void merge​(KeyValueStorage<K,​byte[]> s1, Map<K,​byte[]> s2)
      Merge KVS and Map into current index (first can be this index)
      void merge​(KeyValueStorage<K,​V> s1, KeyValueStorage<K,​V> s2)
      Merge two KVS into current index (first can be this index)
      void put​(long key, byte[] value)
      Put new key/value pair in index (by long key)
      void put​(String key, byte[] value)
      Put new key/value pair in index (by String key)
      void putRAW​(long key, byte[] rawValue)
      Put raw (complex) value to index with complex value type
      byte[] remove​(long key)
      Remove long key from index
      byte[] remove​(String key)
      Remove String key from index
      ByteBuffer serialize()
      Serialize index header
      int size()
      Get index size in elements
      void sync()
      Sync index state with internal store (to file).
    • Method Detail

      • size

        int size()
        Get index size in elements
        Returns:
        size
      • sync

        void sync()
        Sync index state with internal store (to file). Force write cache to store to engine;
      • close

        void close()
        Close index (sync and clear caches)
      • clone

        KeyValueStorage clone​(int newSegment)
        Create clone of current index with new segmentId
        Parameters:
        newSegment - new segment id
        Returns:
        new index
      • cloneHeader

        KeyValueStorage cloneHeader​(int newSegment)
        Clone only header of current index with new segmentId
        Parameters:
        newSegment - new segment id
        Returns:
        new index (same as old, but with new index header and segment)
      • clear

        void clear()
        Remove all element from index
      • contains

        boolean contains​(long key)
        Test if index contain specified key
        Parameters:
        key - key to test
        Returns:
        "key exist in index" flag
      • contains

        boolean contains​(String key)
        Test if index contain specified key
        Parameters:
        key - key to test
        Returns:
        "key exist in index" flag
      • get

        byte[] get​(long key)
        Get value by long key
        Parameters:
        key - key
        Returns:
        value or null (if key doesn;t exist in index)
      • get

        byte[] get​(String key)
        Get value by String key
        Parameters:
        key - key
        Returns:
        value or null (if key doesn;t exist in index)
      • put

        void put​(long key,
                 byte[] value)
        Put new key/value pair in index (by long key)
        Parameters:
        key - key to put
        value - value to put
      • put

        void put​(String key,
                 byte[] value)
        Put new key/value pair in index (by String key)
        Parameters:
        key - key to put
        value - value to put
      • remove

        byte[] remove​(long key)
        Remove long key from index
        Parameters:
        key - key to remove
        Returns:
        old value (or null if key doesn;t exist in index)
      • remove

        byte[] remove​(String key)
        Remove String key from index
        Parameters:
        key - key to remove
        Returns:
        old value (or null if key doesn;t exist in index)
      • entrySet

        Set<Map.Entry<K,​V>> entrySet()
        Get entry set from index
        Returns:
        entry set
      • getCache

        ITreeCache getCache()
        Get internal index cache (same as database cache)
        Returns:
        index cache
      • dropCaches

        void dropCaches()
        Drop all cache without store write cache to disk
      • serialize

        ByteBuffer serialize()
        Serialize index header
        Returns:
        index header byte[] representation
      • getSegment

        int getSegment()
        Get segment id of index
        Returns:
        segment id
      • merge

        void merge​(KeyValueStorage<K,​V> s1,
                   KeyValueStorage<K,​V> s2)
        Merge two KVS into current index (first can be this index)
        Parameters:
        s1 - first KVS, base
        s2 - second KVS, updates
      • merge

        void merge​(KeyValueStorage<K,​byte[]> s1,
                   Map<K,​byte[]> s2)
        Merge KVS and Map into current index (first can be this index)
        Parameters:
        s1 - fist KVS, base
        s2 - second Map, updates
      • putRAW

        void putRAW​(long key,
                    byte[] rawValue)
        Put raw (complex) value to index with complex value type
        Parameters:
        key - long hash key of raw value
        rawValue - raw (complex) value
      • evict

        void evict()
        Advice to XMDB (put all data from caches to files, but no sync fdatasync call). Not mandatory, just safe RAM & speedup another threads
      • keySet

        Set<? extends Object> keySet()
        Get keys set (clone all keys from index into new set)
        Returns:
        keys set