java.lang.Object
org.yamcs.yarch.rocksdb.YRDB
wrapper around RocksDB that keeps track of column families. It also maintains a reference count and last access
timeused by the RdbFactory to close the database if not used for a while
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringcfNameToString(byte[] cfname) org.rocksdb.ColumnFamilyHandlecreateColumnFamily(byte[] cfname) org.rocksdb.ColumnFamilyHandlecreateColumnFamily(String name) voiddelete(byte[] k) voiddropColumnFamily(org.rocksdb.ColumnFamilyHandle cfh) byte[]get(byte[] k) RocksDB.get(byte[], byte[])byte[]get(org.rocksdb.ColumnFamilyHandle cfh, byte[] key) longlonggetApproxNumRecords(org.rocksdb.ColumnFamilyHandle cfh) List<byte[]>org.rocksdb.ColumnFamilyHandlegetColumnFamilyHandle(byte[] cfname) org.rocksdb.ColumnFamilyHandlegetColumnFamilyHandle(String cfname) org.rocksdb.RocksDBgetDb()getPath()org.rocksdb.SnapshotbooleanisOpen()voidlock(byte[] dbKey) Lock the key - that is if another thread called this method for that key, wait until someone calls the unlock on the same key.newDescendingPrefixIterator(byte[] prefix) Returns an iterator that iterates in reverse over all elements with key starting with the prefixorg.rocksdb.RocksIteratororg.rocksdb.RocksIteratornewIterator(org.rocksdb.ColumnFamilyHandle cfh) List<org.rocksdb.RocksIterator>newIterators(List<org.rocksdb.ColumnFamilyHandle> cfhList, boolean tailing) newPrefixIterator(byte[] prefix) Returns an iterator that iterates over all elements with key starting with the prefixvoidput(byte[] k, byte[] v) voidput(org.rocksdb.ColumnFamilyHandle cfh, byte[] k, byte[] v) voidput(org.rocksdb.WriteOptions writeOpt, byte[] k, byte[] v) voidreleaseSnapshot(org.rocksdb.Snapshot snapshot) List<byte[]>scanPartitions(int size) scans and returns a list of all prefixes of specified sizevoidunlock(byte[] dbKey) Unlock the key previously locked bylock(byte[])voidwrite(org.rocksdb.WriteOptions writeOpts, org.rocksdb.WriteBatch writeBatch)
-
Method Details
-
isOpen
public boolean isOpen()- Returns:
- true if the database is open
-
newIterators
public List<org.rocksdb.RocksIterator> newIterators(List<org.rocksdb.ColumnFamilyHandle> cfhList, boolean tailing) throws org.rocksdb.RocksDBException - Throws:
org.rocksdb.RocksDBException
-
newIterator
public org.rocksdb.RocksIterator newIterator() throws org.rocksdb.RocksDBException- Throws:
org.rocksdb.RocksDBException
-
newIterator
public org.rocksdb.RocksIterator newIterator(org.rocksdb.ColumnFamilyHandle cfh) throws org.rocksdb.RocksDBException - Throws:
org.rocksdb.RocksDBException
-
getColumnFamilyHandle
public org.rocksdb.ColumnFamilyHandle getColumnFamilyHandle(byte[] cfname) -
getColumnFamilyHandle
-
get
public byte[] get(org.rocksdb.ColumnFamilyHandle cfh, byte[] key) throws org.rocksdb.RocksDBException - Throws:
org.rocksdb.RocksDBException
-
get
public byte[] get(byte[] k) throws org.rocksdb.RocksDBException RocksDB.get(byte[], byte[])- Throws:
org.rocksdb.RocksDBException
-
createColumnFamily
public org.rocksdb.ColumnFamilyHandle createColumnFamily(byte[] cfname) throws org.rocksdb.RocksDBException - Throws:
org.rocksdb.RocksDBException
-
createColumnFamily
public org.rocksdb.ColumnFamilyHandle createColumnFamily(String name) throws org.rocksdb.RocksDBException - Throws:
org.rocksdb.RocksDBException
-
put
public void put(org.rocksdb.ColumnFamilyHandle cfh, byte[] k, byte[] v) throws org.rocksdb.RocksDBException - Throws:
org.rocksdb.RocksDBException
-
put
public void put(byte[] k, byte[] v) throws org.rocksdb.RocksDBException - Throws:
org.rocksdb.RocksDBException
-
put
public void put(org.rocksdb.WriteOptions writeOpt, byte[] k, byte[] v) throws org.rocksdb.RocksDBException - Throws:
org.rocksdb.RocksDBException
-
getColumnFamilies
-
getColumnFamiliesAsStrings
-
getPath
-
getProperties
- Throws:
org.rocksdb.RocksDBException
-
cfNameToString
-
getDb
public org.rocksdb.RocksDB getDb() -
dropColumnFamily
public void dropColumnFamily(org.rocksdb.ColumnFamilyHandle cfh) throws org.rocksdb.RocksDBException - Throws:
org.rocksdb.RocksDBException
-
scanPartitions
scans and returns a list of all prefixes of specified size- Parameters:
size-- Returns:
- list of partitions
- Throws:
IOException
-
getApproxNumRecords
public long getApproxNumRecords() throws org.rocksdb.RocksDBException- Throws:
org.rocksdb.RocksDBException
-
getApproxNumRecords
public long getApproxNumRecords(org.rocksdb.ColumnFamilyHandle cfh) throws org.rocksdb.RocksDBException - Throws:
org.rocksdb.RocksDBException
-
delete
public void delete(byte[] k) throws org.rocksdb.RocksDBException - Throws:
org.rocksdb.RocksDBException
-
newPrefixIterator
Returns an iterator that iterates over all elements with key starting with the prefix -
newDescendingPrefixIterator
Returns an iterator that iterates in reverse over all elements with key starting with the prefix -
lock
public void lock(byte[] dbKey) Lock the key - that is if another thread called this method for that key, wait until someone calls the unlock on the same key.The method is implemented by first selecting a
Lockfrom an fixed size array based on a hash of the key and performing theLock.lock()operation on it.- Parameters:
dbKey-
-
unlock
public void unlock(byte[] dbKey) Unlock the key previously locked bylock(byte[])- Parameters:
dbKey-
-
write
public void write(org.rocksdb.WriteOptions writeOpts, org.rocksdb.WriteBatch writeBatch) throws org.rocksdb.RocksDBException - Throws:
org.rocksdb.RocksDBException
-
getSnapshot
public org.rocksdb.Snapshot getSnapshot() -
releaseSnapshot
public void releaseSnapshot(org.rocksdb.Snapshot snapshot)
-