public interface WriteBatchInterface
Defines the interface for a Write Batch which holds a collection of updates to apply atomically to a DB.
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear all updates buffered in this batch
|
int |
count()
Returns the number of updates in the batch.
|
void |
delete(byte[] key)
If the database contains a mapping for "key", erase it.
|
void |
delete(ColumnFamilyHandle columnFamilyHandle,
byte[] key)
If column family contains a mapping for "key", erase it.
|
void |
deleteRange(byte[] beginKey,
byte[] endKey)
Removes the database entries in the range ["beginKey", "endKey"), i.e.,
including "beginKey" and excluding "endKey".
|
void |
deleteRange(ColumnFamilyHandle columnFamilyHandle,
byte[] beginKey,
byte[] endKey)
Removes the database entries in the range ["beginKey", "endKey"), i.e.,
including "beginKey" and excluding "endKey".
|
WriteBatch |
getWriteBatch()
Get the underlying Write Batch.
|
void |
merge(byte[] key,
byte[] value)
Merge "value" with the existing value of "key" in the database.
|
void |
merge(ColumnFamilyHandle columnFamilyHandle,
byte[] key,
byte[] value)
Merge "value" with the existing value of "key" in given column family.
|
void |
popSavePoint()
Pop the most recent save point.
|
void |
put(byte[] key,
byte[] value)
Store the mapping "key->value" in the database.
|
void |
put(java.nio.ByteBuffer key,
java.nio.ByteBuffer value)
Store the mapping "key->value" within given column
family.
|
void |
put(ColumnFamilyHandle columnFamilyHandle,
byte[] key,
byte[] value)
Store the mapping "key->value" within given column
family.
|
void |
put(ColumnFamilyHandle columnFamilyHandle,
java.nio.ByteBuffer key,
java.nio.ByteBuffer value)
Store the mapping "key->value" within given column
family.
|
void |
putLogData(byte[] blob)
Append a blob of arbitrary size to the records in this batch.
|
void |
remove(byte[] key)
Deprecated.
Use
delete(byte[]) |
void |
remove(java.nio.ByteBuffer key)
If column family contains a mapping for "key", erase it.
|
void |
remove(ColumnFamilyHandle columnFamilyHandle,
byte[] key)
Deprecated.
|
void |
remove(ColumnFamilyHandle columnFamilyHandle,
java.nio.ByteBuffer key)
If column family contains a mapping for "key", erase it.
|
void |
rollbackToSavePoint()
Remove all entries in this batch (Put, Merge, Delete, PutLogData) since
the most recent call to SetSavePoint() and removes the most recent save
point.
|
void |
setMaxBytes(long maxBytes)
Set the maximum size of the write batch.
|
void |
setSavePoint()
Records the state of the batch for future calls to RollbackToSavePoint().
|
void |
singleDelete(byte[] key)
Remove the database entry for
key . |
void |
singleDelete(ColumnFamilyHandle columnFamilyHandle,
byte[] key)
Remove the database entry for
key . |
int count()
void put(byte[] key, byte[] value) throws RocksDBException
Store the mapping "key->value" in the database.
key
- the specified key to be inserted.value
- the value associated with the specified key.RocksDBException
- thrown if error happens in underlying native library.void put(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException
Store the mapping "key->value" within given column family.
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- the specified key to be inserted.value
- the value associated with the specified key.RocksDBException
- thrown if error happens in underlying native library.void put(java.nio.ByteBuffer key, java.nio.ByteBuffer value) throws RocksDBException
Store the mapping "key->value" within given column family.
key
- the specified key to be inserted. It is using position and limit.
Supports direct buffer only.value
- the value associated with the specified key. It is using position and limit.
Supports direct buffer only.RocksDBException
void put(ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value) throws RocksDBException
Store the mapping "key->value" within given column family.
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- the specified key to be inserted. It is using position and limit.
Supports direct buffer only.value
- the value associated with the specified key. It is using position and limit.
Supports direct buffer only.RocksDBException
void merge(byte[] key, byte[] value) throws RocksDBException
Merge "value" with the existing value of "key" in the database. "key->merge(existing, value)"
key
- the specified key to be merged.value
- the value to be merged with the current value for
the specified key.RocksDBException
- thrown if error happens in underlying native library.void merge(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException
Merge "value" with the existing value of "key" in given column family. "key->merge(existing, value)"
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- the specified key to be merged.value
- the value to be merged with the current value for
the specified key.RocksDBException
- thrown if error happens in underlying native library.@Deprecated void remove(byte[] key) throws RocksDBException
delete(byte[])
If the database contains a mapping for "key", erase it. Else do nothing.
key
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying native library.@Deprecated void remove(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException
delete(ColumnFamilyHandle, byte[])
If column family contains a mapping for "key", erase it. Else do nothing.
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying native library.void delete(byte[] key) throws RocksDBException
If the database contains a mapping for "key", erase it. Else do nothing.
key
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying native library.void delete(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException
If column family contains a mapping for "key", erase it. Else do nothing.
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying native library.@Experimental(value="Performance optimization for a very specific workload") void singleDelete(byte[] key) throws RocksDBException
key
. Requires that the key exists
and was not overwritten. It is not an error if the key did not exist
in the database.
If a key is overwritten (by calling put(byte[], byte[])
multiple
times), then the result of calling SingleDelete() on this key is undefined.
SingleDelete() only behaves correctly if there has been only one Put()
for this key since the previous call to SingleDelete() for this key.
This feature is currently an experimental performance optimization
for a very specific workload. It is up to the caller to ensure that
SingleDelete is only used for a key that is not deleted using Delete() or
written using Merge(). Mixing SingleDelete operations with Deletes and
Merges can result in undefined behavior.key
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.@Experimental(value="Performance optimization for a very specific workload") void singleDelete(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException
key
. Requires that the key exists
and was not overwritten. It is not an error if the key did not exist
in the database.
If a key is overwritten (by calling put(byte[], byte[])
multiple
times), then the result of calling SingleDelete() on this key is undefined.
SingleDelete() only behaves correctly if there has been only one Put()
for this key since the previous call to SingleDelete() for this key.
This feature is currently an experimental performance optimization
for a very specific workload. It is up to the caller to ensure that
SingleDelete is only used for a key that is not deleted using Delete() or
written using Merge(). Mixing SingleDelete operations with Deletes and
Merges can result in undefined behavior.columnFamilyHandle
- The column family to delete the key fromkey
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.void remove(java.nio.ByteBuffer key) throws RocksDBException
If column family contains a mapping for "key", erase it. Else do nothing.
key
- Key to delete within database. It is using position and limit.
Supports direct buffer only.RocksDBException
void remove(ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key) throws RocksDBException
If column family contains a mapping for "key", erase it. Else do nothing.
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- Key to delete within database. It is using position and limit.
Supports direct buffer only.RocksDBException
void deleteRange(byte[] beginKey, byte[] endKey) throws RocksDBException
beginKey
- First key to delete within database (included)endKey
- Last key to delete within database (excluded)RocksDBException
- thrown if error happens in underlying native library.void deleteRange(ColumnFamilyHandle columnFamilyHandle, byte[] beginKey, byte[] endKey) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancebeginKey
- First key to delete within database (included)endKey
- Last key to delete within database (excluded)RocksDBException
- thrown if error happens in underlying native library.void putLogData(byte[] blob) throws RocksDBException
blob
- binary object to be insertedRocksDBException
- thrown if error happens in underlying native library.void clear()
void setSavePoint()
void rollbackToSavePoint() throws RocksDBException
RocksDBException
- if there is no previous call to SetSavePoint()void popSavePoint() throws RocksDBException
setSavePoint()
.RocksDBException
- If there is no previous call to
setSavePoint()
, an exception with
Status.Code.NotFound
will be thrown.void setMaxBytes(long maxBytes)
maxBytes
- the maximum size in bytes.WriteBatch getWriteBatch()