Documentation
¶
Overview ¶
Package kvstore defines a shared, minimal key/value store API used across gomap engines (HashDB, TreeDB, BTreeOnHashDB) and tooling like cmd/unified_bench.
Iterator semantics (performance-first):
- Key() and Value() may return read-only views into underlying storage.
- Returned slices are valid until the next Next()/Close() call on that iterator.
- Callers must not retain or modify returned views across iterator movement.
- Use KeyCopy/ValueCopy for caller-owned stable bytes.
Index ¶
- Constants
- Variables
- type Batch
- type BatchRangeDeleter
- type BatchReader
- type Batcher
- type DB
- type ForEacher
- type Haser
- type Iterator
- type MultiGetViewFunc
- type MultiGetter
- type MultiGetterView
- type Printer
- type RangeDeleteModeReporter
- type RangeScanner
- type ReadSnapshot
- type ReadSnapshotter
- type StatsProvider
- type Syncer
Constants ¶
const ( // RangeDeleteModeNative indicates the adapter uses an engine-native range // deletion primitive for DeleteRange batches. RangeDeleteModeNative = "native" // RangeDeleteModeFallbackIteratorDelete indicates the adapter expands // DeleteRange into iterator-driven point deletes. RangeDeleteModeFallbackIteratorDelete = "fallback_iterator_delete" )
Variables ¶
var ErrUnsupported = errors.New("kvstore: unsupported")
ErrUnsupported is returned by optional capabilities that are not implemented by a particular engine (e.g. ordered iteration for HashDB).
Functions ¶
This section is empty.
Types ¶
type Batch ¶
type Batch interface {
Set(key, value []byte) error
Delete(key []byte) error
Commit() error
CommitSync() error
Close() error
}
Batch is a buffered write unit.
type BatchRangeDeleter ¶ added in v0.6.0
BatchRangeDeleter is an optional batch capability for half-open range deletion. Start is inclusive, end is exclusive; nil bounds mean unbounded when the underlying engine supports that. Implementations that emulate range deletion with iteration/point deletes should report that via RangeDeleteModeReporter rather than claiming native parity.
type BatchReader ¶ added in v0.4.0
BatchReader is an optional capability for batched read execution where callers only need completion/error, not materialized values.
Semantics:
- Missing keys are not errors (same model as GetMany nil entries).
- Duplicate keys are not errors (implementations may deduplicate).
- Empty key slices are a no-op and must return nil.
- If a batch-read mechanism is unavailable for the current DB state (for example, snapshot acquisition fails), return ErrUnsupported.
- Errors should represent batch-level failures, not per-key absence.
type DB ¶
type DB interface {
Name() string
Close() error
Get(key []byte) ([]byte, error)
Set(key, value []byte) error
Delete(key []byte) error
}
DB is the minimal common interface shared across all engines.
type ForEacher ¶
ForEacher is an optional capability for visiting all live key/value pairs. Iteration order is engine-defined and may be arbitrary.
type Iterator ¶
type Iterator interface {
Valid() bool
Next()
Key() []byte
Value() []byte
KeyCopy(dst []byte) []byte
ValueCopy(dst []byte) []byte
Error() error
Close() error
}
Iterator is a forward-only iterator over key/value pairs.
Key()/Value() may return read-only views that are valid only until the next Next()/Close() on the same iterator. KeyCopy()/ValueCopy() return caller-owned stable bytes, reusing dst capacity when possible.
type MultiGetViewFunc ¶ added in v0.6.0
MultiGetViewFunc receives one MultiGetterView result. The callback order is unspecified and implementations may invoke callbacks concurrently; callers that mutate shared state must synchronize it. The index argument identifies the input key. The value slice is a read-only view that is valid only until the callback returns; callers must copy it before retaining. Missing keys are reported with found=false and value=nil.
type MultiGetter ¶ added in v0.4.0
MultiGetter is an optional capability for batched point reads.
type MultiGetterView ¶ added in v0.6.0
type MultiGetterView interface {
GetManyView(keys [][]byte, fn MultiGetViewFunc) error
}
MultiGetterView is an optional lower-allocation batched point-read capability for callers that can consume each value before the callback returns.
type Printer ¶
type Printer interface {
Print() error
}
Printer is an optional capability for debug printing.
type RangeDeleteModeReporter ¶ added in v0.6.0
type RangeDeleteModeReporter interface {
RangeDeleteMode() string
}
RangeDeleteModeReporter reports whether batch DeleteRange is native or a fallback path for benchmark/reporting consumers.
type RangeScanner ¶
type RangeScanner interface {
Iterator(start, end []byte) (Iterator, error)
ReverseIterator(start, end []byte) (Iterator, error)
}
RangeScanner is an optional capability for ordered iteration over a key domain. Start is inclusive, End is exclusive; nil means unbounded.
type ReadSnapshot ¶ added in v0.4.0
type ReadSnapshot interface {
Get(key []byte) ([]byte, error)
GetAppend(key, dst []byte) ([]byte, error)
Close() error
}
ReadSnapshot is an optional point-read snapshot used by benchmarks to measure snapshot-amortized read throughput.
type ReadSnapshotter ¶ added in v0.4.0
type ReadSnapshotter interface {
AcquireReadSnapshot() (ReadSnapshot, error)
}
ReadSnapshotter is an optional capability for acquiring a point-read snapshot that can be reused across many reads.
type StatsProvider ¶
StatsProvider is an optional capability for exposing engine stats.