kv

package
v0.6.1-alpha.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const EmptyPrefix = Key("")

Variables

This section is empty.

Functions

This section is empty.

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 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

Get returns the value, or nil if not found

func (*HiveKVStoreReader) Has added in v0.2.0

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

func (*HiveKVStoreReader) Iterate added in v0.2.0

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

func (*HiveKVStoreReader) IterateKeys added in v0.2.0

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

func (*HiveKVStoreReader) IterateKeysSorted added in v0.2.0

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

func (*HiveKVStoreReader) IterateSorted added in v0.2.0

func (h *HiveKVStoreReader) IterateSorted(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)
	IterateKeys(prefix Key, f func(key Key) bool)
	IterateSorted(prefix Key, f func(key Key, value []byte) bool)
	IterateKeysSorted(prefix Key, f func(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
	Has(key Key) bool
}

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
}

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