Class Transaction
- java.lang.Object
-
- org.rocksdb.AbstractNativeReference
-
- org.rocksdb.AbstractImmutableNativeReference
-
- org.rocksdb.RocksObject
-
- org.rocksdb.Transaction
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class Transaction extends RocksObject
Provides BEGIN/COMMIT/ROLLBACK transactions.To use transactions, you must first create either an
OptimisticTransactionDBor aTransactionDBTo create a transaction, useOptimisticTransactionDB.beginTransaction(org.rocksdb.WriteOptions)orTransactionDB.beginTransaction(org.rocksdb.WriteOptions)It is up to the caller to synchronize access to this object.See samples/src/main/java/OptimisticTransactionSample.java and samples/src/main/java/TransactionSample.java for some simple examples.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTransaction.TransactionStatestatic classTransaction.WaitingTransactions
-
Field Summary
-
Fields inherited from class org.rocksdb.RocksObject
nativeHandle_
-
Fields inherited from class org.rocksdb.AbstractImmutableNativeReference
owningHandle_
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclearSnapshot()Clears the current snapshot (i.e.voidcommit()Write all batched keys to the db atomically.voiddelete(byte[] key)Similar toRocksDB.delete(byte[]), but will also perform conflict checking on the keys be written.voiddelete(byte[][] keyParts)Similar todelete(byte[])but allows you to specify key the in several parts that will be concatenated together.voiddelete(ColumnFamilyHandle columnFamilyHandle, byte[] key)Similar todelete(ColumnFamilyHandle, byte[], boolean)but withassumeTracked = false.voiddelete(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts)Similar todelete(ColumnFamilyHandle, byte[][], boolean)but withassumeTracked = false.voiddelete(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts, boolean assumeTracked)Similar todelete(ColumnFamilyHandle, byte[])but allows you to specify the key in several parts that will be concatenated together.voiddelete(ColumnFamilyHandle columnFamilyHandle, byte[] key, boolean assumeTracked)Similar toRocksDB.delete(ColumnFamilyHandle, byte[]), but will also perform conflict checking on the keys be written.voiddeleteUntracked(byte[] key)Similar toRocksDB.delete(byte[]), but operates on the transactions write batch.voiddeleteUntracked(byte[][] keyParts)Similar todeleteUntracked(byte[])but allows you to specify the key in several parts that will be concatenated together.voiddeleteUntracked(ColumnFamilyHandle columnFamilyHandle, byte[] key)Similar toRocksDB.delete(ColumnFamilyHandle, byte[]), but operates on the transactions write batch.voiddeleteUntracked(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts)Similar todeleteUntracked(ColumnFamilyHandle, byte[])but allows you to specify the key in several parts that will be concatenated together.voiddisableIndexing()By default, all put/merge/delete operations will be indexed in the transaction so that get/getForUpdate/getIterator can search for these keys.protected voiddisposeInternal(long handle)voidenableIndexing()Re-enables indexing after a previous call todisableIndexing()byte[]get(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, byte[] key)Deprecated.byte[]get(ReadOptions readOptions, byte[] key)This function is similar toRocksDB.get(ReadOptions, byte[])except it will also read pending changes in this transaction.GetStatusget(ReadOptions opt, byte[] key, byte[] value)Get the value associated with the specified key in the default column familyGetStatusget(ReadOptions opt, java.nio.ByteBuffer key, java.nio.ByteBuffer value)Get the value associated with the specified key within the default column family.byte[]get(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, byte[] key)This function is similar toRocksDB.get(ColumnFamilyHandle, ReadOptions, byte[])except it will also read pending changes in this transaction.GetStatusget(ReadOptions opt, ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value)Get the value associated with the specified key in a specified column familyGetStatusget(ReadOptions opt, ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value)Get the value associated with the specified key within the specified column family.WriteBatchgetCommitTimeWriteBatch()Get the Commit time Write Batch.longgetElapsedTime()Returns the elapsed time in milliseconds since this Transaction began.byte[]getForUpdate(ReadOptions readOptions, byte[] key, boolean exclusive)Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction).GetStatusgetForUpdate(ReadOptions readOptions, byte[] key, byte[] value, boolean exclusive)Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction).GetStatusgetForUpdate(ReadOptions readOptions, java.nio.ByteBuffer key, java.nio.ByteBuffer value, boolean exclusive)Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction).byte[]getForUpdate(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, byte[] key, boolean exclusive)Same asgetForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean, boolean)with doValidate=true.byte[]getForUpdate(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, byte[] key, boolean exclusive, boolean doValidate)Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction).GetStatusgetForUpdate(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value, boolean exclusive)Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction).GetStatusgetForUpdate(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value, boolean exclusive, boolean doValidate)Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction).GetStatusgetForUpdate(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value, boolean exclusive)Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction).GetStatusgetForUpdate(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value, boolean exclusive, boolean doValidate)Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction).longgetId()The globally unique id with which the transaction is identified.longgetID()Get the ID of the transaction.RocksIteratorgetIterator()Returns an iterator that will iterate on all keys in the default column family including both keys in the DB and uncommitted keys in this transaction.RocksIteratorgetIterator(ColumnFamilyHandle columnFamilyHandle)Returns an iterator that will iterate on all keys in the column family specified bycolumnFamilyHandleincluding both keys in the DB and uncommitted keys in this transaction.RocksIteratorgetIterator(ReadOptions readOptions)Returns an iterator that will iterate on all keys in the default column family including both keys in the DB and uncommitted keys in this transaction.RocksIteratorgetIterator(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle)Returns an iterator that will iterate on all keys in the column family specified bycolumnFamilyHandleincluding both keys in the DB and uncommitted keys in this transaction.longgetLogNumber()Get the log number.java.lang.StringgetName()Get the name of the transaction.longgetNumDeletes()Returns the number of deletes that have been applied to this transaction so far.longgetNumKeys()Returns the number of distinct Keys being tracked by this transaction.longgetNumMerges()Returns the number of merges that have been applied to this transaction so far.longgetNumPuts()Returns the number of puts that have been applied to this transaction so far.SnapshotgetSnapshot()Returns the Snapshot created by the last call tosetSnapshot().Transaction.TransactionStategetState()Get the execution status of the transaction.Transaction.WaitingTransactionsgetWaitingTxns()Get the list of waiting transactions.WriteBatchWithIndexgetWriteBatch()Fetch the underlying write batch that contains all pending changes to be committed.WriteOptionsgetWriteOptions()Return the WriteOptions that will be used duringcommit().booleanisDeadlockDetect()Determine if a deadlock has been detected.voidmerge(byte[] key, byte[] value)Similar toRocksDB.merge(byte[], byte[]), but will also perform conflict checking on the keys be written.voidmerge(java.nio.ByteBuffer key, java.nio.ByteBuffer value)Similar toRocksDB.merge(byte[], byte[]), but will also perform conflict checking on the keys be written.voidmerge(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value)Similar tomerge(ColumnFamilyHandle, byte[], byte[], boolean)but withassumeTracked = false.voidmerge(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value, boolean assumeTracked)Similar toRocksDB.merge(ColumnFamilyHandle, byte[], byte[]), but will also perform conflict checking on the keys be written.voidmerge(ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value)Similar toRocksDB.merge(byte[], byte[]), but will also perform conflict checking on the keys be written.voidmerge(ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value, boolean assumeTracked)Similar toRocksDB.merge(byte[], byte[]), but will also perform conflict checking on the keys be written.voidmergeUntracked(byte[] key, byte[] value)Similar toRocksDB.merge(byte[], byte[]), but operates on the transactions write batch.voidmergeUntracked(java.nio.ByteBuffer key, java.nio.ByteBuffer value)Similar toRocksDB.merge(byte[], byte[]), but operates on the transactions write batch.voidmergeUntracked(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value)Similar toRocksDB.merge(ColumnFamilyHandle, byte[], byte[]), but operates on the transactions write batch.voidmergeUntracked(ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value)Similar toRocksDB.merge(ColumnFamilyHandle, byte[], byte[]), but operates on the transactions write batch.byte[][]multiGet(ReadOptions readOptions, byte[][] keys)Deprecated.byte[][]multiGet(ReadOptions readOptions, java.util.List<ColumnFamilyHandle> columnFamilyHandles, byte[][] keys)Deprecated.java.util.List<byte[]>multiGetAsList(ReadOptions readOptions, java.util.List<byte[]> keys)This function is similar toRocksDB.multiGetAsList(java.util.List<byte[]>)except it will also read pending changes in this transaction.java.util.List<byte[]>multiGetAsList(ReadOptions readOptions, java.util.List<ColumnFamilyHandle> columnFamilyHandles, java.util.List<byte[]> keys)This function is similar toRocksDB.multiGetAsList(ReadOptions, List, List)except it will also read pending changes in this transaction.byte[][]multiGetForUpdate(ReadOptions readOptions, byte[][] keys)Deprecated.byte[][]multiGetForUpdate(ReadOptions readOptions, java.util.List<ColumnFamilyHandle> columnFamilyHandles, byte[][] keys)Deprecated.java.util.List<byte[]>multiGetForUpdateAsList(ReadOptions readOptions, java.util.List<byte[]> keys)A multi-key version ofgetForUpdate(ReadOptions, byte[], boolean).java.util.List<byte[]>multiGetForUpdateAsList(ReadOptions readOptions, java.util.List<ColumnFamilyHandle> columnFamilyHandles, java.util.List<byte[]> keys)A multi-key version ofgetForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean).voidprepare()Prepare the current transaction for 2PCvoidput(byte[][] keyParts, byte[][] valueParts)Similar toput(byte[], byte[])but allows you to specify the key and value in several parts that will be concatenated togethervoidput(byte[] key, byte[] value)Similar toRocksDB.put(byte[], byte[]), but will also perform conflict checking on the keys be written.voidput(java.nio.ByteBuffer key, java.nio.ByteBuffer value)Similar toRocksDB.put(byte[], byte[]), but will also perform conflict checking on the keys be written.voidput(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts, byte[][] valueParts)Similar toput(ColumnFamilyHandle, byte[][], byte[][], boolean)but with withassumeTracked = false.voidput(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts, byte[][] valueParts, boolean assumeTracked)Similar toput(ColumnFamilyHandle, byte[], byte[])but allows you to specify the key and value in several parts that will be concatenated together.voidput(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value)Similar toput(ColumnFamilyHandle, byte[], byte[], boolean)but withassumeTracked = false.voidput(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value, boolean assumeTracked)Similar toRocksDB.put(ColumnFamilyHandle, byte[], byte[]), but will also perform conflict checking on the keys be written.voidput(ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value)voidput(ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value, boolean assumeTracked)Similar toRocksDB.put(byte[], byte[]), but will also perform conflict checking on the keys be written.voidputLogData(byte[] blob)Similar toAbstractWriteBatch.putLogData(byte[])voidputUntracked(byte[][] keyParts, byte[][] valueParts)Similar toputUntracked(byte[], byte[])but allows you to specify the key and value in several parts that will be concatenated together.voidputUntracked(byte[] key, byte[] value)Similar toRocksDB.put(byte[], byte[]), but operates on the transactions write batch.voidputUntracked(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts, byte[][] valueParts)Similar toputUntracked(ColumnFamilyHandle, byte[], byte[])but allows you to specify the key and value in several parts that will be concatenated together.voidputUntracked(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value)Similar toRocksDB.put(ColumnFamilyHandle, byte[], byte[]), but operates on the transactions write batch.voidrebuildFromWriteBatch(WriteBatch writeBatch)Adds the keys from the WriteBatch to the transactionvoidrollback()Discard all batched writes in this transaction.voidrollbackToSavePoint()Undo all operations in this transaction (put, merge, delete, putLogData) since the most recent call tosetSavePoint()and removes the most recentsetSavePoint().voidsetLockTimeout(long lockTimeout)Change the value ofTransactionOptions.getLockTimeout()(in milliseconds) for this transaction.voidsetLogNumber(long logNumber)Set the log number.voidsetName(java.lang.String transactionName)Set the name of the transaction.voidsetSavePoint()Records the state of the transaction for future calls torollbackToSavePoint().voidsetSnapshot()If a transaction has a snapshot set, the transaction will ensure that any keys successfully written (or fetched viagetForUpdate(org.rocksdb.ReadOptions, org.rocksdb.ColumnFamilyHandle, byte[], boolean, boolean)) have not been modified outside of this transaction since the time the snapshot was set.voidsetSnapshotOnNextOperation()Similar tosetSnapshot(), but will not change the current snapshot until put/merge/delete/getForUpdate/multiGetForUpdate is called.voidsetSnapshotOnNextOperation(AbstractTransactionNotifier transactionNotifier)Similar tosetSnapshot(), but will not change the current snapshot until put/merge/delete/getForUpdate/multiGetForUpdate is called.voidsetWriteOptions(WriteOptions writeOptions)Reset the WriteOptions that will be used duringcommit().voidsingleDelete(byte[] key)Similar toRocksDB.singleDelete(byte[]), but will also perform conflict checking on the keys be written.voidsingleDelete(byte[][] keyParts)Similar tosingleDelete(byte[])but allows you to specify the key in several parts that will be concatenated together.voidsingleDelete(ColumnFamilyHandle columnFamilyHandle, byte[] key)Similar tosingleDelete(ColumnFamilyHandle, byte[], boolean)but withassumeTracked = false.voidsingleDelete(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts)Similar tosingleDelete(ColumnFamilyHandle, byte[][], boolean)but withassumeTracked = false.voidsingleDelete(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts, boolean assumeTracked)Similar tosingleDelete(ColumnFamilyHandle, byte[])but allows you to specify the key in several parts that will be concatenated together.voidsingleDelete(ColumnFamilyHandle columnFamilyHandle, byte[] key, boolean assumeTracked)Similar toRocksDB.singleDelete(ColumnFamilyHandle, byte[]), but will also perform conflict checking on the keys be written.voidundoGetForUpdate(byte[] key)If this key was previously fetched in this transaction usinggetForUpdate(ReadOptions, byte[], boolean)/multiGetForUpdate(ReadOptions, List, byte[][]), calling#undoGetForUpdate(byte[])will tell the transaction that it no longer needs to do any conflict checking for this key.voidundoGetForUpdate(ColumnFamilyHandle columnFamilyHandle, byte[] key)If this key was previously fetched in this transaction usinggetForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)/multiGetForUpdate(ReadOptions, List, byte[][]), calling#undoGetForUpdate(ColumnFamilyHandle, byte[])will tell the transaction that it no longer needs to do any conflict checking for this key.-
Methods inherited from class org.rocksdb.RocksObject
disposeInternal, getNativeHandle
-
Methods inherited from class org.rocksdb.AbstractImmutableNativeReference
close, disOwnNativeHandle, isOwningHandle
-
-
-
-
Method Detail
-
setSnapshot
public void setSnapshot()
If a transaction has a snapshot set, the transaction will ensure that any keys successfully written (or fetched viagetForUpdate(org.rocksdb.ReadOptions, org.rocksdb.ColumnFamilyHandle, byte[], boolean, boolean)) have not been modified outside of this transaction since the time the snapshot was set.If a snapshot has not been set, the transaction guarantees that keys have not been modified since the time each key was first written (or fetched via
getForUpdate(org.rocksdb.ReadOptions, org.rocksdb.ColumnFamilyHandle, byte[], boolean, boolean)).Using
#setSnapshot()will provide stricter isolation guarantees at the expense of potentially more transaction failures due to conflicts with other writes.Calling
#setSnapshot()has no effect on keys written before this function has been called.#setSnapshot()may be called multiple times if you would like to change the snapshot used for different operations in this transaction.Calling
#setSnapshot()will not affect the version of Data returned by get(...) methods. Seeget(org.rocksdb.ColumnFamilyHandle, org.rocksdb.ReadOptions, byte[])for more details.
-
setSnapshotOnNextOperation
public void setSnapshotOnNextOperation()
Similar tosetSnapshot(), but will not change the current snapshot until put/merge/delete/getForUpdate/multiGetForUpdate is called. By calling this function, the transaction will essentially callsetSnapshot()for you right before performing the next write/getForUpdate.Calling
#setSnapshotOnNextOperation()will not affect what snapshot is returned bygetSnapshot()until the next write/getForUpdate is executed.When the snapshot is created the notifier's snapshotCreated method will be called so that the caller can get access to the snapshot.
This is an optimization to reduce the likelihood of conflicts that could occur in between the time
setSnapshot()is called and the first write/getForUpdate operation. i.e. this prevents the following race-condition:txn1->setSnapshot(); txn2->put("A", ...); txn2->commit(); txn1->getForUpdate(opts, "A", ...); * FAIL!
-
setSnapshotOnNextOperation
public void setSnapshotOnNextOperation(AbstractTransactionNotifier transactionNotifier)
Similar tosetSnapshot(), but will not change the current snapshot until put/merge/delete/getForUpdate/multiGetForUpdate is called. By calling this function, the transaction will essentially callsetSnapshot()for you right before performing the next write/getForUpdate.Calling
setSnapshotOnNextOperation()will not affect what snapshot is returned bygetSnapshot()until the next write/getForUpdate is executed.When the snapshot is created the
AbstractTransactionNotifier.snapshotCreated(Snapshot)method will be called so that the caller can get access to the snapshot.This is an optimization to reduce the likelihood of conflicts that could occur in between the time
setSnapshot()is called and the first write/getForUpdate operation. i.e. this prevents the following race-condition:txn1->setSnapshot(); txn2->put("A", ...); txn2->commit(); txn1->getForUpdate(opts, "A", ...); * FAIL!
- Parameters:
transactionNotifier- A handler for receiving snapshot notifications for the transaction
-
getSnapshot
public Snapshot getSnapshot()
Returns the Snapshot created by the last call tosetSnapshot().REQUIRED: The returned Snapshot is only valid up until the next time
setSnapshot()/setSnapshotOnNextOperation()is called,clearSnapshot()is called, or the Transaction is deleted.- Returns:
- The snapshot or null if there is no snapshot
-
clearSnapshot
public void clearSnapshot()
Clears the current snapshot (i.e. no snapshot will be 'set')This removes any snapshot that currently exists or is set to be created on the next update operation (
setSnapshotOnNextOperation()).Calling
#clearSnapshot()has no effect on keys written before this function has been called.If a reference to a snapshot was retrieved via
getSnapshot(), it will no longer be valid and should be discarded after a call to#clearSnapshot().
-
prepare
public void prepare() throws RocksDBExceptionPrepare the current transaction for 2PC- Throws:
RocksDBException
-
commit
public void commit() throws RocksDBExceptionWrite all batched keys to the db atomically.Returns OK on success.
May return any error status that could be returned by DB:Write().
If this transaction was created by an
OptimisticTransactionDBStatus::Busy() may be returned if the transaction could not guarantee that there are no write conflicts. Status::TryAgain() may be returned if the memtable history size is not large enough (See max_write_buffer_number_to_maintain).If this transaction was created by a
TransactionDB, Status::Expired() may be returned if this transaction has lived for longer thanTransactionOptions.getExpiration().- Throws:
RocksDBException- if an error occurs when committing the transaction
-
rollback
public void rollback() throws RocksDBExceptionDiscard all batched writes in this transaction.- Throws:
RocksDBException- if an error occurs when rolling back the transaction
-
setSavePoint
public void setSavePoint() throws RocksDBExceptionRecords the state of the transaction for future calls torollbackToSavePoint().May be called multiple times to set multiple save points.
- Throws:
RocksDBException- if an error occurs whilst setting a save point
-
rollbackToSavePoint
public void rollbackToSavePoint() throws RocksDBExceptionUndo all operations in this transaction (put, merge, delete, putLogData) since the most recent call tosetSavePoint()and removes the most recentsetSavePoint().If there is no previous call to
setSavePoint(), returns Status::NotFound()- Throws:
RocksDBException- if an error occurs when rolling back to a save point
-
get
@Deprecated public byte[] get(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, byte[] key) throws RocksDBException
Deprecated.This function has an inconsistent parameter order compared to otherget()methods and is deprecated in favour of one with a consistent order. This function is similar toRocksDB.get(ColumnFamilyHandle, ReadOptions, byte[])except it will also read pending changes in this transaction. Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge.If
ReadOptions.snapshot()is not set, the current version of the key will be read. CallingsetSnapshot()does not affect the version of the data returned.Note that setting
ReadOptions.setSnapshot(Snapshot)will affect what is read from the DB but will NOT change which keys are read from this transaction (the keys in this transaction do not yet belong to any snapshot and will be fetched regardless).- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancereadOptions- Read options.key- the key to retrieve the value for.- Returns:
- a byte array storing the value associated with the input key if any. null if it does not find the specified key.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public byte[] get(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException
This function is similar toRocksDB.get(ColumnFamilyHandle, ReadOptions, byte[])except it will also read pending changes in this transaction. Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge. IfReadOptions.snapshot()is not set, the current version of the key will be read. CallingsetSnapshot()does not affect the version of the data returned. Note that settingReadOptions.setSnapshot(Snapshot)will affect what is read from the DB but will NOT change which keys are read from this transaction (the keys in this transaction do not yet belong to any snapshot and will be fetched regardless).- Parameters:
readOptions- Read options.columnFamilyHandle-ColumnFamilyHandleinstancekey- the key to retrieve the value for.- Returns:
- a byte array storing the value associated with the input key if any. null if it does not find the specified key.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public byte[] get(ReadOptions readOptions, byte[] key) throws RocksDBException
This function is similar toRocksDB.get(ReadOptions, byte[])except it will also read pending changes in this transaction. Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge.If
ReadOptions.snapshot()is not set, the current version of the key will be read. CallingsetSnapshot()does not affect the version of the data returned.Note that setting
ReadOptions.setSnapshot(Snapshot)will affect what is read from the DB but will NOT change which keys are read from this transaction (the keys in this transaction do not yet belong to any snapshot and will be fetched regardless).- Parameters:
readOptions- Read options.key- the key to retrieve the value for.- Returns:
- a byte array storing the value associated with the input key if any. null if it does not find the specified key.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public GetStatus get(ReadOptions opt, byte[] key, byte[] value) throws RocksDBException
Get the value associated with the specified key in the default column family- Parameters:
opt-ReadOptionsinstance.key- the key to retrieve the value.value- the out-value to receive the retrieved value.- Returns:
- A
GetStatuswrapping the result status and the return value size. IfGetStatus.statusisOkthenGetStatus.requiredSizecontains the size of the actual value that matches the specifiedkeyin byte. IfGetStatus.requiredSizeis greater than the length ofvalue, then it indicates that the size of the input buffervalueis insufficient and a partial result was returned. IfGetStatus.statusisNotFoundthis indicates that the value was not found. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public GetStatus get(ReadOptions opt, ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException
Get the value associated with the specified key in a specified column family- Parameters:
opt-ReadOptionsinstance.columnFamilyHandle- the column family to find the key inkey- the key to retrieve the value.value- the out-value to receive the retrieved value.- Returns:
- A
GetStatuswrapping the result status and the return value size. IfGetStatus.statusisOkthenGetStatus.requiredSizecontains the size of the actual value that matches the specifiedkeyin byte. IfGetStatus.requiredSizeis greater than the length ofvalue, then it indicates that the size of the input buffervalueis insufficient and a partial result was returned. IfGetStatus.statusisNotFoundthis indicates that the value was not found. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public GetStatus get(ReadOptions opt, ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value) throws RocksDBException
Get the value associated with the specified key within the specified column family.- Parameters:
opt-ReadOptionsinstance.columnFamilyHandle- the column family in which to find the key.key- the key to retrieve the value. It is using position and limit. Supports direct buffer only.value- the out-value to receive the retrieved value. It is using position and limit. Limit is set according to value size. Supports direct buffer only.- Returns:
- A
GetStatuswrapping the result status and the return value size. IfGetStatus.statusisOkthenGetStatus.requiredSizecontains the size of the actual value that matches the specifiedkeyin byte. IfGetStatus.requiredSizeis greater than the length ofvalue, then it indicates that the size of the input buffervalueis insufficient and a partial result was returned. IfGetStatus.statusisNotFoundthis indicates that the value was not found. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public GetStatus get(ReadOptions opt, java.nio.ByteBuffer key, java.nio.ByteBuffer value) throws RocksDBException
Get the value associated with the specified key within the default column family.- Parameters:
opt-ReadOptionsinstance.key- the key to retrieve the value. It is using position and limit. Supports direct buffer only.value- the out-value to receive the retrieved value. It is using position and limit. Limit is set according to value size. Supports direct buffer only.- Returns:
- A
GetStatuswrapping the result status and the return value size. IfGetStatus.statusisOkthenGetStatus.requiredSizecontains the size of the actual value that matches the specifiedkeyin byte. IfGetStatus.requiredSizeis greater than the length ofvalue, then it indicates that the size of the input buffervalueis insufficient and a partial result was returned. IfGetStatus.statusisNotFoundthis indicates that the value was not found. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
multiGet
@Deprecated public byte[][] multiGet(ReadOptions readOptions, java.util.List<ColumnFamilyHandle> columnFamilyHandles, byte[][] keys) throws RocksDBException
Deprecated.This function is similar toRocksDB.multiGetAsList(java.util.List<byte[]>)except it will also read pending changes in this transaction. Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge.If
ReadOptions.snapshot()is not set, the current version of the key will be read. CallingsetSnapshot()does not affect the version of the data returned.Note that setting
ReadOptions.setSnapshot(Snapshot)will affect what is read from the DB but will NOT change which keys are read from this transaction (the keys in this transaction do not yet belong to any snapshot and will be fetched regardless).- Parameters:
readOptions- Read options.columnFamilyHandles-ListcontainingColumnFamilyHandleinstances.keys- of keys for which values need to be retrieved.- Returns:
- Array of values, one for each key
- Throws:
RocksDBException- thrown if error happens in underlying native library.java.lang.IllegalArgumentException- thrown if the size of passed keys is not equal to the amount of passed column family handles.
-
multiGetAsList
public java.util.List<byte[]> multiGetAsList(ReadOptions readOptions, java.util.List<ColumnFamilyHandle> columnFamilyHandles, java.util.List<byte[]> keys) throws RocksDBException
This function is similar toRocksDB.multiGetAsList(ReadOptions, List, List)except it will also read pending changes in this transaction. Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge.If
ReadOptions.snapshot()is not set, the current version of the key will be read. CallingsetSnapshot()does not affect the version of the data returned.Note that setting
ReadOptions.setSnapshot(Snapshot)will affect what is read from the DB but will NOT change which keys are read from this transaction (the keys in this transaction do not yet belong to any snapshot and will be fetched regardless).- Parameters:
readOptions- Read options.columnFamilyHandles-ListcontainingColumnFamilyHandleinstances.keys- of keys for which values need to be retrieved.- Returns:
- Array of values, one for each key
- Throws:
RocksDBException- thrown if error happens in underlying native library.java.lang.IllegalArgumentException- thrown if the size of passed keys is not equal to the amount of passed column family handles.
-
multiGet
@Deprecated public byte[][] multiGet(ReadOptions readOptions, byte[][] keys) throws RocksDBException
Deprecated.This function is similar toRocksDB.multiGetAsList(java.util.List<byte[]>)except it will also read pending changes in this transaction. Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge.If
ReadOptions.snapshot()is not set, the current version of the key will be read. CallingsetSnapshot()does not affect the version of the data returned.Note that setting
ReadOptions.setSnapshot(Snapshot)will affect what is read from the DB but will NOT change which keys are read from this transaction (the keys in this transaction do not yet belong to any snapshot and will be fetched regardless).- Parameters:
readOptions- Read options.=ColumnFamilyHandleinstances.keys- of keys for which values need to be retrieved.- Returns:
- Array of values, one for each key
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
multiGetAsList
public java.util.List<byte[]> multiGetAsList(ReadOptions readOptions, java.util.List<byte[]> keys) throws RocksDBException
This function is similar toRocksDB.multiGetAsList(java.util.List<byte[]>)except it will also read pending changes in this transaction. Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge.If
ReadOptions.snapshot()is not set, the current version of the key will be read. CallingsetSnapshot()does not affect the version of the data returned.Note that setting
ReadOptions.setSnapshot(Snapshot)will affect what is read from the DB but will NOT change which keys are read from this transaction (the keys in this transaction do not yet belong to any snapshot and will be fetched regardless).- Parameters:
readOptions- Read options.=ColumnFamilyHandleinstances.keys- of keys for which values need to be retrieved.- Returns:
- Array of values, one for each key
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
getForUpdate
public byte[] getForUpdate(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, byte[] key, boolean exclusive, boolean doValidate) throws RocksDBException
Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction). The transaction behavior is the same regardless of whether the key exists or not.Note: Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge.
The values returned by this function are similar to
RocksDB.get(ColumnFamilyHandle, ReadOptions, byte[]). If value==nullptr, then this function will not read any data, but will still ensure that this key cannot be written to by outside of this transaction.If this transaction was created by an
OptimisticTransactionDB,getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)could causecommit()to fail. Otherwise, it could return any error that could be returned byRocksDB.get(ColumnFamilyHandle, ReadOptions, byte[]).If this transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()Status.Code.MergeInProgressif merge operations cannot be resolved.- Parameters:
readOptions- Read options.columnFamilyHandle-ColumnFamilyHandleinstancekey- the key to retrieve the value for.exclusive- true if the transaction should have exclusive access to the key, otherwise false for shared access.doValidate- true if it should validate the snapshot before doing the read- Returns:
- a byte array storing the value associated with the input key if any. null if it does not find the specified key.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
getForUpdate
public byte[] getForUpdate(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, byte[] key, boolean exclusive) throws RocksDBException
Same asgetForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean, boolean)with doValidate=true.- Parameters:
readOptions- Read options.columnFamilyHandle-ColumnFamilyHandleinstancekey- the key to retrieve the value for.exclusive- true if the transaction should have exclusive access to the key, otherwise false for shared access.- Returns:
- a byte array storing the value associated with the input key if any. null if it does not find the specified key.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
getForUpdate
public byte[] getForUpdate(ReadOptions readOptions, byte[] key, boolean exclusive) throws RocksDBException
Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction). The transaction behavior is the same regardless of whether the key exists or not.Note: Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge.
The values returned by this function are similar to
RocksDB.get(ReadOptions, byte[]). If value==nullptr, then this function will not read any data, but will still ensure that this key cannot be written to by outside of this transaction.If this transaction was created on an
OptimisticTransactionDB,getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)could causecommit()to fail. Otherwise, it could return any error that could be returned byRocksDB.get(ReadOptions, byte[]).If this transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()Status.Code.MergeInProgressif merge operations cannot be resolved.- Parameters:
readOptions- Read options.key- the key to retrieve the value for.exclusive- true if the transaction should have exclusive access to the key, otherwise false for shared access.- Returns:
- a byte array storing the value associated with the input key if any. null if it does not find the specified key.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
getForUpdate
public GetStatus getForUpdate(ReadOptions readOptions, byte[] key, byte[] value, boolean exclusive) throws RocksDBException
Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction). The transaction behavior is the same regardless of whether the key exists or not.Note: Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge.
The values returned by this function are similar to
RocksDB.get(ReadOptions, byte[]). If value==nullptr, then this function will not read any data, but will still ensure that this key cannot be written to by outside of this transaction.If this transaction was created on an
OptimisticTransactionDB,getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)could causecommit()to fail. Otherwise, it could return any error that could be returned byRocksDB.get(ReadOptions, byte[]).If this transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()Status.Code.MergeInProgressif merge operations cannot be resolved.- Parameters:
readOptions- Read options.key- the key to retrieve the value for.value- the value associated with the input key if * any. The result is undefined in no value is associated with the keyexclusive- true if the transaction should have exclusive access to the key, otherwise false for shared access.- Returns:
- a status object containing Status.OK if the requested value was read Status.NotFound if the requested value does not exist
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
getForUpdate
public GetStatus getForUpdate(ReadOptions readOptions, java.nio.ByteBuffer key, java.nio.ByteBuffer value, boolean exclusive) throws RocksDBException
Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction). The transaction behavior is the same regardless of whether the key exists or not.Note: Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge.
The values returned by this function are similar to
RocksDB.get(ReadOptions, byte[]). If value==nullptr, then this function will not read any data, but will still ensure that this key cannot be written to by outside of this transaction.If this transaction was created on an
OptimisticTransactionDB,getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)could causecommit()to fail. Otherwise, it could return any error that could be returned byRocksDB.get(ReadOptions, byte[]).If this transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()Status.Code.MergeInProgressif merge operations cannot be resolved.- Parameters:
readOptions- Read options.key- the key to retrieve the value for.value- the value associated with the input key if * any. The result is undefined in no value is associated with the keyexclusive- true if the transaction should have exclusive access to the key, otherwise false for shared access.- Returns:
- a status object containing Status.OK if the requested value was read Status.NotFound if the requested value does not exist
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
getForUpdate
public GetStatus getForUpdate(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value, boolean exclusive) throws RocksDBException
Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction). The transaction behavior is the same regardless of whether the key exists or not.Note: Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge.
The values returned by this function are similar to
RocksDB.get(ReadOptions, byte[]). If value==nullptr, then this function will not read any data, but will still ensure that this key cannot be written to by outside of this transaction.If this transaction was created on an
OptimisticTransactionDB,getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)could causecommit()to fail. Otherwise, it could return any error that could be returned byRocksDB.get(ReadOptions, byte[]).If this transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()Status.Code.MergeInProgressif merge operations cannot be resolved.- Parameters:
readOptions- Read options.columnFamilyHandle- in which to find the key/valuekey- the key to retrieve the value for.value- the value associated with the input key if * any. The result is undefined in no value is associated with the keyexclusive- true if the transaction should have exclusive access to the key, otherwise false for shared access.- Returns:
- a status object containing Status.OK if the requested value was read Status.NotFound if the requested value does not exist
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
getForUpdate
public GetStatus getForUpdate(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value, boolean exclusive, boolean doValidate) throws RocksDBException
Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction). The transaction behavior is the same regardless of whether the key exists or not.Note: Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge.
The values returned by this function are similar to
RocksDB.get(ReadOptions, byte[]). If value==nullptr, then this function will not read any data, but will still ensure that this key cannot be written to by outside of this transaction.If this transaction was created on an
OptimisticTransactionDB,getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)could causecommit()to fail. Otherwise, it could return any error that could be returned byRocksDB.get(ReadOptions, byte[]).If this transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()Status.Code.MergeInProgressif merge operations cannot be resolved.- Parameters:
readOptions- Read options.columnFamilyHandle- in which to find the key/valuekey- the key to retrieve the value for.value- the value associated with the input key if * any. The result is undefined in no value is associated with the keyexclusive- true if the transaction should have exclusive access to the key, otherwise false for shared access.doValidate- true if the transaction should validate the snapshot before doing the read- Returns:
- a status object containing Status.OK if the requested value was read Status.NotFound if the requested value does not exist
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
getForUpdate
public GetStatus getForUpdate(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value, boolean exclusive) throws RocksDBException
Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction). The transaction behavior is the same regardless of whether the key exists or not.Note: Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge.
The values returned by this function are similar to
RocksDB.get(ReadOptions, byte[]). If value==nullptr, then this function will not read any data, but will still ensure that this key cannot be written to by outside of this transaction.If this transaction was created on an
OptimisticTransactionDB,getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)could causecommit()to fail. Otherwise, it could return any error that could be returned byRocksDB.get(ReadOptions, byte[]).If this transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()Status.Code.MergeInProgressif merge operations cannot be resolved.- Parameters:
readOptions- Read options.columnFamilyHandle- in which to find the key/valuekey- the key to retrieve the value for.value- the value associated with the input key if * any. The result is undefined in no value is associated with the keyexclusive- true if the transaction should have exclusive access to the key, otherwise false for shared access.- Returns:
- a status object containing Status.OK if the requested value was read Status.NotFound if the requested value does not exist
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
getForUpdate
public GetStatus getForUpdate(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value, boolean exclusive, boolean doValidate) throws RocksDBException
Read this key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction). The transaction behavior is the same regardless of whether the key exists or not.Note: Currently, this function will return Status::MergeInProgress if the most recent write to the queried key in this batch is a Merge.
The values returned by this function are similar to
RocksDB.get(ReadOptions, byte[]). If value==nullptr, then this function will not read any data, but will still ensure that this key cannot be written to by outside of this transaction.If this transaction was created on an
OptimisticTransactionDB,getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)could causecommit()to fail. Otherwise, it could return any error that could be returned byRocksDB.get(ReadOptions, byte[]).If this transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()Status.Code.MergeInProgressif merge operations cannot be resolved.- Parameters:
readOptions- Read options.columnFamilyHandle- in which to find the key/valuekey- the key to retrieve the value for.value- the value associated with the input key if * any. The result is undefined in no value is associated with the keyexclusive- true if the transaction should have exclusive access to the key, otherwise false for shared access.doValidate- true if the transaction should validate the snapshot before doing the read- Returns:
- a status object containing Status.OK if the requested value was read Status.NotFound if the requested value does not exist
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
multiGetForUpdate
@Deprecated public byte[][] multiGetForUpdate(ReadOptions readOptions, java.util.List<ColumnFamilyHandle> columnFamilyHandles, byte[][] keys) throws RocksDBException
Deprecated.A multi-key version ofgetForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean).- Parameters:
readOptions- Read options.columnFamilyHandles-ColumnFamilyHandleinstanceskeys- the keys to retrieve the values for.- Returns:
- Array of values, one for each key
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
multiGetForUpdateAsList
public java.util.List<byte[]> multiGetForUpdateAsList(ReadOptions readOptions, java.util.List<ColumnFamilyHandle> columnFamilyHandles, java.util.List<byte[]> keys) throws RocksDBException
A multi-key version ofgetForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean).- Parameters:
readOptions- Read options.columnFamilyHandles-ColumnFamilyHandleinstanceskeys- the keys to retrieve the values for.- Returns:
- Array of values, one for each key
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
multiGetForUpdate
@Deprecated public byte[][] multiGetForUpdate(ReadOptions readOptions, byte[][] keys) throws RocksDBException
Deprecated.A multi-key version ofgetForUpdate(ReadOptions, byte[], boolean).- Parameters:
readOptions- Read options.keys- the keys to retrieve the values for.- Returns:
- Array of values, one for each key
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
multiGetForUpdateAsList
public java.util.List<byte[]> multiGetForUpdateAsList(ReadOptions readOptions, java.util.List<byte[]> keys) throws RocksDBException
A multi-key version ofgetForUpdate(ReadOptions, byte[], boolean).- Parameters:
readOptions- Read options.keys- the keys to retrieve the values for.- Returns:
- List of values, one for each key
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
getIterator
public RocksIterator getIterator()
Returns an iterator that will iterate on all keys in the default column family including both keys in the DB and uncommitted keys in this transaction.Caller is responsible for deleting the returned Iterator.
The returned iterator is only valid until
commit(),rollback(), orrollbackToSavePoint()is called.- Returns:
- instance of iterator object.
-
getIterator
public RocksIterator getIterator(ReadOptions readOptions)
Returns an iterator that will iterate on all keys in the default column family including both keys in the DB and uncommitted keys in this transaction. SettingReadOptions.setSnapshot(Snapshot)will affect what is read from the DB but will NOT change which keys are read from this transaction (the keys in this transaction do not yet belong to any snapshot and will be fetched regardless).Caller is responsible for deleting the returned Iterator.
The returned iterator is only valid until
commit(),rollback(), orrollbackToSavePoint()is called.- Parameters:
readOptions- Read options.- Returns:
- instance of iterator object.
-
getIterator
public RocksIterator getIterator(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle)
Returns an iterator that will iterate on all keys in the column family specified bycolumnFamilyHandleincluding both keys in the DB and uncommitted keys in this transaction.Setting
ReadOptions.setSnapshot(Snapshot)will affect what is read from the DB but will NOT change which keys are read from this transaction (the keys in this transaction do not yet belong to any snapshot and will be fetched regardless).Caller is responsible for calling
AbstractImmutableNativeReference.close()on the returned Iterator.The returned iterator is only valid until
commit(),rollback(), orrollbackToSavePoint()is called.- Parameters:
readOptions- Read options.columnFamilyHandle-ColumnFamilyHandleinstance- Returns:
- instance of iterator object.
-
getIterator
public RocksIterator getIterator(ColumnFamilyHandle columnFamilyHandle)
Returns an iterator that will iterate on all keys in the column family specified bycolumnFamilyHandleincluding both keys in the DB and uncommitted keys in this transaction.Setting
ReadOptions.setSnapshot(Snapshot)will affect what is read from the DB but will NOT change which keys are read from this transaction (the keys in this transaction do not yet belong to any snapshot and will be fetched regardless).Caller is responsible for calling
AbstractImmutableNativeReference.close()on the returned Iterator.The returned iterator is only valid until
commit(),rollback(), orrollbackToSavePoint()is called.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstance- Returns:
- instance of iterator object.
-
put
public void put(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value, boolean assumeTracked) throws RocksDBException
Similar toRocksDB.put(ColumnFamilyHandle, byte[], byte[]), but will also perform conflict checking on the keys be written.If this Transaction was created on an
OptimisticTransactionDB, these functions should always succeed.If this Transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
columnFamilyHandle- The column family to put the key/value intokey- the specified key to be inserted.value- the value associated with the specified key.assumeTracked- true when it is expected that the key is already tracked. More specifically, it means the the key was previous tracked in the same savepoint, with the same exclusive flag, and at a lower sequence number. If valid then it skips ValidateSnapshot, throws an error otherwise.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
put
public void put(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException
Similar toput(ColumnFamilyHandle, byte[], byte[], boolean)but withassumeTracked = false.Will also perform conflict checking on the keys be written.
If this Transaction was created on an
OptimisticTransactionDB, these functions should always succeed.If this Transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
columnFamilyHandle- The column family to put the key/value intokey- the specified key to be inserted.value- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
put
public void put(byte[] key, byte[] value) throws RocksDBExceptionSimilar toRocksDB.put(byte[], byte[]), but will also perform conflict checking on the keys be written.If this Transaction was created on an
OptimisticTransactionDB, these functions should always succeed.If this Transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
key- the specified key to be inserted.value- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
put
public void put(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts, byte[][] valueParts, boolean assumeTracked) throws RocksDBException
Similar toput(ColumnFamilyHandle, byte[], byte[])but allows you to specify the key and value in several parts that will be concatenated together.- Parameters:
columnFamilyHandle- The column family to put the key/value intokeyParts- the specified key to be inserted.valueParts- the value associated with the specified key.assumeTracked- true when it is expected that the key is already tracked. More specifically, it means the the key was previous tracked in the same savepoint, with the same exclusive flag, and at a lower sequence number. If valid then it skips ValidateSnapshot, throws an error otherwise.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
put
public void put(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts, byte[][] valueParts) throws RocksDBException
Similar toput(ColumnFamilyHandle, byte[][], byte[][], boolean)but with withassumeTracked = false.Allows you to specify the key and value in several parts that will be concatenated together.
- Parameters:
columnFamilyHandle- The column family to put the key/value intokeyParts- the specified key to be inserted.valueParts- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
put
public void put(java.nio.ByteBuffer key, java.nio.ByteBuffer value) throws RocksDBExceptionSimilar toRocksDB.put(byte[], byte[]), but will also perform conflict checking on the keys be written. If this Transaction was created on anOptimisticTransactionDB, these functions should always succeed. If this Transaction was created on aTransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
key- the specified key to be inserted.value- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
put
public void put(ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value, boolean assumeTracked) throws RocksDBException
Similar toRocksDB.put(byte[], byte[]), but will also perform conflict checking on the keys be written. If this Transaction was created on anOptimisticTransactionDB, these functions should always succeed. If this Transaction was created on aTransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
columnFamilyHandle- The column family to put the key/value intokey- the specified key to be inserted.value- the value associated with the specified key.assumeTracked- true when it is expected that the key is already tracked. More specifically, it means the the key was previous tracked in the same savepoint, with the same exclusive flag, and at a lower sequence number. If valid then it skips ValidateSnapshot, throws an error otherwise.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
put
public void put(ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value) throws RocksDBException
- Throws:
RocksDBException
-
put
public void put(byte[][] keyParts, byte[][] valueParts) throws RocksDBExceptionSimilar toput(byte[], byte[])but allows you to specify the key and value in several parts that will be concatenated together- Parameters:
keyParts- the specified key to be inserted.valueParts- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
merge
public void merge(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value, boolean assumeTracked) throws RocksDBException
Similar toRocksDB.merge(ColumnFamilyHandle, byte[], byte[]), but will also perform conflict checking on the keys be written.If this Transaction was created on an
OptimisticTransactionDB, these functions should always succeed.If this Transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
columnFamilyHandle- The column family to merge the key/value intokey- the specified key to be merged.value- the value associated with the specified key.assumeTracked- true when it is expected that the key is already tracked. More specifically, it means the the key was previous tracked in the same savepoint, with the same exclusive flag, and at a lower sequence number. If valid then it skips ValidateSnapshot, throws an error otherwise.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
merge
public void merge(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException
Similar tomerge(ColumnFamilyHandle, byte[], byte[], boolean)but withassumeTracked = false.Will also perform conflict checking on the keys be written.
If this Transaction was created on an
OptimisticTransactionDB, these functions should always succeed.If this Transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
columnFamilyHandle- The column family to merge the key/value intokey- the specified key to be merged.value- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
merge
public void merge(byte[] key, byte[] value) throws RocksDBExceptionSimilar toRocksDB.merge(byte[], byte[]), but will also perform conflict checking on the keys be written.If this Transaction was created on an
OptimisticTransactionDB, these functions should always succeed.If this Transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
key- the specified key to be merged.value- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
merge
public void merge(java.nio.ByteBuffer key, java.nio.ByteBuffer value) throws RocksDBExceptionSimilar toRocksDB.merge(byte[], byte[]), but will also perform conflict checking on the keys be written. If this Transaction was created on anOptimisticTransactionDB, these functions should always succeed. If this Transaction was created on aTransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
key- the specified key to be merged.value- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
merge
public void merge(ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value, boolean assumeTracked) throws RocksDBException
Similar toRocksDB.merge(byte[], byte[]), but will also perform conflict checking on the keys be written. If this Transaction was created on anOptimisticTransactionDB, these functions should always succeed. If this Transaction was created on aTransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
columnFamilyHandle- in which to apply the mergekey- the specified key to be merged.value- the value associated with the specified key.assumeTracked- expects the key be already tracked.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
merge
public void merge(ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value) throws RocksDBException
Similar toRocksDB.merge(byte[], byte[]), but will also perform conflict checking on the keys be written. If this Transaction was created on anOptimisticTransactionDB, these functions should always succeed. If this Transaction was created on aTransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
columnFamilyHandle- in which to apply the mergekey- the specified key to be merged.value- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
delete
public void delete(ColumnFamilyHandle columnFamilyHandle, byte[] key, boolean assumeTracked) throws RocksDBException
Similar toRocksDB.delete(ColumnFamilyHandle, byte[]), but will also perform conflict checking on the keys be written.If this Transaction was created on an
OptimisticTransactionDB, these functions should always succeed.If this Transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
columnFamilyHandle- The column family to delete the key/value fromkey- the specified key to be deleted.assumeTracked- true when it is expected that the key is already tracked. More specifically, it means the the key was previous tracked in the same savepoint, with the same exclusive flag, and at a lower sequence number. If valid then it skips ValidateSnapshot, throws an error otherwise.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
delete
public void delete(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException
Similar todelete(ColumnFamilyHandle, byte[], boolean)but withassumeTracked = false.Will also perform conflict checking on the keys be written.
If this Transaction was created on an
OptimisticTransactionDB, these functions should always succeed.If this Transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
columnFamilyHandle- The column family to delete the key/value fromkey- the specified key to be deleted.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
delete
public void delete(byte[] key) throws RocksDBExceptionSimilar toRocksDB.delete(byte[]), but will also perform conflict checking on the keys be written.If this Transaction was created on an
OptimisticTransactionDB, these functions should always succeed.If this Transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
key- the specified key to be deleted.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
delete
public void delete(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts, boolean assumeTracked) throws RocksDBException
Similar todelete(ColumnFamilyHandle, byte[])but allows you to specify the key in several parts that will be concatenated together.- Parameters:
columnFamilyHandle- The column family to delete the key/value fromkeyParts- the specified key to be deleted.assumeTracked- true when it is expected that the key is already tracked. More specifically, it means the the key was previous tracked in the same savepoint, with the same exclusive flag, and at a lower sequence number. If valid then it skips ValidateSnapshot, throws an error otherwise.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
delete
public void delete(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts) throws RocksDBException
Similar todelete(ColumnFamilyHandle, byte[][], boolean)but withassumeTracked = false.Allows you to specify the key in several parts that will be concatenated together.
- Parameters:
columnFamilyHandle- The column family to delete the key/value fromkeyParts- the specified key to be deleted.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
delete
public void delete(byte[][] keyParts) throws RocksDBExceptionSimilar todelete(byte[])but allows you to specify key the in several parts that will be concatenated together.- Parameters:
keyParts- the specified key to be deleted- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
singleDelete
@Experimental("Performance optimization for a very specific workload") public void singleDelete(ColumnFamilyHandle columnFamilyHandle, byte[] key, boolean assumeTracked) throws RocksDBException
Similar toRocksDB.singleDelete(ColumnFamilyHandle, byte[]), but will also perform conflict checking on the keys be written.If this Transaction was created on an
OptimisticTransactionDB, these functions should always succeed.If this Transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
columnFamilyHandle- The column family to delete the key/value fromkey- the specified key to be deleted.assumeTracked- true when it is expected that the key is already tracked. More specifically, it means the key was previously tracked in the same savepoint, with the same exclusive flag, and at a lower sequence number. If valid then it skips ValidateSnapshot, throws an error otherwise.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
singleDelete
@Experimental("Performance optimization for a very specific workload") public void singleDelete(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException
Similar tosingleDelete(ColumnFamilyHandle, byte[], boolean)but withassumeTracked = false.will also perform conflict checking on the keys be written.
If this Transaction was created on an
OptimisticTransactionDB, these functions should always succeed.If this Transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
columnFamilyHandle- The column family to delete the key/value fromkey- the specified key to be deleted.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
singleDelete
@Experimental("Performance optimization for a very specific workload") public void singleDelete(byte[] key) throws RocksDBException
Similar toRocksDB.singleDelete(byte[]), but will also perform conflict checking on the keys be written.If this Transaction was created on an
OptimisticTransactionDB, these functions should always succeed.If this Transaction was created on a
TransactionDB, anRocksDBExceptionmay be thrown with an accompanyingStatuswhen:Status.Code.Busyif there is a write conflict,Status.Code.TimedOutif a lock could not be acquired,Status.Code.TryAgainif the memtable history size is not large enough. SeeColumnFamilyOptions.maxWriteBufferNumberToMaintain()- Parameters:
key- the specified key to be deleted.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
singleDelete
@Experimental("Performance optimization for a very specific workload") public void singleDelete(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts, boolean assumeTracked) throws RocksDBException
Similar tosingleDelete(ColumnFamilyHandle, byte[])but allows you to specify the key in several parts that will be concatenated together.- Parameters:
columnFamilyHandle- The column family to delete the key/value fromkeyParts- the specified key to be deleted.assumeTracked- true when it is expected that the key is already tracked. More specifically, it means the key was previously tracked in the same savepoint, with the same exclusive flag, and at a lower sequence number. If valid then it skips ValidateSnapshot, throws an error otherwise.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
singleDelete
@Experimental("Performance optimization for a very specific workload") public void singleDelete(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts) throws RocksDBException
Similar tosingleDelete(ColumnFamilyHandle, byte[][], boolean)but withassumeTracked = false.Allows you to specify the key in several parts that will be concatenated together.
- Parameters:
columnFamilyHandle- The column family to delete the key/value fromkeyParts- the specified key to be deleted.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
singleDelete
@Experimental("Performance optimization for a very specific workload") public void singleDelete(byte[][] keyParts) throws RocksDBException
Similar tosingleDelete(byte[])but allows you to specify the key in several parts that will be concatenated together.- Parameters:
keyParts- the specified key to be deleted.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
putUntracked
public void putUntracked(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException
Similar toRocksDB.put(ColumnFamilyHandle, byte[], byte[]), but operates on the transactions write batch. This write will only happen if this transaction gets committed successfully.Unlike
put(ColumnFamilyHandle, byte[], byte[])no conflict checking will be performed for this key.If this Transaction was created on a
TransactionDB, this function will still acquire locks necessary to make sure this write doesn't cause conflicts in other transactions; This may cause aRocksDBExceptionwith associatedStatus.Code.Busy.- Parameters:
columnFamilyHandle- The column family to put the key/value intokey- the specified key to be inserted.value- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
putUntracked
public void putUntracked(byte[] key, byte[] value) throws RocksDBExceptionSimilar toRocksDB.put(byte[], byte[]), but operates on the transactions write batch. This write will only happen if this transaction gets committed successfully.Unlike
put(byte[], byte[])no conflict checking will be performed for this key.If this Transaction was created on a
TransactionDB, this function will still acquire locks necessary to make sure this write doesn't cause conflicts in other transactions; This may cause aRocksDBExceptionwith associatedStatus.Code.Busy.- Parameters:
key- the specified key to be inserted.value- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
putUntracked
public void putUntracked(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts, byte[][] valueParts) throws RocksDBException
Similar toputUntracked(ColumnFamilyHandle, byte[], byte[])but allows you to specify the key and value in several parts that will be concatenated together.- Parameters:
columnFamilyHandle- The column family to put the key/value intokeyParts- the specified key to be inserted.valueParts- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
putUntracked
public void putUntracked(byte[][] keyParts, byte[][] valueParts) throws RocksDBExceptionSimilar toputUntracked(byte[], byte[])but allows you to specify the key and value in several parts that will be concatenated together.- Parameters:
keyParts- the specified key to be inserted.valueParts- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
mergeUntracked
public void mergeUntracked(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException
Similar toRocksDB.merge(ColumnFamilyHandle, byte[], byte[]), but operates on the transactions write batch. This write will only happen if this transaction gets committed successfully.Unlike
merge(ColumnFamilyHandle, byte[], byte[])no conflict checking will be performed for this key.If this Transaction was created on a
TransactionDB, this function will still acquire locks necessary to make sure this write doesn't cause conflicts in other transactions; This may cause aRocksDBExceptionwith associatedStatus.Code.Busy.- Parameters:
columnFamilyHandle- The column family to merge the key/value intokey- the specified key to be merged.value- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
mergeUntracked
public void mergeUntracked(ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value) throws RocksDBException
Similar toRocksDB.merge(ColumnFamilyHandle, byte[], byte[]), but operates on the transactions write batch. This write will only happen if this transaction gets committed successfully. Unlikemerge(ColumnFamilyHandle, byte[], byte[])no conflict checking will be performed for this key. If this Transaction was created on aTransactionDB, this function will still acquire locks necessary to make sure this write doesn't cause conflicts in other transactions; This may cause aRocksDBExceptionwith associatedStatus.Code.Busy.- Parameters:
columnFamilyHandle- The column family to merge the key/value intokey- the specified key to be merged.value- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
mergeUntracked
public void mergeUntracked(byte[] key, byte[] value) throws RocksDBExceptionSimilar toRocksDB.merge(byte[], byte[]), but operates on the transactions write batch. This write will only happen if this transaction gets committed successfully.Unlike
merge(byte[], byte[])no conflict checking will be performed for this key.If this Transaction was created on a
TransactionDB, this function will still acquire locks necessary to make sure this write doesn't cause conflicts in other transactions; This may cause aRocksDBExceptionwith associatedStatus.Code.Busy.- Parameters:
key- the specified key to be merged.value- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
mergeUntracked
public void mergeUntracked(java.nio.ByteBuffer key, java.nio.ByteBuffer value) throws RocksDBExceptionSimilar toRocksDB.merge(byte[], byte[]), but operates on the transactions write batch. This write will only happen if this transaction gets committed successfully. Unlikemerge(byte[], byte[])no conflict checking will be performed for this key. If this Transaction was created on aTransactionDB, this function will still acquire locks necessary to make sure this write doesn't cause conflicts in other transactions; This may cause aRocksDBExceptionwith associatedStatus.Code.Busy.- Parameters:
key- the specified key to be merged.value- the value associated with the specified key.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
deleteUntracked
public void deleteUntracked(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException
Similar toRocksDB.delete(ColumnFamilyHandle, byte[]), but operates on the transactions write batch. This write will only happen if this transaction gets committed successfully.Unlike
delete(ColumnFamilyHandle, byte[])no conflict checking will be performed for this key.If this Transaction was created on a
TransactionDB, this function will still acquire locks necessary to make sure this write doesn't cause conflicts in other transactions; This may cause aRocksDBExceptionwith associatedStatus.Code.Busy.- Parameters:
columnFamilyHandle- The column family to delete the key/value fromkey- the specified key to be deleted.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
deleteUntracked
public void deleteUntracked(byte[] key) throws RocksDBExceptionSimilar toRocksDB.delete(byte[]), but operates on the transactions write batch. This write will only happen if this transaction gets committed successfully.Unlike
delete(byte[])no conflict checking will be performed for this key.If this Transaction was created on a
TransactionDB, this function will still acquire locks necessary to make sure this write doesn't cause conflicts in other transactions; This may cause aRocksDBExceptionwith associatedStatus.Code.Busy.- Parameters:
key- the specified key to be deleted.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
deleteUntracked
public void deleteUntracked(ColumnFamilyHandle columnFamilyHandle, byte[][] keyParts) throws RocksDBException
Similar todeleteUntracked(ColumnFamilyHandle, byte[])but allows you to specify the key in several parts that will be concatenated together.- Parameters:
columnFamilyHandle- The column family to delete the key/value fromkeyParts- the specified key to be deleted.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
deleteUntracked
public void deleteUntracked(byte[][] keyParts) throws RocksDBExceptionSimilar todeleteUntracked(byte[])but allows you to specify the key in several parts that will be concatenated together.- Parameters:
keyParts- the specified key to be deleted.- Throws:
RocksDBException- when one of the TransactionalDB conditions described above occurs, or in the case of an unexpected error
-
putLogData
public void putLogData(byte[] blob)
Similar toAbstractWriteBatch.putLogData(byte[])- Parameters:
blob- binary object to be inserted
-
disableIndexing
public void disableIndexing()
By default, all put/merge/delete operations will be indexed in the transaction so that get/getForUpdate/getIterator can search for these keys.If the caller does not want to fetch the keys about to be written, they may want to avoid indexing as a performance optimization. Calling
#disableIndexing()will turn off indexing for all future put/merge/delete operations untilenableIndexing()is called.If a key is put/merge/deleted after
#disableIndexing()is called and then is fetched via get/getForUpdate/getIterator, the result of the fetch is undefined.
-
enableIndexing
public void enableIndexing()
Re-enables indexing after a previous call todisableIndexing()
-
getNumKeys
public long getNumKeys()
Returns the number of distinct Keys being tracked by this transaction. If this transaction was created by aTransactionDB, this is the number of keys that are currently locked by this transaction. If this transaction was created by anOptimisticTransactionDB, this is the number of keys that need to be checked for conflicts at commit time.- Returns:
- the number of distinct Keys being tracked by this transaction
-
getNumPuts
public long getNumPuts()
Returns the number of puts that have been applied to this transaction so far.- Returns:
- the number of puts that have been applied to this transaction
-
getNumDeletes
public long getNumDeletes()
Returns the number of deletes that have been applied to this transaction so far.- Returns:
- the number of deletes that have been applied to this transaction
-
getNumMerges
public long getNumMerges()
Returns the number of merges that have been applied to this transaction so far.- Returns:
- the number of merges that have been applied to this transaction
-
getElapsedTime
public long getElapsedTime()
Returns the elapsed time in milliseconds since this Transaction began.- Returns:
- the elapsed time in milliseconds since this transaction began.
-
getWriteBatch
public WriteBatchWithIndex getWriteBatch()
Fetch the underlying write batch that contains all pending changes to be committed.Note: You should not write or delete anything from the batch directly and should only use the functions in the
Transactionclass to write to this transaction.- Returns:
- The write batch
-
setLockTimeout
public void setLockTimeout(long lockTimeout)
Change the value ofTransactionOptions.getLockTimeout()(in milliseconds) for this transaction.Has no effect on OptimisticTransactions.
- Parameters:
lockTimeout- the timeout (in milliseconds) for locks used by this transaction.
-
getWriteOptions
public WriteOptions getWriteOptions()
Return the WriteOptions that will be used duringcommit().- Returns:
- the WriteOptions that will be used
-
setWriteOptions
public void setWriteOptions(WriteOptions writeOptions)
Reset the WriteOptions that will be used duringcommit().- Parameters:
writeOptions- The new WriteOptions
-
undoGetForUpdate
public void undoGetForUpdate(ColumnFamilyHandle columnFamilyHandle, byte[] key)
If this key was previously fetched in this transaction usinggetForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)/multiGetForUpdate(ReadOptions, List, byte[][]), calling#undoGetForUpdate(ColumnFamilyHandle, byte[])will tell the transaction that it no longer needs to do any conflict checking for this key.If a key has been fetched N times via
getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)/multiGetForUpdate(ReadOptions, List, byte[][]), then#undoGetForUpdate(ColumnFamilyHandle, byte[])will only have an effect if it is also called N times. If this key has been written to in this transaction,#undoGetForUpdate(ColumnFamilyHandle, byte[])will have no effect.If
setSavePoint()has been called after thegetForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean),#undoGetForUpdate(ColumnFamilyHandle, byte[])will not have any effect.If this Transaction was created by an
OptimisticTransactionDB, calling#undoGetForUpdate(ColumnFamilyHandle, byte[])can affect whether this key is conflict checked at commit time. If this Transaction was created by aTransactionDB, calling#undoGetForUpdate(ColumnFamilyHandle, byte[])may release any held locks for this key.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- the key to retrieve the value for.
-
undoGetForUpdate
public void undoGetForUpdate(byte[] key)
If this key was previously fetched in this transaction usinggetForUpdate(ReadOptions, byte[], boolean)/multiGetForUpdate(ReadOptions, List, byte[][]), calling#undoGetForUpdate(byte[])will tell the transaction that it no longer needs to do any conflict checking for this key.If a key has been fetched N times via
getForUpdate(ReadOptions, byte[], boolean)/multiGetForUpdate(ReadOptions, List, byte[][]), then#undoGetForUpdate(byte[])will only have an effect if it is also called N times. If this key has been written to in this transaction,#undoGetForUpdate(byte[])will have no effect.If
setSavePoint()has been called after thegetForUpdate(ReadOptions, byte[], boolean),#undoGetForUpdate(byte[])will not have any effect.If this Transaction was created by an
OptimisticTransactionDB, calling#undoGetForUpdate(byte[])can affect whether this key is conflict checked at commit time. If this Transaction was created by aTransactionDB, calling#undoGetForUpdate(byte[])may release any held locks for this key.- Parameters:
key- the key to retrieve the value for.
-
rebuildFromWriteBatch
public void rebuildFromWriteBatch(WriteBatch writeBatch) throws RocksDBException
Adds the keys from the WriteBatch to the transaction- Parameters:
writeBatch- The write batch to read from- Throws:
RocksDBException- if an error occurs whilst rebuilding from the write batch.
-
getCommitTimeWriteBatch
public WriteBatch getCommitTimeWriteBatch()
Get the Commit time Write Batch.- Returns:
- the commit time write batch.
-
setLogNumber
public void setLogNumber(long logNumber)
Set the log number.- Parameters:
logNumber- the log number
-
getLogNumber
public long getLogNumber()
Get the log number.- Returns:
- the log number
-
setName
public void setName(java.lang.String transactionName) throws RocksDBExceptionSet the name of the transaction.- Parameters:
transactionName- the name of the transaction- Throws:
RocksDBException- if an error occurs when setting the transaction name.
-
getName
public java.lang.String getName()
Get the name of the transaction.- Returns:
- the name of the transaction
-
getID
public long getID()
Get the ID of the transaction.- Returns:
- the ID of the transaction.
-
isDeadlockDetect
public boolean isDeadlockDetect()
Determine if a deadlock has been detected.- Returns:
- true if a deadlock has been detected.
-
getWaitingTxns
public Transaction.WaitingTransactions getWaitingTxns()
Get the list of waiting transactions.- Returns:
- The list of waiting transactions.
-
getState
public Transaction.TransactionState getState()
Get the execution status of the transaction.NOTE: The execution status of an Optimistic Transaction never changes. This is only useful for non-optimistic transactions!
- Returns:
- The execution status of the transaction
-
getId
@Experimental("NOTE: Experimental feature") public long getId()
The globally unique id with which the transaction is identified. This id might or might not be set depending on the implementation. Similarly the implementation decides the point in lifetime of a transaction at which it assigns the id. Although currently it is the case, the id is not guaranteed to remain the same across restarts.- Returns:
- the transaction id.
-
disposeInternal
protected final void disposeInternal(long handle)
- Specified by:
disposeInternalin classRocksObject
-
-