kiesel

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 8 Imported by: 0

README

kiesel

Test GoDoc Release

Go package with tools for working with the pebble embedded database engine.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPipelineClosed = errors.New("pipeline closed")

ErrPipelineClosed is returned if the pipeline has already been closed.

Functions

func BuildOptions

func BuildOptions(bp Blueprint) *pebble.Options

BuildOptions supports building pebble options based on a blueprint. The default values applied to the blueprint represents the chosen settings in CockroachDB the primary users of pebble. https://github.com/cockroachdb/cockroach/blob/master/pkg/storage/pebble.go#L570 https://github.com/cockroachdb/pebble/blob/master/cmd/pebble/db.go#L53

func EndPrefixRange

func EndPrefixRange(prefix []byte) []byte

EndPrefixRange will return the end of a prefix range. It will modify the supplied byte slice. The function may return nil if the specified prefix cannot be terminated.

func NewCacheWithShards

func NewCacheWithShards(size int64, shards int) *pebble.Cache

NewCacheWithShards allows the creation of a cache with an explicit number of shards.

func Reset

func Reset(batch *pebble.Batch, min, max int) bool

Reset will reset the provided batch and attempt to reuse the underlying buffer up to the specified maximum. If a buffer is absent or too big, it will allocate a new buffer with the specified minimum instead. It returns whether the underlying buffer has been reused.

func Rewind

func Rewind(batch *pebble.Batch, length int)

Rewind will restore a batch to the provided length. The length must be obtained using len(batch.Repr()) from the same batch.

Types

type Action added in v0.1.4

type Action int

Action defines the action take by the pipeline after executing a work function.

const (
	Defer Action = iota
	Commit
	Sync
)

The available actions.

type Blueprint

type Blueprint struct {
	// The file system implementation.
	FS vfs.FS

	// The block cache instance.
	Cache *pebble.Cache

	// Whether to not use bloom filters on all except the last level.
	NoFilters bool

	// The number of levels to use.
	//
	// Default: 7
	Levels int

	// The mem table size.
	//
	// Default: 64 MiB
	MemTableSize int

	// The maximum number of active mem tables.
	//
	// Default: 4
	MaxMemTables int

	// The maximum size of the base level.
	//
	// Pebble uses an algorithm to dynamically calculate the level sizes similar
	// to the one found in RocksDB. This options forces a cap on the level L0
	// is compacted into to ensure new levels are created when needed.
	// https://github.com/cockroachdb/pebble/blob/master/options.go#L538
	// https://github.com/cockroachdb/pebble/commit/22071b0f2df784875d3be05132f71396463b0dc4
	// https://github.com/cockroachdb/pebble/commit/f5d25937abe21677033114db971e3acf863bc1a3
	// http://rocksdb.org/blog/2015/07/23/dynamic-level.html
	//
	// Default: 64 MiB
	MaxBaseLevelSize int

	// The start file size for the first level and the file size multiplier for
	// the following levels.
	//
	// Default: 2 MiB, 2x
	StartFileSize      int
	FileSizeMultiplier int

	// The data and index block size.
	//
	// Default: 32 KiB, 256 KiB
	DataBlockSize  int
	IndexBlockSize int
}

Blueprint describes the values used to build options for pebble.

type Pipeline added in v0.1.4

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

Pipeline provides a mechanism to coalesce multiple mini-transactions into a single batch to reduce overhead and improve performance. It is most useful in scenarios where many goroutines perform transactions that only modify a small set of keys.

func NewPipeline added in v0.1.4

func NewPipeline(db *pebble.DB, queueSize, minBuffer, maxBuffer int) *Pipeline

NewPipeline will create and return a new pipeline. The queue size specifies the number parallel operations that may be coalesced.

func (*Pipeline) Close added in v0.1.4

func (b *Pipeline) Close()

Close will stop and close the pipeline.

func (*Pipeline) Queue added in v0.1.4

func (b *Pipeline) Queue(work func(batch *pebble.Batch) (Action, error), result func(error)) error

Queue will submit the provided work function to the queue. The function will be called with a new or used batch for operation. If it returns an error, the performed changes are rolled back. On success the final indicated action is taken after executing all current operations. If a result function is provided it will be called with the result of the batch application. Only if the action is Sync and both calls return no error, the changes can be considered to be durable.

type ReadWriter

type ReadWriter interface {
	pebble.Reader
	pebble.Writer
}

ReadWriter is a common interface for a pebble reader or writer aka. database or batch.

Jump to

Keyboard shortcuts

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