Documentation
¶
Index ¶
- Constants
- type Config
- type Database
- func (d *Database) Backup(w io.Writer, since uint64) (uint64, error)
- func (d *Database) Close() error
- func (d *Database) Compact(start []byte, limit []byte) error
- func (d *Database) Delete(key []byte) error
- func (d *Database) Empty() (bool, error)
- func (d *Database) FlushGPUCache() error
- func (d *Database) GPUCacheEnabled() bool
- func (d *Database) GPUCacheStats() *gpuCacheStats
- func (d *Database) Get(key []byte) ([]byte, error)
- func (d *Database) GetSnapshot() (database.Database, error)
- func (d *Database) Has(key []byte) (bool, error)
- func (d *Database) HealthCheck(ctx context.Context) (interface{}, error)
- func (d *Database) InvalidateGPUCache()
- func (d *Database) Len() (int, error)
- func (d *Database) Load(r io.Reader) error
- func (d *Database) NewBatch() database.Batch
- func (d *Database) NewIterator() database.Iterator
- func (d *Database) NewIteratorWithPrefix(prefix []byte) database.Iterator
- func (d *Database) NewIteratorWithStart(start []byte) database.Iterator
- func (d *Database) NewIteratorWithStartAndPrefix(start, prefix []byte) database.Iterator
- func (d *Database) Put(key []byte, value []byte) error
- func (d *Database) Sync() error
Constants ¶
const Name = "zapdb"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
SyncWrites bool `json:"syncWrites"`
NumCompactors int `json:"numCompactors"`
NumMemtables int `json:"numMemtables"`
MemTableSize int64 `json:"memTableSize"`
ValueLogFileSize int64 `json:"valueLogFileSize"`
ValueLogMaxEntries uint32 `json:"valueLogMaxEntries"`
BlockCacheSize int64 `json:"blockCacheSize"`
IndexCacheSize int64 `json:"indexCacheSize"`
BloomFalsePositive float64 `json:"bloomFalsePositive"`
ValueThreshold int `json:"valueThreshold"`
Compression string `json:"compression"`
ZSTDCompressionLevel int `json:"zstdCompressionLevel"`
}
Config represents BadgerDB configuration
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is a badgerdb backed database with optional GPU-accelerated caching. When GPUCacheConfig.GPUMemoryBudget > 0, hot data is kept in a GPU-resident hash table for O(1) lookups. Reads hit GPU cache first, then fall through to disk. Writes go through to both GPU cache and disk (write-through).
func New ¶
func New(file string, configBytes []byte, namespace string, metrics metric.Registerer) (*Database, error)
New returns a new badgerdb-backed database
func NewWithGPU ¶ added in v1.17.45
func NewWithGPU(file string, configBytes []byte, namespace string, metrics metric.Registerer, gpuCfg GPUCacheConfig) (*Database, error)
NewWithGPU returns a new badgerdb-backed database with optional GPU caching. When gpuCfg.GPUMemoryBudget > 0, a GPU-accelerated cache is initialized that keeps hot key-value pairs in GPU memory for fast access. All existing database tests pass identically with and without GPU caching.
func (*Database) Empty ¶
Empty returns true if the database doesn't contain any keys (but not deleted keys)
func (*Database) FlushGPUCache ¶ added in v1.17.45
FlushGPUCache flushes all dirty GPU cache entries to disk. No-op if GPU caching is disabled.
func (*Database) GPUCacheEnabled ¶ added in v1.17.45
GPUCacheEnabled returns true if GPU caching is active.
func (*Database) GPUCacheStats ¶ added in v1.17.45
func (d *Database) GPUCacheStats() *gpuCacheStats
GPUCacheStats returns GPU cache statistics, or nil if GPU caching is disabled.
func (*Database) GetSnapshot ¶
GetSnapshot implements the database.Database interface
func (*Database) HealthCheck ¶
HealthCheck returns nil if the database is healthy, non-nil otherwise.
func (*Database) InvalidateGPUCache ¶ added in v1.17.45
func (d *Database) InvalidateGPUCache()
InvalidateGPUCache clears the GPU cache without affecting disk data. No-op if GPU caching is disabled.
func (*Database) NewIterator ¶
NewIterator implements the Database interface
func (*Database) NewIteratorWithPrefix ¶
NewIteratorWithPrefix implements the Database interface
func (*Database) NewIteratorWithStart ¶
NewIteratorWithStart implements the Database interface
func (*Database) NewIteratorWithStartAndPrefix ¶
NewIteratorWithStartAndPrefix implements the Database interface