kv

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStopScan     = errors.New("stop scanning")
	DefaultScanOpts = ScanOpts{
		PrefetchSize:   100,
		PrefetchValues: true,
	}
)
View Source
var (
	ErrKeyNotFound = badger.ErrKeyNotFound
)

Functions

This section is empty.

Types

type HandoverCallback

type HandoverCallback func()

type IndexOptions

type IndexOptions func(store IndexStore)

func IndexWithLogger

func IndexWithLogger(l *logger.Logger) IndexOptions

IndexWithLogger sets a external logger into underlying IndexStore

type IndexStore

type IndexStore interface {
	Iterable
	Reader
	Handover(iterator Iterator) error
	Close() error
}

func OpenIndexStore

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

OpenIndexStore creates a new IndexStore

type Iterable

type Iterable interface {
	NewIterator(opt ScanOpts) Iterator
}

type Iterator

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

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
}

type ScanFunc

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

type ScanOpts

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

type Store

type Store interface {
	observability.Observable
	io.Closer
	Writer
	Reader
}

Store is a common kv storage with auto-generated key

func OpenStore

func OpenStore(shardID int, path string, options ...StoreOptions) (Store, error)

OpenStore creates a new Store

type StoreOptions

type StoreOptions func(Store)

func StoreWithLogger

func StoreWithLogger(l *logger.Logger) StoreOptions

StoreWithLogger sets a external logger into underlying Store

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)

func TSSWithEncoding

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

func TSSWithFlushCallback

func TSSWithFlushCallback(callback func()) TimeSeriesOptions

func TSSWithLogger

func TSSWithLogger(l *logger.Logger) TimeSeriesOptions

TSSWithLogger sets a external logger into underlying TimeSeriesStore

type TimeSeriesReader

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

type TimeSeriesStore

type TimeSeriesStore interface {
	observability.Observable
	io.Closer
	TimeSeriesWriter
	TimeSeriesReader
}

TimeSeriesStore is time series storage

func OpenTimeSeriesStore

func OpenTimeSeriesStore(shardID int, path string, options ...TimeSeriesOptions) (TimeSeriesStore, error)

OpenTimeSeriesStore creates a new TimeSeriesStore

type TimeSeriesWriter

type TimeSeriesWriter interface {
	// Put a value with a timestamp/version
	Put(key, val []byte, ts uint64) error
	// PutAsync a value with a timestamp/version asynchronously.
	// Injected "f" func will notice the result of value write.
	PutAsync(key, val []byte, ts uint64, f func(error)) error
}

type Writer

type Writer interface {
	// Put a value
	Put(key, val []byte) error
	PutWithVersion(key, val []byte, version uint64) error
}

Jump to

Keyboard shortcuts

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