Versions in this module Expand all Collapse all v0 v0.0.3 Aug 15, 2022 Changes in this version + const BitDiscardEarlierVersions + const DEBUG + const ERROR + const FILE_ATTRIBUTE_TEMPORARY — windows/amd64 + const FILE_FLAG_DELETE_ON_CLOSE — windows/amd64 + const INFO + const KeyRegistryFileName + const KeyRegistryRewriteFileName + const ManifestFilename + const ValueThresholdLimit + const WARNING + var DefaultIteratorOptions = IteratorOptions + var ErrBannedKey = errors.New("Key is using the banned prefix") + var ErrBlockedWrites = errors.New("Writes are blocked, possibly due to DropAll or Close") + var ErrConflict = errors.New("Transaction Conflict. Please retry") + var ErrDBClosed = errors.New("DB Closed") + var ErrDiscardedTxn = errors.New("This transaction has been discarded. Create a new one") + var ErrEmptyKey = errors.New("Key cannot be empty") + var ErrEncryptionKeyMismatch = errors.New("Encryption key mismatch") + var ErrGCInMemoryMode = errors.New("Cannot run value log GC when DB is opened in InMemory mode") + var ErrInternalPanic = errors.New("failed to initialize db directory") + var ErrInvalidDataKeyID = errors.New("Invalid datakey id") + var ErrInvalidDump = errors.New("Data dump cannot be read") + var ErrInvalidEncryptionKey = errors.New(...) + var ErrInvalidKey = errors.New("Key is using a reserved !badger! prefix") + var ErrInvalidRequest = errors.New("Invalid request") + var ErrKeyNotFound = errors.New("Key not found") + var ErrManagedTxn = errors.New("Invalid API request. Not allowed to perform this action using ManagedDB") + var ErrNamespaceMode = errors.New(...) + var ErrNilCallback = errors.New("Callback cannot be nil") + var ErrNoRewrite = errors.New("Value log GC attempt didn't result in any cleanup") + var ErrPlan9NotSupported = errors.New("Read-only mode is not supported on Plan 9") + var ErrReadOnlyTxn = errors.New("No sets or deletes are allowed in a read-only transaction") + var ErrRejected = errors.New("Value log GC request rejected") + var ErrThresholdZero = errors.New("Value log GC can't run because threshold is set to zero") + var ErrTruncateNeeded = errors.New("Log truncate required to run DB. This might result in data loss") + var ErrTxnTooBig = errors.New("Txn is too big to fit into one request") + var ErrValueLogSize = errors.New("Invalid ValueLogFileSize, must be in range [1MB, 2GB)") + var ErrWindowsNotSupported = errors.New("Read-only mode is not supported on Windows") + var ErrZeroBandwidth = errors.New("Bandwidth must be greater than zero") + func BufferToKVList(buf *z.Buffer) (*pb.KVList, error) + func GetCurOpt() string + func InitDiscardStats(opt Options) (*discardStats, error) + func KVToBuffer(kv *pb.KV, buf *z.Buffer) + func SetCurOpt(opt Options) + func ValidEntry(db *DB, key, val []byte) error + func WriteKeyRegistry(reg *KeyRegistry, opt KeyRegistryOptions) error + type CacheType int + const BlockCache + const IndexCache + type DB struct + func Open(opt Options) (*DB, error) + func OpenManaged(opts Options) (*DB, error) + func (db *DB) Backup(w io.Writer, since uint64) (uint64, error) + func (db *DB) BanNamespace(ns uint64) error + func (db *DB) BannedNamespaces() []uint64 + func (db *DB) BlockCacheMetrics() *ristretto.Metrics + func (db *DB) CacheMaxCost(cache CacheType, maxCost int64) (int64, error) + func (db *DB) Close() error + func (db *DB) DropAll() error + func (db *DB) DropPrefix(prefixes ...[]byte) error + func (db *DB) DropPrefixBlocking(prefixes ...[]byte) error + func (db *DB) DropPrefixNonBlocking(prefixes ...[]byte) error + func (db *DB) EstimateSize(prefix []byte) (uint64, uint64) + func (db *DB) Flatten(workers int) error + func (db *DB) GetMergeOperator(key []byte, f MergeFunc, dur time.Duration) *MergeOperator + func (db *DB) GetSequence(key []byte, bandwidth uint64) (*Sequence, error) + func (db *DB) HandoverSkiplist(skl *skl.Skiplist, callback func()) error + func (db *DB) IndexCacheMetrics() *ristretto.Metrics + func (db *DB) IsClosed() bool + func (db *DB) Levels() []LevelInfo + func (db *DB) LevelsToString() string + func (db *DB) Load(r io.Reader, maxPendingWrites int) error + func (db *DB) MaxBatchCount() int64 + func (db *DB) MaxBatchSize() int64 + func (db *DB) MaxVersion() uint64 + func (db *DB) NewKVLoader(maxPendingWrites int) *KVLoader + func (db *DB) NewManagedWriteBatch() *WriteBatch + func (db *DB) NewSkiplist() *skl.Skiplist + func (db *DB) NewStream() *Stream + func (db *DB) NewStreamAt(readTs uint64) *Stream + func (db *DB) NewStreamWriter() *StreamWriter + func (db *DB) NewTransaction(update bool) *Txn + func (db *DB) NewTransactionAt(readTs uint64, update bool) *Txn + func (db *DB) NewWriteBatch() *WriteBatch + func (db *DB) NewWriteBatchAt(commitTs uint64) *WriteBatch + func (db *DB) Opts() Options + func (db *DB) PrintHistogram(keyPrefix []byte) + func (db *DB) Ranges(prefix []byte, numRanges int) []*keyRange + func (db *DB) RunValueLogGC(discardRatio float64) error + func (db *DB) SetDiscardTs(ts uint64) + func (db *DB) Size() (lsm, vlog int64) + func (db *DB) StreamDB(outOptions Options) error + func (db *DB) Subscribe(ctx context.Context, cb func(kv *KVList) error, matches []pb.Match) error + func (db *DB) Sync() error + func (db *DB) Tables() []TableInfo + func (db *DB) Update(fn func(txn *Txn) error) error + func (db *DB) VerifyChecksum() error + func (db *DB) View(fn func(txn *Txn) error) error + type Entry struct + ExpiresAt uint64 + Key []byte + UserMeta byte + Value []byte + func NewEntry(key, value []byte) *Entry + func (e *Entry) WithDiscard() *Entry + func (e *Entry) WithMeta(meta byte) *Entry + func (e *Entry) WithTTL(dur time.Duration) *Entry + type Item struct + func (item *Item) DiscardEarlierVersions() bool + func (item *Item) EstimatedSize() int64 + func (item *Item) ExpiresAt() uint64 + func (item *Item) IsDeletedOrExpired() bool + func (item *Item) Key() []byte + func (item *Item) KeyCopy(dst []byte) []byte + func (item *Item) KeySize() int64 + func (item *Item) String() string + func (item *Item) UserMeta() byte + func (item *Item) Value(fn func(val []byte) error) error + func (item *Item) ValueCopy(dst []byte) ([]byte, error) + func (item *Item) ValueSize() int64 + func (item *Item) Version() uint64 + type Iterator struct + Alloc *z.Allocator + ThreadId int + func (it *Iterator) Close() + func (it *Iterator) Item() *Item + func (it *Iterator) Next() + func (it *Iterator) Rewind() + func (it *Iterator) Seek(key []byte) uint64 + func (it *Iterator) Valid() bool + func (it *Iterator) ValidForPrefix(prefix []byte) bool + type IteratorOptions struct + AllVersions bool + InternalAccess bool + PrefetchSize int + PrefetchValues bool + Prefix []byte + Reverse bool + SinceTs uint64 + type KVList = pb.KVList + type KVLoader struct + func (l *KVLoader) Finish() error + func (l *KVLoader) Set(kv *pb.KV) error + type KeyRegistry struct + func OpenKeyRegistry(opt KeyRegistryOptions) (*KeyRegistry, error) + func (kr *KeyRegistry) AddKey(dk pb.DataKey) (uint64, error) + func (kr *KeyRegistry) Close() error + func (kr *KeyRegistry) DataKey(id uint64) (*pb.DataKey, error) + func (kr *KeyRegistry) LatestDataKey() (*pb.DataKey, error) + type KeyRegistryOptions struct + Dir string + EncryptionKey []byte + EncryptionKeyRotationDuration time.Duration + InMemory bool + ReadOnly bool + type LevelInfo struct + Adjusted float64 + IsBaseLevel bool + Level int + NumTables int + Score float64 + Size int64 + StaleDatSize int64 + TargetFileSize int64 + TargetSize int64 + type Logger interface + Debugf func(string, ...interface{}) + Errorf func(string, ...interface{}) + Infof func(string, ...interface{}) + Warningf func(string, ...interface{}) + type Manifest struct + Creations int + Deletions int + Levels []levelManifest + Tables map[uint64]TableManifest + func ReplayManifestFile(fp *os.File, extMagic uint16) (Manifest, int64, error) + type MergeFunc func(existingVal, newVal []byte) []byte + type MergeOperator struct + func (op *MergeOperator) Add(val []byte) error + func (op *MergeOperator) Get() ([]byte, error) + func (op *MergeOperator) Stop() + type Options struct + AllowStopTheWorld bool + BaseLevelSize int64 + BaseTableSize int64 + BlockCacheSize int64 + BlockSize int + BloomFalsePositive float64 + BypassLockGuard bool + ChecksumVerificationMode options.ChecksumVerificationMode + CompactL0OnClose bool + Compression options.CompressionType + DetectConflicts bool + Dir string + EncryptionKey []byte + EncryptionKeyRotationDuration time.Duration + ExternalMagicVersion uint16 + InMemory bool + IndexCacheSize int64 + LevelSizeMultiplier int + LmaxCompaction bool + Logger Logger + MaxLevels int + MemTableSize int64 + MetricsEnabled bool + NamespaceOffset int + NumCompactors int + NumGoroutines int + NumLevelZeroTables int + NumLevelZeroTablesStall int + NumMemtables int + NumVersionsToKeep int + ReadOnly bool + SyncWrites bool + TableSizeMultiplier int + VLogPercentile float64 + ValueDir string + ValueLogFileSize int64 + ValueLogMaxEntries uint32 + ValueThreshold int64 + VerifyValueChecksum bool + ZSTDCompressionLevel int + func DefaultOptions(path string) Options + func LSMOnlyOptions(path string) Options + func (opt *Options) Debugf(format string, v ...interface{}) + func (opt *Options) Errorf(format string, v ...interface{}) + func (opt *Options) Infof(format string, v ...interface{}) + func (opt *Options) Warningf(format string, v ...interface{}) + func (opt Options) FromSuperFlag(superflag string) Options + func (opt Options) WithAllowStopTheWorld(b bool) Options + func (opt Options) WithBaseLevelSize(val int64) Options + func (opt Options) WithBaseTableSize(val int64) Options + func (opt Options) WithBlockCacheSize(size int64) Options + func (opt Options) WithBlockSize(val int) Options + func (opt Options) WithBloomFalsePositive(val float64) Options + func (opt Options) WithBypassLockGuard(b bool) Options + func (opt Options) WithChecksumVerificationMode(cvMode options.ChecksumVerificationMode) Options + func (opt Options) WithCompactL0OnClose(val bool) Options + func (opt Options) WithCompression(cType options.CompressionType) Options + func (opt Options) WithDetectConflicts(b bool) Options + func (opt Options) WithDir(val string) Options + func (opt Options) WithEncryptionKey(key []byte) Options + func (opt Options) WithEncryptionKeyRotationDuration(d time.Duration) Options + func (opt Options) WithExternalMagic(magic uint16) Options + func (opt Options) WithInMemory(b bool) Options + func (opt Options) WithIndexCacheSize(size int64) Options + func (opt Options) WithLevelSizeMultiplier(val int) Options + func (opt Options) WithLogger(val Logger) Options + func (opt Options) WithLoggingLevel(val loggingLevel) Options + func (opt Options) WithMaxLevels(val int) Options + func (opt Options) WithMemTableSize(val int64) Options + func (opt Options) WithMetricsEnabled(val bool) Options + func (opt Options) WithNamespaceOffset(offset int) Options + func (opt Options) WithNumCompactors(val int) Options + func (opt Options) WithNumGoroutines(val int) Options + func (opt Options) WithNumLevelZeroTables(val int) Options + func (opt Options) WithNumLevelZeroTablesStall(val int) Options + func (opt Options) WithNumMemtables(val int) Options + func (opt Options) WithNumVersionsToKeep(val int) Options + func (opt Options) WithReadOnly(val bool) Options + func (opt Options) WithSyncWrites(val bool) Options + func (opt Options) WithVLogPercentile(t float64) Options + func (opt Options) WithValueDir(val string) Options + func (opt Options) WithValueLogFileSize(val int64) Options + func (opt Options) WithValueLogMaxEntries(val uint32) Options + func (opt Options) WithValueThreshold(val int64) Options + func (opt Options) WithVerifyValueChecksum(val bool) Options + func (opt Options) WithZSTDCompressionLevel(cLevel int) Options + type Sequence struct + func (seq *Sequence) Next() (uint64, error) + func (seq *Sequence) Release() error + type Stream struct + ChooseKey func(item *Item) bool + FullCopy bool + KeyToList func(key []byte, itr *Iterator) (*pb.KVList, error) + LogPrefix string + NumGo int + Prefix []byte + Send func(buf *z.Buffer) error + SinceTs uint64 + func (st *Stream) Orchestrate(ctx context.Context) error + func (st *Stream) SendDoneMarkers(done bool) + func (st *Stream) ToList(key []byte, itr *Iterator) (*pb.KVList, error) + func (stream *Stream) Backup(w io.Writer, since uint64) (uint64, error) + type StreamWriter struct + func (sw *StreamWriter) Cancel() + func (sw *StreamWriter) Flush() error + func (sw *StreamWriter) Prepare() error + func (sw *StreamWriter) PrepareIncremental() error + func (sw *StreamWriter) Write(buf *z.Buffer) error + type TableInfo struct + BloomFilterSize int + ID uint64 + IndexSz int + KeyCount uint32 + Left []byte + Level int + MaxVersion uint64 + OnDiskSize uint32 + Right []byte + StaleDataSize uint32 + UncompressedSize uint32 + type TableManifest struct + Compression options.CompressionType + KeyID uint64 + Level uint8 + type Txn struct + func (txn *Txn) Commit() error + func (txn *Txn) CommitAt(commitTs uint64, callback func(error)) error + func (txn *Txn) CommitWith(cb func(error)) + func (txn *Txn) Delete(key []byte) error + func (txn *Txn) Discard() + func (txn *Txn) Discarded() bool + func (txn *Txn) Get(key []byte) (item *Item, rerr error) + func (txn *Txn) NewIterator(opt IteratorOptions) *Iterator + func (txn *Txn) NewKeyIterator(key []byte, opt IteratorOptions) *Iterator + func (txn *Txn) ReadTs() uint64 + func (txn *Txn) Set(key, val []byte) error + func (txn *Txn) SetEntry(e *Entry) error + type WriteBatch struct + func (wb *WriteBatch) Cancel() + func (wb *WriteBatch) Delete(k []byte) error + func (wb *WriteBatch) DeleteAt(k []byte, ts uint64) error + func (wb *WriteBatch) Error() error + func (wb *WriteBatch) Flush() error + func (wb *WriteBatch) Set(k, v []byte) error + func (wb *WriteBatch) SetEntry(e *Entry) error + func (wb *WriteBatch) SetEntryAt(e *Entry, ts uint64) error + func (wb *WriteBatch) SetMaxPendingTxns(max int) + func (wb *WriteBatch) Write(buf *z.Buffer) error + func (wb *WriteBatch) WriteList(kvList *pb.KVList) error