Class WalIterator
- Namespace
- RocksDbNet
- Assembly
- RocksDb.Net.dll
Walks the write-ahead log from a given sequence number, yielding the batches
that were written.
Maps to rocksdb_wal_iterator_t.
public sealed class WalIterator : RocksDbHandle, IDisposable
- Inheritance
-
WalIterator
- Implements
- Inherited Members
Remarks
Useful for replication and change-data-capture: each step gives the batch and the sequence number it started at. Only records still present in the WAL are visible, so a sequence number older than the oldest retained log is an error rather than an empty result.
Methods
AsEnumerable()
Enumerates the remaining records, disposing each batch once the consumer has moved past it.
public IEnumerable<(WriteBatch Batch, ulong Sequence)> AsEnumerable()
Returns
Remarks
Do not hold on to a batch beyond its iteration step. Use GetBatch() directly if you need to keep one.
CheckForError()
Throws if the iterator has encountered an error.
public void CheckForError()
Exceptions
- RocksDbException
Reading the log failed.
DisposeHandle()
Releases the native handle. Called during disposal.
protected override void DisposeHandle()
Remarks
Protected rather than public: it destroys the native object without marking this instance disposed or clearing the handle, so calling it from outside and then disposing normally would free the same pointer twice. It was the most Dispose-looking member on the type. Callers want Dispose().
GetBatch()
Returns the batch at the current position, along with the sequence number of its first record.
public (WriteBatch Batch, ulong Sequence) GetBatch()
Returns
Remarks
RocksDb builds a fresh batch for each call, so the returned WriteBatch belongs to the caller and must be disposed.
IsValid()
Whether the iterator currently points at a record.
public bool IsValid()
Returns
Next()
Advances to the next record.
public void Next()