kv

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package kv implements a key-value engine.

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultScanOpts is a helper to provides canonical options for scanning.
	DefaultScanOpts = ScanOpts{
		PrefetchSize:   100,
		PrefetchValues: true,
	}
)
View Source
var (

	// ErrKeyNotFound denotes the expected key can not be got from the kv service.
	ErrKeyNotFound = badger.ErrKeyNotFound
)

Functions

This section is empty.

Types

type IndexOptions

type IndexOptions func(store IndexStore)

IndexOptions sets options for creating the index store.

func IndexWithLogger

func IndexWithLogger(l *logger.Logger) IndexOptions

IndexWithLogger sets a external logger into underlying IndexStore.

type IndexStore

type IndexStore interface {
	Iterable
	Reader
	Close() error
	SizeOnDisk() int64
}

IndexStore allows writing and reading index format data.

func OpenIndexStore

func OpenIndexStore(path string, options ...IndexOptions) (IndexStore, error)

OpenIndexStore creates a new IndexStore.

type Iterable

type Iterable interface {
	NewIterator(opt ScanOpts) Iterator
}

Iterable allows creating a Iterator.

type Iterator

type Iterator interface {
	Next()
	Rewind()
	Seek(key []byte)
	Key() []byte
	RawKey() []byte
	Val() []byte
	Valid() bool
	Close() error
}

Iterator allows iterating the kv tables. TODO: use generic to provide a unique iterator.

type Reader

type Reader interface {
	Iterable
	// Get a value by its key
	Get(key []byte) ([]byte, error)
	GetAll(key []byte, applyFn func([]byte) error) error
	Scan(prefix, seekKey []byte, opt ScanOpts, f ScanFunc) error
}

Reader allows retrieving data from kv.

type ScanFunc

type ScanFunc func(key []byte, getVal func() ([]byte, error)) error

ScanFunc is the closure executed on scanning out a pair of key-value.

type ScanOpts

type ScanOpts struct {
	Prefix         []byte
	PrefetchSize   int
	PrefetchValues bool
	Reverse        bool
}

ScanOpts wraps options for scanning the kv storage.

type Store

type Store interface {
	io.Closer

	Reader
	SizeOnDisk() int64
	// contains filtered or unexported methods
}

Store is a common kv storage with auto-generated key.

func OpenStore

func OpenStore(path string, opts ...StoreOptions) (Store, error)

OpenStore creates a new Store. nolint: contextcheck

type StoreOptions

type StoreOptions func(Store)

StoreOptions sets options for creating Store.

func StoreWithLogger

func StoreWithLogger(l *logger.Logger) StoreOptions

StoreWithLogger sets a external logger into underlying Store.

func StoreWithMemTableSize added in v0.2.0

func StoreWithMemTableSize(size int64) StoreOptions

StoreWithMemTableSize sets MemTable size.

func StoreWithNamedLogger

func StoreWithNamedLogger(name string, l *logger.Logger) StoreOptions

StoreWithNamedLogger sets a external logger with a name into underlying Store.

type TimeSeriesOptions

type TimeSeriesOptions func(TimeSeriesStore)

TimeSeriesOptions sets an options for creating a TimeSeriesStore.

func TSSWithEncoding

func TSSWithEncoding(encoderPool encoding.SeriesEncoderPool, decoderPool encoding.SeriesDecoderPool, chunkSize int) TimeSeriesOptions

TSSWithEncoding sets encoding and decoding pools for building chunks.

func TSSWithLogger

func TSSWithLogger(l *logger.Logger) TimeSeriesOptions

TSSWithLogger sets a external logger into underlying TimeSeriesStore.

func TSSWithMemTableSize added in v0.2.0

func TSSWithMemTableSize(sizeInBytes int64) TimeSeriesOptions

TSSWithMemTableSize sets the size of memory table in bytes.

func TSSWithZSTDCompression added in v0.3.0

func TSSWithZSTDCompression(chunkSize int) TimeSeriesOptions

TSSWithZSTDCompression sets a ZSTD based compression method.

type TimeSeriesReader

type TimeSeriesReader interface {
	// Get a value by its key and timestamp/version
	Get(key []byte, ts uint64) ([]byte, error)
}

TimeSeriesReader allows retrieving data from a time-series storage.

type TimeSeriesStore

type TimeSeriesStore interface {
	io.Closer
	Handover(skl *skl.Skiplist) error
	TimeSeriesReader
	SizeOnDisk() int64
	CollectStats() *badger.Statistics
}

TimeSeriesStore is time series storage.

func OpenTimeSeriesStore

func OpenTimeSeriesStore(path string, timeRange timestamp.TimeRange, options ...TimeSeriesOptions) (TimeSeriesStore, error)

OpenTimeSeriesStore creates a new TimeSeriesStore. nolint: contextcheck

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL