dbreader

package
v1.1.0-beta.0...-db2776a Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

ErrScanBreak is returned by ScanFunc to break the scan loop.

Functions

func NewIterator

func NewIterator(txn *badger.Txn, reverse bool, startKey, endKey []byte) *badger.Iterator

NewIterator returns a new *badger.Iterator.

Types

type BatchGetFunc

type BatchGetFunc = func(key, value []byte, err error)

BatchGetFunc defines a batch get function.

type DBReader

type DBReader struct {
	StartKey []byte
	EndKey   []byte

	RcCheckTS bool
	// contains filtered or unexported fields
}

DBReader reads data from DB, for read-only requests, the locks must already be checked before DBReader is created.

func NewDBReader

func NewDBReader(startKey, endKey []byte, txn *badger.Txn) *DBReader

NewDBReader returns a new *DBReader.

func (*DBReader) BatchGet

func (r *DBReader) BatchGet(keys [][]byte, startTS uint64, f BatchGetFunc)

BatchGet batch gets keys.

func (*DBReader) CheckWriteItemForRcCheckTSRead

func (r *DBReader) CheckWriteItemForRcCheckTSRead(readTS uint64, item *badger.Item) error

CheckWriteItemForRcCheckTSRead checks the data version if `RcCheckTS` isolation level is used.

func (*DBReader) Close

func (r *DBReader) Close()

Close closes the *DBReader.

func (*DBReader) Get

func (r *DBReader) Get(key []byte, startTS uint64) ([]byte, error)

Get gets a value with the key and start ts.

func (*DBReader) GetExtraIter

func (r *DBReader) GetExtraIter() *badger.Iterator

GetExtraIter returns the extra *badger.Iterator of a *DBReader.

func (*DBReader) GetIter

func (r *DBReader) GetIter() *badger.Iterator

GetIter returns the *badger.Iterator of a *DBReader.

func (*DBReader) GetKeyByStartTs

func (r *DBReader) GetKeyByStartTs(startKey, endKey []byte, startTs uint64) ([]byte, error)

GetKeyByStartTs gets a key with the start ts.

func (*DBReader) GetMvccInfoByKey

func (r *DBReader) GetMvccInfoByKey(key []byte, _ bool, mvccInfo *kvrpcpb.MvccInfo) error

GetMvccInfoByKey fills MvccInfo reading committed keys from db

func (*DBReader) GetTxn

func (r *DBReader) GetTxn() *badger.Txn

GetTxn gets the *badger.Txn of the *DBReader.

func (*DBReader) ReverseScan

func (r *DBReader) ReverseScan(startKey, endKey []byte, limit int, startTS uint64, proc ScanProcessor) error

ReverseScan implements the MVCCStore interface. The search range is [startKey, endKey).

func (*DBReader) Scan

func (r *DBReader) Scan(startKey, endKey []byte, limit int, startTS uint64, proc ScanProcessor) error

Scan scans the key range with the given ScanProcessor.

type ScanFunc

type ScanFunc = func(key, value []byte) error

ScanFunc accepts key and value, should not keep reference to them. Returns ErrScanBreak will break the scan loop.

type ScanProcessor

type ScanProcessor interface {
	// Process accepts key and value, should not keep reference to them.
	// Returns ErrScanBreak will break the scan loop.
	Process(key, value []byte) error
	// SkipValue returns if we can skip the value.
	SkipValue() bool
}

ScanProcessor process the key/value pair.

Jump to

Keyboard shortcuts

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