kv

package
v0.4.0-alpha.8 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

View Source
const EmptyPrefix = Key("")

Variables

This section is empty.

Functions

func DumpKeySet added in v0.3.0

func DumpKeySet(s map[Key]struct{}) []string

func GetAllKeys added in v0.3.0

func GetAllKeys(pref Key, kvr1, kvr2 KVStoreReader) map[Key]struct{}

func GetAllKeysWithDiff added in v0.3.0

func GetAllKeysWithDiff(kvr1, kvr2 KVStoreReader) string

func GetDiffKeyValues added in v0.3.0

func GetDiffKeyValues(kvr1, kvr2 KVStoreReader) map[Key]struct{}

func GetDiffKeys added in v0.3.0

func GetDiffKeys(kvr1, kvr2 KVStoreReader) map[Key]struct{}

func MustGet added in v0.1.0

func MustGet(kvs KVStoreReader, key Key) []byte

func MustHas added in v0.1.0

func MustHas(kvs KVStoreReader, key Key) bool

func MustIterate added in v0.1.0

func MustIterate(kvs KVStoreReader, prefix Key, f func(key Key, value []byte) bool)

func MustIterateKeys added in v0.1.0

func MustIterateKeys(kvs KVStoreReader, prefix Key, f func(key Key) bool)

func MustIterateKeysSorted added in v0.2.0

func MustIterateKeysSorted(kvs KVStoreReader, prefix Key, f func(key Key) bool)

func MustIterateSorted added in v0.2.0

func MustIterateSorted(kvs KVStoreReader, prefix Key, f func(key Key, value []byte) bool)

func NumKeys added in v0.3.0

func NumKeys(kvr KVMustIterator) int

Types

type BinaryStreamFileIterator added in v0.3.0

type BinaryStreamFileIterator struct {
	*BinaryStreamIterator
	File *os.File
}

func OpenKVStreamFile added in v0.3.0

func OpenKVStreamFile(fname string) (*BinaryStreamFileIterator, error)

OpenKVStreamFile opens existing file with k/v stream

type BinaryStreamFileWriter added in v0.3.0

type BinaryStreamFileWriter struct {
	*BinaryStreamWriter
	File *os.File
}

func CreateKVStreamFile added in v0.3.0

func CreateKVStreamFile(fname string) (*BinaryStreamFileWriter, error)

CreateKVStreamFile create a new k/v file

type BinaryStreamIterator added in v0.3.0

type BinaryStreamIterator struct {
	// contains filtered or unexported fields
}

func NewBinaryStreamIterator added in v0.3.0

func NewBinaryStreamIterator(r io.Reader) *BinaryStreamIterator

func (BinaryStreamIterator) Iterate added in v0.3.0

func (b BinaryStreamIterator) Iterate(fun func(k []byte, v []byte) bool) error

type BinaryStreamWriter added in v0.3.0

type BinaryStreamWriter struct {
	// contains filtered or unexported fields
}

BinaryStreamWriter writes stream of k/v pairs in binary format. Keys encoding is 'bytes16' and values is 'bytes32'

func NewBinaryStreamWriter added in v0.3.0

func NewBinaryStreamWriter(w io.Writer) *BinaryStreamWriter

func (*BinaryStreamWriter) Stats added in v0.3.0

func (b *BinaryStreamWriter) Stats() (int, int)

func (*BinaryStreamWriter) Write added in v0.3.0

func (b *BinaryStreamWriter) Write(key, value []byte) error

type DBError

type DBError struct {
	// contains filtered or unexported fields
}

func (*DBError) Error

func (d *DBError) Error() string

func (*DBError) Unwrap added in v0.2.0

func (d *DBError) Unwrap() error

type Diff added in v0.3.0

type Diff []*DiffElement

func GetDiff added in v0.3.0

func GetDiff(kvr1, kvr2 KVStoreReader) Diff

func (Diff) DumpDiff added in v0.3.0

func (d Diff) DumpDiff() string

type DiffElement added in v0.3.0

type DiffElement struct {
	Key    Key
	Value1 []byte
	Value2 []byte
}

type HiveKVStoreReader added in v0.2.0

type HiveKVStoreReader struct {
	// contains filtered or unexported fields
}

HiveKVStoreReader is an implementation of KVStoreReader with an instance of hive's kvstore.KVStore as backend.

func NewHiveKVStoreReader added in v0.2.0

func NewHiveKVStoreReader(db kvstore.KVStore) *HiveKVStoreReader

func (*HiveKVStoreReader) Get added in v0.2.0

func (h *HiveKVStoreReader) Get(key Key) ([]byte, error)

Get returns the value, or nil if not found

func (*HiveKVStoreReader) Has added in v0.2.0

func (h *HiveKVStoreReader) Has(key Key) (bool, error)

func (*HiveKVStoreReader) Iterate added in v0.2.0

func (h *HiveKVStoreReader) Iterate(prefix Key, f func(key Key, value []byte) bool) error

func (*HiveKVStoreReader) IterateKeys added in v0.2.0

func (h *HiveKVStoreReader) IterateKeys(prefix Key, f func(key Key) bool) error

func (*HiveKVStoreReader) IterateKeysSorted added in v0.2.0

func (h *HiveKVStoreReader) IterateKeysSorted(prefix Key, f func(key Key) bool) error

func (*HiveKVStoreReader) IterateSorted added in v0.2.0

func (h *HiveKVStoreReader) IterateSorted(prefix Key, f func(key Key, value []byte) bool) error

func (*HiveKVStoreReader) MustGet added in v0.2.0

func (h *HiveKVStoreReader) MustGet(key Key) []byte

MustGet returns the value, or nil if not found

func (*HiveKVStoreReader) MustHas added in v0.2.0

func (h *HiveKVStoreReader) MustHas(key Key) bool

func (*HiveKVStoreReader) MustIterate added in v0.2.0

func (h *HiveKVStoreReader) MustIterate(prefix Key, f func(key Key, value []byte) bool)

func (*HiveKVStoreReader) MustIterateKeys added in v0.2.0

func (h *HiveKVStoreReader) MustIterateKeys(prefix Key, f func(key Key) bool)

func (*HiveKVStoreReader) MustIterateKeysSorted added in v0.2.0

func (h *HiveKVStoreReader) MustIterateKeysSorted(prefix Key, f func(key Key) bool)

func (*HiveKVStoreReader) MustIterateSorted added in v0.2.0

func (h *HiveKVStoreReader) MustIterateSorted(prefix Key, f func(key Key, value []byte) bool)

type Item added in v0.2.0

type Item struct {
	Key   Key
	Value []byte
}

func (*Item) Format added in v0.3.0

func (it *Item) Format(format string) string

type Items added in v0.2.0

type Items []Item

func (Items) Len added in v0.2.0

func (items Items) Len() int

func (Items) Less added in v0.2.0

func (items Items) Less(i, j int) bool

func (Items) Swap added in v0.2.0

func (items Items) Swap(i, j int)

type KVIterator added in v0.2.0

type KVIterator interface {
	Iterate(prefix Key, f func(key Key, value []byte) bool) error
	IterateKeys(prefix Key, f func(key Key) bool) error
	IterateSorted(prefix Key, f func(key Key, value []byte) bool) error
	IterateKeysSorted(prefix Key, f func(key Key) bool) error
}

type KVMustIterator added in v0.2.0

type KVMustIterator interface {
	MustIterate(prefix Key, f func(key Key, value []byte) bool)
	MustIterateKeys(prefix Key, f func(key Key) bool)
	MustIterateSorted(prefix Key, f func(key Key, value []byte) bool)
	MustIterateKeysSorted(prefix Key, f func(key Key) bool)
}

type KVMustReader added in v0.2.0

type KVMustReader interface {
	// MustGet returns the value, or nil if not found
	MustGet(key Key) []byte
	MustHas(key Key) bool
}

type KVReader added in v0.2.0

type KVReader interface {
	// Get returns the value, or nil if not found
	Get(key Key) ([]byte, error)
	Has(key Key) (bool, error)
}

type KVStore

type KVStore interface {
	KVWriter
	KVStoreReader
}

KVStore represents a key-value store where both keys and values are arbitrary byte slices.

type KVStoreReader added in v0.1.0

type KVStoreReader interface {
	KVReader
	KVIterator
	KVMustReader
	KVMustIterator
}

func NewCachedKVStoreReader added in v1.0.3

func NewCachedKVStoreReader(r KVStoreReader, cacheSize int) KVStoreReader

NewCachedKVStoreReader wraps a KVStoreReader with an in-memory cache. IMPORTANT: there is no logic for cache invalidation, so make sure that the underlying KVStoreReader is never mutated.

type KVWriter added in v0.2.0

type KVWriter interface {
	Set(key Key, value []byte)
	Del(key Key)
}

type Key

type Key string

Key represents a key in the KVStore, to avoid unnecessary conversions between string and []byte, we use string as key data type, but it does not necessarily have to be a valid UTF-8 string.

func (Key) HasPrefix

func (k Key) HasPrefix(prefix Key) bool

func (Key) Hex added in v0.2.0

func (k Key) Hex() string

type StreamIterator added in v0.3.0

type StreamIterator interface {
	Iterate(func(k, v []byte) bool) error
}

StreamIterator is an interface to iterate stream

type StreamWriter added in v0.3.0

type StreamWriter interface {
	Write(key, value []byte) error
	Stats() (int, int) // num k/v pairs and num bytes so far
}

StreamWriter represents an interface specific to write a sequence of key/value pairs

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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