Package com._1c.g5.v8.xmdb.impl
Class TransactionalKVSImpl<K,V>
java.lang.Object
com._1c.g5.v8.xmdb.impl.TransactionalKVSImpl<K,V>
- All Implemented Interfaces:
KeyValueStorage<K,,V> TransactionalKVS<K,V>
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTransactionalKVSImpl(KeyValueStorage primaryKVS, Database database, String name) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Remove all element from indexclone(int newSegment) Create clone of current index with new segmentIdcloneHeader(int newSegment) Clone only header of current index with new segmentIdvoidclose()Close index (sync and clear caches)voidcommit()Commit changes from last merge operationbooleancontains(long key) Test if index contain specified keybooleanTest if index contain specified keyvoidDrop all cache without store write cache to diskentrySet()Get entry set from indexvoidevict()Advice to XMDB (put all data from caches to files, but no sync fdatasync call).byte[]get(long key) Get value by long keybyte[]Get value by String keygetCache()Get internal index cache (same as database cache)intGet merge rebuild border.Get base indexintGet segment id of indexkeySet()Get keys set (clone all keys from index into new set)voidmerge(KeyValueStorage updates) Merge updates into base index If updates contain entry with empty (=null) value - key will be removed from base indexvoidmerge(KeyValueStorage<K, byte[]> s1, Map<K, byte[]> s2) Merge KVS and Map into current index (first can be this index)voidmerge(KeyValueStorage s1, KeyValueStorage s2) Merge two KVS into current index (first can be this index)voidMerge updates into base index If updates contain entry with empty (=null) value - key will be removed from base indexvoidmergeCommit(KeyValueStorage updates) Merge&commit updates - fastest, but less integrity safe method to bulk update indexvoidmergeCommit(Map<K, V> updates) merge&commit updates - fastest, but less integrity safe method to bulk update indexvoidput(long key, byte[] value) Put new key/value pair in index (by long key)voidPut new key/value pair in index (by String key)voidputRAW(long key, byte[] rawValue) Put raw (complex) value to index with complex value typebyte[]remove(long key) Remove long key from indexbyte[]Remove String key from indexvoidrollback()Rollback changes from last uncommited merge operationSerialize index headervoidsetMergeRebuildBorder(int mergeRebuildBorder) Set merge rebuild border (see getMergeRebuildBorder)intsize()Get index size in elementsvoidsync()Sync index state with internal store (to file).
-
Field Details
-
MERGE_REBUILD_BORDER_DEF
public static final int MERGE_REBUILD_BORDER_DEF- See Also:
-
-
Constructor Details
-
TransactionalKVSImpl
-
-
Method Details
-
size
public int size()Description copied from interface:KeyValueStorageGet index size in elements- Specified by:
sizein interfaceKeyValueStorage<K,V> - Returns:
- size
-
clear
public void clear()Description copied from interface:KeyValueStorageRemove all element from index- Specified by:
clearin interfaceKeyValueStorage<K,V>
-
sync
public void sync()Description copied from interface:KeyValueStorageSync index state with internal store (to file). Force write cache to store to engine;- Specified by:
syncin interfaceKeyValueStorage<K,V>
-
close
public void close()Description copied from interface:KeyValueStorageClose index (sync and clear caches)- Specified by:
closein interfaceKeyValueStorage<K,V>
-
get
public byte[] get(long key) Description copied from interface:KeyValueStorageGet value by long key- Specified by:
getin interfaceKeyValueStorage<K,V> - Parameters:
key- key- Returns:
- value or null (if key doesn;t exist in index)
-
get
Description copied from interface:KeyValueStorageGet value by String key- Specified by:
getin interfaceKeyValueStorage<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:KeyValueStoragePut new key/value pair in index (by long key)- Specified by:
putin interfaceKeyValueStorage<K,V> - Parameters:
key- key to putvalue- value to put
-
put
Description copied from interface:KeyValueStoragePut new key/value pair in index (by String key)- Specified by:
putin interfaceKeyValueStorage<K,V> - Parameters:
key- key to putvalue- value to put
-
entrySet
Description copied from interface:KeyValueStorageGet entry set from index- Specified by:
entrySetin interfaceKeyValueStorage<K,V> - Returns:
- entry<Key,Value> set
-
setMergeRebuildBorder
public void setMergeRebuildBorder(int mergeRebuildBorder) Description copied from interface:TransactionalKVSSet merge rebuild border (see getMergeRebuildBorder)- Specified by:
setMergeRebuildBorderin interfaceTransactionalKVS<K,V> - Parameters:
mergeRebuildBorder- merge rebuild border
-
mergeCommit
Description copied from interface:TransactionalKVSMerge&commit updates - fastest, but less integrity safe method to bulk update index- Specified by:
mergeCommitin interfaceTransactionalKVS<K,V> - Parameters:
updates- updates
-
merge
Description copied from interface:TransactionalKVSMerge updates into base index If updates contain entry with empty (=null) value - key will be removed from base index- Specified by:
mergein interfaceTransactionalKVS<K,V> - Parameters:
updates- updates to merge
-
rollback
Description copied from interface:TransactionalKVSRollback changes from last uncommited merge operation- Specified by:
rollbackin interfaceTransactionalKVS<K,V> - Throws:
DBException
-
commit
Description copied from interface:TransactionalKVSCommit changes from last merge operation- Specified by:
commitin interfaceTransactionalKVS<K,V> - Throws:
DBException
-
getCache
Description copied from interface:KeyValueStorageGet internal index cache (same as database cache)- Specified by:
getCachein interfaceKeyValueStorage<K,V> - Returns:
- index cache
-
merge
Description copied from interface:KeyValueStorageMerge two KVS into current index (first can be this index)- Specified by:
mergein interfaceKeyValueStorage<K,V> - Parameters:
s1- first KVS, bases2- second KVS, updates
-
remove
public byte[] remove(long key) Description copied from interface:KeyValueStorageRemove long key from index- Specified by:
removein interfaceKeyValueStorage<K,V> - Parameters:
key- key to remove- Returns:
- old value (or null if key doesn;t exist in index)
-
remove
Description copied from interface:KeyValueStorageRemove String key from index- Specified by:
removein interfaceKeyValueStorage<K,V> - Parameters:
key- key to remove- Returns:
- old value (or null if key doesn;t exist in index)
-
getPrimaryStorage
Description copied from interface:TransactionalKVSGet base index- Specified by:
getPrimaryStoragein interfaceTransactionalKVS<K,V> - Returns:
- KeyValueStorage
-
getMergeRebuildBorder
public int getMergeRebuildBorder()Description copied from interface:TransactionalKVSGet 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:
getMergeRebuildBorderin interfaceTransactionalKVS<K,V> - Returns:
- merge rebuld border
-
dropCaches
public void dropCaches()Description copied from interface:KeyValueStorageDrop all cache without store write cache to disk- Specified by:
dropCachesin interfaceKeyValueStorage<K,V>
-
serialize
Description copied from interface:KeyValueStorageSerialize index header- Specified by:
serializein interfaceKeyValueStorage<K,V> - Returns:
- index header byte[] representation
-
getSegment
public int getSegment()Description copied from interface:KeyValueStorageGet segment id of index- Specified by:
getSegmentin interfaceKeyValueStorage<K,V> - Returns:
- segment id
-
clone
Description copied from interface:KeyValueStorageCreate clone of current index with new segmentId- Specified by:
clonein interfaceKeyValueStorage<K,V> - Parameters:
newSegment- new segment id- Returns:
- new index
-
cloneHeader
Description copied from interface:KeyValueStorageClone only header of current index with new segmentId- Specified by:
cloneHeaderin interfaceKeyValueStorage<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:KeyValueStoragePut raw (complex) value to index with complex value type- Specified by:
putRAWin interfaceKeyValueStorage<K,V> - Parameters:
key- long hash key of raw valuerawValue- raw (complex) value
-
contains
public boolean contains(long key) Description copied from interface:KeyValueStorageTest if index contain specified key- Specified by:
containsin interfaceKeyValueStorage<K,V> - Parameters:
key- key to test- Returns:
- "key exist in index" flag
-
contains
Description copied from interface:KeyValueStorageTest if index contain specified key- Specified by:
containsin interfaceKeyValueStorage<K,V> - Parameters:
key- key to test- Returns:
- "key exist in index" flag
-
evict
public void evict()Description copied from interface:KeyValueStorageAdvice to XMDB (put all data from caches to files, but no sync fdatasync call). Not mandatory, just safe RAM & speedup another threads- Specified by:
evictin interfaceKeyValueStorage<K,V>
-
merge
Description copied from interface:KeyValueStorageMerge KVS and Map into current index (first can be this index)- Specified by:
mergein interfaceKeyValueStorage<K,V> - Parameters:
s1- fist KVS, bases2- second Map, updates
-
merge
Description copied from interface:TransactionalKVSMerge updates into base index If updates contain entry with empty (=null) value - key will be removed from base index- Specified by:
mergein interfaceTransactionalKVS<K,V> - Parameters:
updates- updates to merge
-
mergeCommit
Description copied from interface:TransactionalKVSmerge&commit updates - fastest, but less integrity safe method to bulk update index- Specified by:
mergeCommitin interfaceTransactionalKVS<K,V> - Parameters:
updates- updates
-
keySet
Description copied from interface:KeyValueStorageGet keys set (clone all keys from index into new set)- Specified by:
keySetin interfaceKeyValueStorage<K,V> - Returns:
- keys set
-