Class TransactionalKVSImpl<K,​V>

    • Field Detail

      • MERGE_REBUILD_BORDER_DEF

        public static final int MERGE_REBUILD_BORDER_DEF
        See Also:
        Constant Field Values
    • Method Detail

      • sync

        public void sync()
        Description copied from interface: KeyValueStorage
        Sync index state with internal store (to file). Force write cache to store to engine;
        Specified by:
        sync in interface KeyValueStorage<K,​V>
      • get

        public byte[] get​(long key)
        Description copied from interface: KeyValueStorage
        Get value by long key
        Specified by:
        get in interface KeyValueStorage<K,​V>
        Parameters:
        key - key
        Returns:
        value or null (if key doesn;t exist in index)
      • get

        public byte[] get​(String key)
        Description copied from interface: KeyValueStorage
        Get value by String key
        Specified by:
        get in interface KeyValueStorage<K,​V>
        Parameters:
        key - key
        Returns:
        value or null (if key doesn;t exist in index)
      • put

        public void put​(long key,
                        byte[] value)
        Description copied from interface: KeyValueStorage
        Put new key/value pair in index (by long key)
        Specified by:
        put in interface KeyValueStorage<K,​V>
        Parameters:
        key - key to put
        value - value to put
      • put

        public void put​(String key,
                        byte[] value)
        Description copied from interface: KeyValueStorage
        Put new key/value pair in index (by String key)
        Specified by:
        put in interface KeyValueStorage<K,​V>
        Parameters:
        key - key to put
        value - value to put
      • setMergeRebuildBorder

        public void setMergeRebuildBorder​(int mergeRebuildBorder)
        Description copied from interface: TransactionalKVS
        Set merge rebuild border (see getMergeRebuildBorder)
        Specified by:
        setMergeRebuildBorder in interface TransactionalKVS<K,​V>
        Parameters:
        mergeRebuildBorder - merge rebuild border
      • mergeCommit

        public void mergeCommit​(KeyValueStorage updates)
        Description copied from interface: TransactionalKVS
        Merge&commit updates - fastest, but less integrity safe method to bulk update index
        Specified by:
        mergeCommit in interface TransactionalKVS<K,​V>
        Parameters:
        updates - updates
      • merge

        public void merge​(KeyValueStorage updates)
        Description copied from interface: TransactionalKVS
        Merge updates into base index If updates contain entry with empty (=null) value - key will be removed from base index
        Specified by:
        merge in interface TransactionalKVS<K,​V>
        Parameters:
        updates - updates to merge
      • remove

        public byte[] remove​(long key)
        Description copied from interface: KeyValueStorage
        Remove long key from index
        Specified by:
        remove in interface KeyValueStorage<K,​V>
        Parameters:
        key - key to remove
        Returns:
        old value (or null if key doesn;t exist in index)
      • remove

        public byte[] remove​(String key)
        Description copied from interface: KeyValueStorage
        Remove String key from index
        Specified by:
        remove in interface KeyValueStorage<K,​V>
        Parameters:
        key - key to remove
        Returns:
        old value (or null if key doesn;t exist in index)
      • getMergeRebuildBorder

        public int getMergeRebuildBorder()
        Description copied from interface: TransactionalKVS
        Get merge rebuild border. Value (in percent) show how many updates need to full rebuild of base index. If updates have less size - it will be merge by simple put into base index (on mergeCommit method) or base index clone (on merge method)
        Specified by:
        getMergeRebuildBorder in interface TransactionalKVS<K,​V>
        Returns:
        merge rebuld border
      • clone

        public KeyValueStorage clone​(int newSegment)
        Description copied from interface: KeyValueStorage
        Create clone of current index with new segmentId
        Specified by:
        clone in interface KeyValueStorage<K,​V>
        Parameters:
        newSegment - new segment id
        Returns:
        new index
      • cloneHeader

        public KeyValueStorage cloneHeader​(int newSegment)
        Description copied from interface: KeyValueStorage
        Clone only header of current index with new segmentId
        Specified by:
        cloneHeader in interface KeyValueStorage<K,​V>
        Parameters:
        newSegment - new segment id
        Returns:
        new index (same as old, but with new index header and segment)
      • putRAW

        public void putRAW​(long key,
                           byte[] rawValue)
        Description copied from interface: KeyValueStorage
        Put raw (complex) value to index with complex value type
        Specified by:
        putRAW in interface KeyValueStorage<K,​V>
        Parameters:
        key - long hash key of raw value
        rawValue - raw (complex) value
      • contains

        public boolean contains​(long key)
        Description copied from interface: KeyValueStorage
        Test if index contain specified key
        Specified by:
        contains in interface KeyValueStorage<K,​V>
        Parameters:
        key - key to test
        Returns:
        "key exist in index" flag
      • contains

        public boolean contains​(String key)
        Description copied from interface: KeyValueStorage
        Test if index contain specified key
        Specified by:
        contains in interface KeyValueStorage<K,​V>
        Parameters:
        key - key to test
        Returns:
        "key exist in index" flag
      • evict

        public void evict()
        Description copied from interface: KeyValueStorage
        Advice to XMDB (put all data from caches to files, but no sync fdatasync call). Not mandatory, just safe RAM & speedup another threads
        Specified by:
        evict in interface KeyValueStorage<K,​V>
      • merge

        public void merge​(KeyValueStorage<K,​byte[]> s1,
                          Map<K,​byte[]> s2)
        Description copied from interface: KeyValueStorage
        Merge KVS and Map into current index (first can be this index)
        Specified by:
        merge in interface KeyValueStorage<K,​V>
        Parameters:
        s1 - fist KVS, base
        s2 - second Map, updates
      • merge

        public void merge​(Map<K,​V> updates)
        Description copied from interface: TransactionalKVS
        Merge updates into base index If updates contain entry with empty (=null) value - key will be removed from base index
        Specified by:
        merge in interface TransactionalKVS<K,​V>
        Parameters:
        updates - updates to merge
      • mergeCommit

        public void mergeCommit​(Map<K,​V> updates)
        Description copied from interface: TransactionalKVS
        merge&commit updates - fastest, but less integrity safe method to bulk update index
        Specified by:
        mergeCommit in interface TransactionalKVS<K,​V>
        Parameters:
        updates - updates