store

package
v0.0.0-...-e4e1abe Latest Latest
Warning

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

Go to latest
Published: May 28, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BreakScan = errors.New("break scan")

BreakScan error can be used on scanning function to notify termination of scanning

View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type Batch

type Batch interface {
	Flush(ctx context.Context) error
	FlushIfFull(ctx context.Context) (flushed bool, err error)

	// PurgeRow is used to completely delete an element for the database.
	//
	// **Important** If a tablet row/singlet entry was deleted, you should use
	//               instead `SetRow(key, nil)` which is the correct way to represent
	//               a deleted row in FluxDB system.
	PurgeRow(key []byte)

	// FIXME: Maybe the batch "adder/setter" should not event care about the key and compute
	//        it straight? Since this is per storage engine, it would be a good place since
	//        all saved element would pass through those methods...
	SetRow(key []byte, value []byte)
	SetLastCheckpoint(key []byte, value []byte)

	Reset()
}

type KVStore

type KVStore interface {
	Close() error

	NewBatch(logger *zap.Logger) Batch

	HasTabletRow(ctx context.Context, keyStart, keyEnd []byte) (exists bool, err error)

	FetchTabletRow(ctx context.Context, key []byte) (value []byte, err error)

	FetchTabletRows(ctx context.Context, keys [][]byte, onKeyValue OnKeyValue) error

	// FetchSingletEntry reads a single singlet entry for the given Singlet range. The range must include block
	// boundaries to ensure we match only element from this singlet and not a next following.
	//
	// If the entry is found, the `key` and `value` will be set and `err` will be `nil`. If the entry is
	// found withing the range, `key`, `value` and `err` will be `nil`. Finally, if an error is encountered
	// while fetching the singlet entry, `key` and `value` will be `nil` and `err` will be set to the
	// error hit.
	FetchSingletEntry(ctx context.Context, keyStart, keyEnd []byte) (key []byte, value []byte, err error)

	ScanTabletRows(ctx context.Context, keyStart, keyEnd []byte, onKeyValue OnKeyValue) error

	ScanIndexKeys(ctx context.Context, prefix []byte, onKey OnKey) error

	// FetchLastWrittenCheckpoint returns the latest written checkpoint reference that was correctly
	// committed to the storage system.
	//
	// If nothing was ever written yet, this must return `nil, ErrNotFound`.
	FetchLastWrittenCheckpoint(ctx context.Context, key []byte) (value []byte, err error)

	ScanLastShardsWrittenCheckpoint(ctx context.Context, keyPrefix []byte, onKeyValue OnKeyValue) error

	DeleteShardsCheckpoint(ctx context.Context, keyPrefix []byte) error
}

KVStore represents the abstraction needed by FluxDB to correctly use different underlying KV storage engine.

type Key

type Key []byte

func (Key) String

func (k Key) String() string

type OnKey

type OnKey func(key []byte) error

type OnKeyValue

type OnKeyValue func(key []byte, value []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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