Class Transaction
- All Implemented Interfaces:
AutoCloseable
To use transactions, you must first create either an
OptimisticTransactionDB or a TransactionDB
To create a transaction, use
OptimisticTransactionDB.beginTransaction(org.rocksdb.WriteOptions) or
TransactionDB.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 ClassesModifier and TypeClassDescriptionstatic enumstatic class -
Field Summary
Fields inherited from class org.rocksdb.RocksObject
nativeHandle_Fields inherited from class org.rocksdb.AbstractImmutableNativeReference
owningHandle_ -
Method Summary
Modifier and TypeMethodDescriptionvoidClears 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.voidBy default, all put/merge/delete operations will be indexed in the transaction so that get/getForUpdate/getIterator can search for these keys.protected final voiddisposeInternal(long handle) voidRe-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.get(ReadOptions opt, byte[] key, byte[] value) Get the value associated with the specified key in the default column familyget(ReadOptions opt, ByteBuffer key, 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.get(ReadOptions opt, ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) Get the value associated with the specified key in a specified column familyget(ReadOptions opt, ColumnFamilyHandle columnFamilyHandle, ByteBuffer key, ByteBuffer value) Get the value associated with the specified key within the specified column family.Get the Commit time Write Batch.longReturns 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).getForUpdate(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).getForUpdate(ReadOptions readOptions, ByteBuffer key, 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).getForUpdate(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).getForUpdate(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).getForUpdate(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, ByteBuffer key, 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).getForUpdate(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, ByteBuffer key, 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.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.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.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.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.longGet the log number.getName()Get the name of the transaction.longReturns the number of deletes that have been applied to this transaction so far.longReturns the number of distinct Keys being tracked by this transaction.longReturns the number of merges that have been applied to this transaction so far.longReturns the number of puts that have been applied to this transaction so far.Returns the Snapshot created by the last call tosetSnapshot().getState()Get the execution status of the transaction.Get the list of waiting transactions.Fetch the underlying write batch that contains all pending changes to be committed.Return the WriteOptions that will be used duringcommit().booleanDetermine 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(ByteBuffer key, 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, ByteBuffer key, ByteBuffer value) Similar toRocksDB.merge(byte[], byte[]), but will also perform conflict checking on the keys be written.voidmerge(ColumnFamilyHandle columnFamilyHandle, ByteBuffer key, 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(ByteBuffer key, 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, ByteBuffer key, 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, List<ColumnFamilyHandle> columnFamilyHandles, byte[][] keys) Deprecated.List<byte[]> multiGetAsList(ReadOptions readOptions, List<byte[]> keys) This function is similar toRocksDB.multiGetAsList(java.util.List<byte[]>)except it will also read pending changes in this transaction.List<byte[]> multiGetAsList(ReadOptions readOptions, List<ColumnFamilyHandle> columnFamilyHandles, 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, List<ColumnFamilyHandle> columnFamilyHandles, byte[][] keys) Deprecated.List<byte[]> multiGetForUpdateAsList(ReadOptions readOptions, List<byte[]> keys) A multi-key version ofgetForUpdate(ReadOptions, byte[], boolean).List<byte[]> multiGetForUpdateAsList(ReadOptions readOptions, List<ColumnFamilyHandle> columnFamilyHandles, 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(ByteBuffer key, 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, ByteBuffer key, ByteBuffer value) voidput(ColumnFamilyHandle columnFamilyHandle, ByteBuffer key, 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.voidUndo 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.voidSet the name of the transaction.voidRecords the state of the transaction for future calls torollbackToSavePoint().voidIf 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.voidSimilar 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, getNativeHandleMethods inherited from class org.rocksdb.AbstractImmutableNativeReference
close, disOwnNativeHandle, isOwningHandle
-
Method Details
-
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
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
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
Prepare the current transaction for 2PC- Throws:
RocksDBException
-
commit
Write 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
Discard all batched writes in this transaction.- Throws:
RocksDBException- if an error occurs when rolling back the transaction
-
setSavePoint
Records 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
Undo 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
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
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, ByteBuffer key, 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
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, 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.IllegalArgumentException- thrown if the size of passed keys is not equal to the amount of passed column family handles.
-
multiGetAsList
public List<byte[]> multiGetAsList(ReadOptions readOptions, List<ColumnFamilyHandle> columnFamilyHandles, 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.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 List<byte[]> multiGetAsList(ReadOptions readOptions, 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, ByteBuffer key, 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, ByteBuffer key, 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, ByteBuffer key, 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, 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 List<byte[]> multiGetForUpdateAsList(ReadOptions readOptions, List<ColumnFamilyHandle> columnFamilyHandles, 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 List<byte[]> multiGetForUpdateAsList(ReadOptions readOptions, 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
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
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
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
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
Similar 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
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:
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, ByteBuffer key, 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, ByteBuffer key, ByteBuffer value) throws RocksDBException - Throws:
RocksDBException
-
put
Similar 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
Similar 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
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:
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, ByteBuffer key, 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, ByteBuffer key, 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
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
Similar 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
Similar 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
Similar 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
Similar 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, ByteBuffer key, 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
Similar 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
Similar 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
Similar 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
Similar 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
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
Return the WriteOptions that will be used duringcommit().- Returns:
- the WriteOptions that will be used
-
setWriteOptions
Reset the WriteOptions that will be used duringcommit().- Parameters:
writeOptions- The new WriteOptions
-
undoGetForUpdate
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
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
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
Set the name of the transaction.- Parameters:
transactionName- the name of the transaction- Throws:
RocksDBException- if an error occurs when setting the transaction name.
-
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
Get the list of waiting transactions.- Returns:
- The list of waiting transactions.
-
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
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
-