Documentation
¶
Index ¶
- Variables
- func Release(b *Batch)
- type Batch
- func (b *Batch) ByteSize() int
- func (b *Batch) Close() error
- func (b *Batch) Delete(key []byte) error
- func (b *Batch) DeleteView(key []byte) error
- func (b *Batch) Ops() map[string]Entry
- func (b *Batch) Replay(fn func(Entry) error) error
- func (b *Batch) Reserve(n int)
- func (b *Batch) Reset()
- func (b *Batch) Set(key, value []byte) error
- func (b *Batch) SetOps(ops []Entry) error
- func (b *Batch) SetPointer(key []byte, ptr page.ValuePtr) error
- func (b *Batch) SetPointerView(key []byte, ptr page.ValuePtr) error
- func (b *Batch) SetView(key, value []byte) error
- func (b *Batch) SlabWriteBytes() int
- func (b *Batch) SlabWriteBytesByFile() map[uint32]int64
- func (b *Batch) SortedEntries() []Entry
- type Entry
- type Interface
- type OpType
Constants ¶
This section is empty.
Variables ¶
var ( ErrKeyEmpty = errors.New("key cannot be empty") ErrBatchClosed = errors.New("batch closed") )
Functions ¶
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch accumulates writes and deletes before committing them.
func Acquire ¶
func Acquire(sm *slab.SlabManager, threshold int) *Batch
Acquire returns a reusable Batch from the pool.
func (*Batch) DeleteView ¶
DeleteView is an internal-performance helper that records a Delete without copying the key bytes. Callers must treat key as immutable until the batch is committed (Write/WriteSync) or closed.
func (*Batch) Ops ¶
Ops returns the map of operations. WARNING: This constructs the map on demand. Duplicate keys in the batch are resolved so the last one wins.
func (*Batch) Reserve ¶ added in v0.2.0
Reserve grows internal buffers to accommodate roughly n entries without reallocation. It is intended as a best-effort performance hint for high-throughput internal callers (e.g. flush).
func (*Batch) Reset ¶
func (b *Batch) Reset()
Reset clears the batch for reuse without releasing its internal buffers.
func (*Batch) SetPointer ¶
SetPointer adds a pointer directly to the batch (used by Compaction).
func (*Batch) SetPointerView ¶ added in v0.2.0
SetPointerView is an internal-performance helper that records a pointer Put without copying the key bytes. Callers must treat key as immutable until the batch is committed (Write/WriteSync) or closed.
This is intentionally not part of the public batch.Interface; it is a best-effort optimization used by higher-level layers (e.g. cached flush streaming).
func (*Batch) SetView ¶
SetView is an internal-performance helper that records a Put without copying key/value bytes. Callers must treat key/value as immutable until the batch is committed (Write/WriteSync) or closed.
func (*Batch) SlabWriteBytes ¶
SlabWriteBytes returns the number of bytes written to the slab file.
func (*Batch) SlabWriteBytesByFile ¶
SlabWriteBytesByFile returns a per-slab breakdown of bytes appended during this batch. The returned map must be treated as read-only by callers.
func (*Batch) SortedEntries ¶
SortedEntries returns the operations sorted by key. Duplicate keys are resolved (last write wins). This modifies the internal entries slice (sorts and compacts).
type Entry ¶
type Entry struct {
Type OpType
Key []byte
Value []byte // For inline values
ValuePtr page.ValuePtr // For large values
IsPtr bool // True if ValuePtr is valid
}
Entry represents a single operation in the batch.