public abstract class AbstractWriteBatch extends RocksObject implements WriteBatchInterface
nativeHandle_owningHandle_| 限定符 | 构造器和说明 |
|---|---|
protected |
AbstractWriteBatch(long nativeHandle) |
| 限定符和类型 | 方法和说明 |
|---|---|
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(java.nio.ByteBuffer key)
If column family contains a mapping for "key", erase it.
|
void |
delete(ColumnFamilyHandle columnFamilyHandle,
byte[] key)
If column family contains a mapping for "key", erase it.
|
void |
delete(ColumnFamilyHandle columnFamilyHandle,
java.nio.ByteBuffer 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". a non-OK status on error.
|
void |
deleteRange(ColumnFamilyHandle columnFamilyHandle,
byte[] beginKey,
byte[] endKey)
Removes the database entries in the range ["beginKey", "endKey"), i.e.,
including "beginKey" and excluding "endKey". a non-OK status on error.
|
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 |
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. |
disposeInternal, disposeInternal, getNativeHandleclose, disOwnNativeHandle, isOwningHandlepublic int count()
WriteBatchInterfacecount 在接口中 WriteBatchInterfacepublic void put(byte[] key,
byte[] value)
throws RocksDBException
WriteBatchInterfaceStore the mapping "key->value" in the database.
put 在接口中 WriteBatchInterfacekey - the specified key to be inserted.value - the value associated with the specified key.RocksDBException - thrown if error happens in underlying native library.public void put(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException
WriteBatchInterfaceStore the mapping "key->value" within given column family.
put 在接口中 WriteBatchInterfacecolumnFamilyHandle - 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.public void merge(byte[] key,
byte[] value)
throws RocksDBException
WriteBatchInterfaceMerge "value" with the existing value of "key" in the database. "key->merge(existing, value)"
merge 在接口中 WriteBatchInterfacekey - 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.public void merge(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException
WriteBatchInterfaceMerge "value" with the existing value of "key" in given column family. "key->merge(existing, value)"
merge 在接口中 WriteBatchInterfacecolumnFamilyHandle - 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.public void put(java.nio.ByteBuffer key,
java.nio.ByteBuffer value)
throws RocksDBException
WriteBatchInterfaceStore the mapping "key->value" within given column family.
put 在接口中 WriteBatchInterfacekey - 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 - thrown if error happens in underlying native library.public void put(ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key, java.nio.ByteBuffer value) throws RocksDBException
WriteBatchInterfaceStore the mapping "key->value" within given column family.
put 在接口中 WriteBatchInterfacecolumnFamilyHandle - 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 - thrown if error happens in underlying native library.public void delete(byte[] key)
throws RocksDBException
WriteBatchInterfaceIf the database contains a mapping for "key", erase it. Else do nothing.
delete 在接口中 WriteBatchInterfacekey - Key to delete within databaseRocksDBException - thrown if error happens in underlying native library.public void delete(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException
WriteBatchInterfaceIf column family contains a mapping for "key", erase it. Else do nothing.
delete 在接口中 WriteBatchInterfacecolumnFamilyHandle - ColumnFamilyHandle instancekey - Key to delete within databaseRocksDBException - thrown if error happens in underlying native library.public void delete(java.nio.ByteBuffer key)
throws RocksDBException
WriteBatchInterfaceIf column family contains a mapping for "key", erase it. Else do nothing.
delete 在接口中 WriteBatchInterfacekey - Key to delete within database. It is using position and limit.
Supports direct buffer only.RocksDBException - thrown if error happens in underlying native library.public void delete(ColumnFamilyHandle columnFamilyHandle, java.nio.ByteBuffer key) throws RocksDBException
WriteBatchInterfaceIf column family contains a mapping for "key", erase it. Else do nothing.
delete 在接口中 WriteBatchInterfacecolumnFamilyHandle - ColumnFamilyHandle instancekey - Key to delete within database. It is using position and limit.
Supports direct buffer only.RocksDBException - thrown if error happens in underlying native library.public void singleDelete(byte[] key)
throws RocksDBException
WriteBatchInterfacekey. 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 WriteBatchInterface.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.
singleDelete 在接口中 WriteBatchInterfacekey - Key to delete within databaseRocksDBException - thrown if error happens in underlying
native library.public void singleDelete(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException
WriteBatchInterfacekey. 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 WriteBatchInterface.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.
singleDelete 在接口中 WriteBatchInterfacecolumnFamilyHandle - The column family to delete the key fromkey - Key to delete within databaseRocksDBException - thrown if error happens in underlying
native library.public void deleteRange(byte[] beginKey,
byte[] endKey)
throws RocksDBException
WriteBatchInterfaceDelete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.
deleteRange 在接口中 WriteBatchInterfacebeginKey - First key to delete within database (included)endKey - Last key to delete within database (excluded)RocksDBException - thrown if error happens in underlying native library.public void deleteRange(ColumnFamilyHandle columnFamilyHandle, byte[] beginKey, byte[] endKey) throws RocksDBException
WriteBatchInterfaceDelete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.
deleteRange 在接口中 WriteBatchInterfacecolumnFamilyHandle - 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.public void putLogData(byte[] blob)
throws RocksDBException
WriteBatchInterfaceExample application: add timestamps to the transaction log for use in replication.
putLogData 在接口中 WriteBatchInterfaceblob - binary object to be insertedRocksDBException - thrown if error happens in underlying native library.public void clear()
WriteBatchInterfaceclear 在接口中 WriteBatchInterfacepublic void setSavePoint()
WriteBatchInterfacesetSavePoint 在接口中 WriteBatchInterfacepublic void rollbackToSavePoint()
throws RocksDBException
WriteBatchInterfacerollbackToSavePoint 在接口中 WriteBatchInterfaceRocksDBException - if there is no previous call to SetSavePoint()public void popSavePoint()
throws RocksDBException
WriteBatchInterface
That is to say that it removes the last save point,
which was set by WriteBatchInterface.setSavePoint().
popSavePoint 在接口中 WriteBatchInterfaceRocksDBException - If there is no previous call to
WriteBatchInterface.setSavePoint(), an exception with
Status.Code.NotFound will be thrown.public void setMaxBytes(long maxBytes)
WriteBatchInterfacesetMaxBytes 在接口中 WriteBatchInterfacemaxBytes - the maximum size in bytes.public WriteBatch getWriteBatch()
WriteBatchInterfacegetWriteBatch 在接口中 WriteBatchInterface