kv

package
v4.0.0-beta.2.0...-c7f9382 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NextKey

func NextKey(key []byte) []byte

NextKey return the smallest []byte that is bigger than current bytes. special case when key is empty, empty bytes means infinity in our context, so directly return itself.

func TableHasAutoRowID

func TableHasAutoRowID(info *model.TableInfo) bool

TableHasAutoRowID return whether table has auto generated row id.

Types

type Checksum

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

Checksum represents the field needs checksum.

func MakeKVChecksum

func MakeKVChecksum(bytes uint64, kvs uint64, checksum uint64) Checksum

MakeKVChecksum creates Checksum.

func NewKVChecksum

func NewKVChecksum(checksum uint64) *Checksum

NewKVChecksum creates Checksum.

func (*Checksum) Add

func (c *Checksum) Add(other *Checksum)

Add other checksum.

func (Checksum) MarshalJSON

func (c Checksum) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*Checksum) MarshalLogObject

func (c *Checksum) MarshalLogObject(encoder zapcore.ObjectEncoder) error

MarshalLogObject implements the zapcore.ObjectMarshaler interface.

func (*Checksum) Sum

func (c *Checksum) Sum() uint64

Sum returns the checksum.

func (*Checksum) SumKVS

func (c *Checksum) SumKVS() uint64

SumKVS returns the kv count.

func (*Checksum) SumSize

func (c *Checksum) SumSize() uint64

SumSize returns the bytes.

func (*Checksum) Update

func (c *Checksum) Update(kvs []Pair)

Update add batch of kvs with their values.

func (*Checksum) UpdateOne

func (c *Checksum) UpdateOne(kv Pair)

UpdateOne add kv with its values.

type Encoder

type Encoder interface {
	// Close the encoder.
	Close()

	// AddRecord encode encodes a row of SQL values into a backend-friendly format.
	AddRecord(
		row []types.Datum,
		rowID int64,
		columnPermutation []int,
	) (Row, int, error)

	// RemoveRecord encode encodes a row of SQL delete values into a backend-friendly format.
	RemoveRecord(
		row []types.Datum,
		rowID int64,
		columnPermutation []int,
	) (Row, int, error)
}

Encoder encodes a row of SQL values into some opaque type which can be consumed by OpenEngine.WriteEncoded.

func NewTableKVEncoder

func NewTableKVEncoder(tbl table.Table, options *SessionOptions) Encoder

NewTableKVEncoder creates the Encoder.

type Iter

type Iter interface {
	// Seek seek to specify position.
	// if key not found, seeks next key position in iter.
	Seek(key []byte) bool
	// Error return current error on this iter.
	Error() error
	// First moves this iter to the first key.
	First() bool
	// Last moves this iter to the last key.
	Last() bool
	// Valid check this iter reach the end.
	Valid() bool
	// Next moves this iter forward.
	Next() bool
	// Key represents current position pair's key.
	Key() []byte
	// Value represents current position pair's Value.
	Value() []byte
	// Close close this iter.
	Close() error
	// OpType represents operations of pair. currently we have two types.
	// 1. Put
	// 2. Delete
	OpType() sst.Pair_OP
}

Iter abstract iterator method for Ingester.

type IterProducer

type IterProducer interface {
	// Produce produces iterator with given range [start, end).
	Produce(start []byte, end []byte) Iter
}

IterProducer produces iterator with given range.

func NewSimpleKVIterProducer

func NewSimpleKVIterProducer(pairs Pairs) IterProducer

NewSimpleKVIterProducer creates SimpleKVIterProducer.

type Pair

type Pair struct {
	// Key is the key of the KV pair
	Key []byte
	// Val is the value of the KV pair
	Val []byte
	// IsDelete represents whether we should remove this KV pair.
	IsDelete bool
}

Pair is a pair of key and value.

type Pairs

type Pairs []Pair

Pairs represents the slice of Pair.

func (Pairs) ClassifyAndAppend

func (kvs Pairs) ClassifyAndAppend(
	data *Pairs,
	dataChecksum *Checksum,
	indices *Pairs,
	indexChecksum *Checksum,
)

ClassifyAndAppend split Pairs to data rows and index rows.

func (Pairs) Clear

func (kvs Pairs) Clear() Pairs

Clear resets the Pairs.

type Row

type Row interface {
	// ClassifyAndAppend separates the data-like and index-like parts of the
	// encoded row, and appends these parts into the existing buffers and
	// checksums.
	ClassifyAndAppend(
		data *Pairs,
		dataChecksum *Checksum,
		indices *Pairs,
		indexChecksum *Checksum,
	)
}

Row represents a single encoded row.

type SessionOptions

type SessionOptions struct {
	SQLMode          mysql.SQLMode
	Timestamp        int64
	RowFormatVersion string
}

SessionOptions is the initial configuration of the session.

type SimpleKVIter

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

SimpleKVIter represents simple pair iterator. which is used for log restore.

func (*SimpleKVIter) Close

func (s *SimpleKVIter) Close() error

Close implements Iter.Close.

func (*SimpleKVIter) Error

func (s *SimpleKVIter) Error() error

Error implements Iter.Error.

func (*SimpleKVIter) First

func (s *SimpleKVIter) First() bool

First implements Iter.First.

func (*SimpleKVIter) Key

func (s *SimpleKVIter) Key() []byte

Key implements Iter.Key.

func (*SimpleKVIter) Last

func (s *SimpleKVIter) Last() bool

Last implements Iter.Last.

func (*SimpleKVIter) Next

func (s *SimpleKVIter) Next() bool

Next implements Iter.Next.

func (*SimpleKVIter) OpType

func (s *SimpleKVIter) OpType() sst.Pair_OP

OpType implements Iter.KeyIsDelete.

func (*SimpleKVIter) Seek

func (s *SimpleKVIter) Seek(key []byte) bool

Seek implements Iter.Seek.

func (*SimpleKVIter) Valid

func (s *SimpleKVIter) Valid() bool

Valid implements Iter.Valid.

func (*SimpleKVIter) Value

func (s *SimpleKVIter) Value() []byte

Value implements Iter.Value.

type SimpleKVIterProducer

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

SimpleKVIterProducer represents kv iter producer.

func (*SimpleKVIterProducer) Produce

func (p *SimpleKVIterProducer) Produce(start []byte, end []byte) Iter

Produce implements Iter.Producer.Produce.

Jump to

Keyboard shortcuts

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