Documentation
¶
Overview ¶
package pdb has utilities for working with the Pebble database.
Index ¶
- func Compact(sp *pebble.Snapshot, ba *pebble.Batch, tableID TableID, ...) error
- func DoRO(db *pebble.DB, fn func(*pebble.Snapshot) error) error
- func DoRW(db *pebble.DB, fn func(*pebble.Batch) error) error
- func Exists(sp RO, k []byte, pred func([]byte) bool) (bool, error)
- func IncrUint32(ba *pebble.Batch, key []byte, delta int32, deleteZero bool) (uint32, error)
- func IncrUint64(ba *pebble.Batch, key []byte, delta int64) (uint64, error)
- func PrefixUpperBound(prefix []byte) []byte
- func TableDelete(ba WO, tid TableID, key []byte) error
- func TableLowerBound(tableID TableID) []byte
- func TablePut(ba WO, tid TableID, key []byte, value []byte) error
- func TableUpperBound(tableID TableID) []byte
- func Undo(sp RO, ba WO, tid TableID, prefix []byte, mvid MVTag) error
- type MVKey
- type MVRow
- type MVSet
- type MVTag
- type RO
- type TKey
- type TableID
- type TxSys
- func (txs *TxSys) AllocateTxID() (MVTag, error)
- func (txs *TxSys) Failure(ba WO, txid MVTag) error
- func (txs *TxSys) IsActive(sn RO, txid MVTag) (bool, error)
- func (txs *TxSys) ReadActive(sp RO, dst map[MVTag]struct{}) error
- func (txs *TxSys) RemoveFailed(ba WO, txid MVTag) error
- func (txs *TxSys) Success(ba WO, txid MVTag) error
- type WO
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 DoRW ¶
DoRW creates an indexed batch and calls fn with it. if fn returns nil, the batch is committed.
func Exists ¶
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 IncrUint64 ¶
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 TableLowerBound ¶
func TableUpperBound ¶
Types ¶
type MVRow ¶
MVRow is a multi-version row.
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 TxSys ¶
type TxSys struct {
// contains filtered or unexported fields
}
TxSys manages the transaction sequence number, and the set of active transactions.
func (*TxSys) AllocateTxID ¶
allocateTxID allocates a new transaction ID. It is guaranteed to be unique. If the ID is lost and never used, that's fine.
func (*TxSys) Failure ¶
failure marks a transaction as failed. The transaction stays in the active set.
func (*TxSys) RemoveFailed ¶
removeFailed removes a failed transaction from the active set. This should only be called after all the rows written by the transaction have been cleaned up.
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.