pdb

package
v0.0.0-...-1007bb0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

package pdb has utilities for working with the Pebble database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compact

func Compact(sp *pebble.Snapshot, ba *pebble.Batch, tableID TableID, exclude func(MVTag) bool) error

Compact iterates over the snapshot, and write delete to Batch to compact a table with Multi-Version keys. The snapshot should be from before the batch. There can be an arbitrary amount of time between the snapshot and the batch, and this algorithm will still be correct. This assumes that MVIDs are never reused.

func Exists

func Exists(sp RO, k []byte, pred func([]byte) bool) (bool, error)

Exists returns true if the key exists in the database, who's value satisfies a predicate. If pred is nil, it is ignored.

func IncrUint32

func IncrUint32(ba *pebble.Batch, key []byte, delta int32, deleteZero bool) (uint32, error)

func IncrUint64

func IncrUint64(ba *pebble.Batch, key []byte, delta int64) (uint64, error)

IncrUint64 looks for a 64 bit integer at key adds delta to it and saves it. If the key is not found that is equivalent to reading a 0. The new value is returned.

func PrefixUpperBound

func PrefixUpperBound(prefix []byte) []byte

func TableDelete

func TableDelete(ba WO, tid TableID, key []byte) error

func TableLowerBound

func TableLowerBound(tableID TableID) []byte

func TablePut

func TablePut(ba WO, tid TableID, key []byte, value []byte) error

func TableUpperBound

func TableUpperBound(tableID TableID) []byte

func Undo

func Undo(sp RO, ba WO, tid TableID, prefix []byte, mvid MVTag) error

Undo removes all the rows in a given table with a specific version.

Types

type MVKey

type MVKey struct {
	TableID TableID
	Key     []byte
	Version MVTag
}

MVKey is a multi-version key. Not all tables use MVKeys.

func ParseMVKey

func ParseMVKey(k []byte) (MVKey, error)

func (MVKey) Marshal

func (k MVKey) Marshal(out []byte) []byte

type MVRow

type MVRow struct {
	Key   MVKey
	Value []byte
}

MVRow is a multi-version row.

func MVGet

func MVGet(sp RO, tid TableID, data []byte, excluding func(MVTag) bool) (*MVRow, io.Closer, error)

MVGet gets the most recent value for the given MVKey from the database, where the version is not in excluding. Excluding should be a fast, deterministic function, that returns true if the version should be excluded. If no row is found, (nil, no-op-closer, nil) is returned.

type MVSet

type MVSet = map[MVTag]struct{}

MVSet is a set of MVIDs.

type MVTag

type MVTag uint64

MVTag (Multi-Version Tag) is used to order transactions on volumes.

func (MVTag) Marshal

func (mvt MVTag) Marshal(out []byte) []byte

type RO

type RO interface {
	Get(k []byte) (v []byte, closer io.Closer, err error)
	NewIter(opts *pebble.IterOptions) (*pebble.Iterator, error)
}

RO is a read-only interface for the Pebble database.

type TKey

type TKey struct {
	TableID TableID
	Key     []byte
}

TKey is a table key.

func ParseTKey

func ParseTKey(k []byte) (TKey, error)

func (TKey) Marshal

func (k TKey) Marshal(out []byte) []byte

type TableID

type TableID uint32

type WO

type WO interface {
	Set(k, v []byte, opts *pebble.WriteOptions) error
	Delete(k []byte, opts *pebble.WriteOptions) error
}

WO is a write-only interface for the Pebble database.

Jump to

Keyboard shortcuts

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