Package org.rocksdb
Class WriteBatch
- All Implemented Interfaces:
AutoCloseable,WriteBatchInterface
WriteBatch holds a collection of updates to apply atomically to a DB.
The updates are applied in the order in which they are added to the WriteBatch. For example, the value of "key" will be "v3" after the following batch is written:
batch.put("key", "v1"); batch.remove("key"); batch.put("key", "v2"); batch.put("key", "v3");
Multiple threads can invoke const methods on a WriteBatch without external synchronization, but if any of the threads may call a non-const method, all threads accessing the same WriteBatch must use external synchronization.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHandler callback for iterating over the contents of a batch.static classA structure for describing the save point in the Write Batch. -
Field Summary
Fields inherited from class org.rocksdb.RocksObject
nativeHandle_Fields inherited from class org.rocksdb.AbstractImmutableNativeReference
owningHandle_ -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a WriteBatch instance.WriteBatch(byte[] serialized) Constructs a WriteBatch instance from a serialized representation as returned bydata().WriteBatch(int reserved_bytes) Constructs a WriteBatch instance with a given size. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]data()Retrieve the serialized version of this batch.protected final voiddisposeInternal(long handle) longRetrieve data size of the batch.Gets the WAL termination point.Get the underlying Write Batch.booleanReturns true if MarkBeginPrepare will be called during Iterate.booleanReturns true if MarkCommit will be called during Iterate.booleanReturns true if Delete will be called during Iterate.booleanReturns true if DeleteRange will be called during Iterate.booleanReturns true if MarkEndPrepare will be called during Iterate.booleanhasMerge()Returns true if Merge will be called during Iterate.booleanhasPut()Returns true if Put will be called during Iterate.booleanReturns true if MarkRollback will be called during Iterate.booleanReturns true if SingleDelete will be called during Iterate.voiditerate(WriteBatch.Handler handler) Support for iterating over the contents of a batch.voidMarks this point in the WriteBatch as the last record to be inserted into the WAL, provided the WAL is enabled.Methods inherited from class org.rocksdb.AbstractWriteBatch
clear, count, delete, delete, delete, delete, deleteRange, deleteRange, merge, merge, popSavePoint, put, put, put, put, putLogData, rollbackToSavePoint, setMaxBytes, setSavePoint, singleDelete, singleDeleteMethods inherited from class org.rocksdb.RocksObject
disposeInternal, getNativeHandleMethods inherited from class org.rocksdb.AbstractImmutableNativeReference
close, disOwnNativeHandle, isOwningHandle
-
Constructor Details
-
WriteBatch
public WriteBatch()Constructs a WriteBatch instance. -
WriteBatch
public WriteBatch(int reserved_bytes) Constructs a WriteBatch instance with a given size.- Parameters:
reserved_bytes- reserved size for WriteBatch
-
WriteBatch
public WriteBatch(byte[] serialized) Constructs a WriteBatch instance from a serialized representation as returned bydata().- Parameters:
serialized- the serialized representation.
-
-
Method Details
-
iterate
Support for iterating over the contents of a batch.- Parameters:
handler- A handler that is called back for each update present in the batch- Throws:
RocksDBException- If we cannot iterate over the batch
-
data
Retrieve the serialized version of this batch.- Returns:
- the serialized representation of this write batch.
- Throws:
RocksDBException- if an error occurs whilst retrieving the serialized batch data.
-
getDataSize
public long getDataSize()Retrieve data size of the batch.- Returns:
- the serialized data size of the batch.
-
hasPut
public boolean hasPut()Returns true if Put will be called during Iterate.- Returns:
- true if Put will be called during Iterate.
-
hasDelete
public boolean hasDelete()Returns true if Delete will be called during Iterate.- Returns:
- true if Delete will be called during Iterate.
-
hasSingleDelete
public boolean hasSingleDelete()Returns true if SingleDelete will be called during Iterate.- Returns:
- true if SingleDelete will be called during Iterate.
-
hasDeleteRange
public boolean hasDeleteRange()Returns true if DeleteRange will be called during Iterate.- Returns:
- true if DeleteRange will be called during Iterate.
-
hasMerge
public boolean hasMerge()Returns true if Merge will be called during Iterate.- Returns:
- true if Merge will be called during Iterate.
-
hasBeginPrepare
public boolean hasBeginPrepare()Returns true if MarkBeginPrepare will be called during Iterate.- Returns:
- true if MarkBeginPrepare will be called during Iterate.
-
hasEndPrepare
public boolean hasEndPrepare()Returns true if MarkEndPrepare will be called during Iterate.- Returns:
- true if MarkEndPrepare will be called during Iterate.
-
hasCommit
public boolean hasCommit()Returns true if MarkCommit will be called during Iterate.- Returns:
- true if MarkCommit will be called during Iterate.
-
hasRollback
public boolean hasRollback()Returns true if MarkRollback will be called during Iterate.- Returns:
- true if MarkRollback will be called during Iterate.
-
getWriteBatch
Description copied from interface:WriteBatchInterfaceGet the underlying Write Batch.- Specified by:
getWriteBatchin interfaceWriteBatchInterface- Overrides:
getWriteBatchin classAbstractWriteBatch- Returns:
- the underlying WriteBatch.
-
markWalTerminationPoint
public void markWalTerminationPoint()Marks this point in the WriteBatch as the last record to be inserted into the WAL, provided the WAL is enabled. -
getWalTerminationPoint
Gets the WAL termination point.- Returns:
- the WAL termination point
-
disposeInternal
protected final void disposeInternal(long handle) - Specified by:
disposeInternalin classRocksObject
-