cdclog

package
v5.0.2-20210628+incomp... Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BatchVersion1 represents the version of batch format.
	BatchVersion1 uint64 = 1
)

TODO let cdc import these flags.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Type byte `json:"t"`

	// WhereHandle is deprecated
	// WhereHandle is replaced by HandleKey in Flag.
	WhereHandle *bool          `json:"h,omitempty"`
	Flag        ColumnFlagType `json:"f"`
	Value       interface{}    `json:"v"`
}

Column represents the column data define by cdc.

func (Column) ToDatum

func (c Column) ToDatum() (types.Datum, error)

ToDatum encode Column to Datum.

type ColumnFlagType

type ColumnFlagType uint64

ColumnFlagType represents the type of Column.

const (
	// BinaryFlag means the Column charset is binary.
	BinaryFlag ColumnFlagType = 1 << ColumnFlagType(iota)
	// HandleKeyFlag means the Column is selected as the handle key.
	HandleKeyFlag
	// GeneratedColumnFlag means the Column is a generated Column.
	GeneratedColumnFlag
	// PrimaryKeyFlag means the Column is primary key.
	PrimaryKeyFlag
	// UniqueKeyFlag means the Column is unique key.
	UniqueKeyFlag
	// MultipleKeyFlag means the Column is multiple key.
	MultipleKeyFlag
	// NullableFlag means the Column is nullable.
	NullableFlag
)

type EventPuller

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

EventPuller pulls next event in ts order.

func NewEventPuller

func NewEventPuller(
	ctx context.Context,
	schema string,
	table string,
	ddlFiles []string,
	rowChangedFiles []string,
	storage storage.ExternalStorage) (*EventPuller, error)

NewEventPuller create eventPuller by given log files, we assume files come in ts order.

func (*EventPuller) PullOneEvent

func (e *EventPuller) PullOneEvent(ctx context.Context) (*SortItem, error)

PullOneEvent pulls one event in ts order. The Next event which can be DDL item or Row changed Item depends on next commit ts.

type ItemType

type ItemType uint

ItemType represents the type of SortItem.

const (
	// RowChanged represents dml type.
	RowChanged ItemType = 1 << ItemType(iota)
	// DDL represents ddl type.
	DDL
)

type JSONEventBatchMixedDecoder

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

JSONEventBatchMixedDecoder decodes the byte of a batch into the original messages.

func NewJSONEventBatchDecoder

func NewJSONEventBatchDecoder(data []byte) (*JSONEventBatchMixedDecoder, error)

NewJSONEventBatchDecoder creates a new JSONEventBatchDecoder.

func (*JSONEventBatchMixedDecoder) HasNext

func (b *JSONEventBatchMixedDecoder) HasNext() bool

HasNext represents whether it has next kv to decode.

func (*JSONEventBatchMixedDecoder) NextEvent

func (b *JSONEventBatchMixedDecoder) NextEvent(itemType ItemType) (*SortItem, error)

NextEvent return next item depends on type.

type MessageDDL

type MessageDDL struct {
	Query string             `json:"q"`
	Type  timodel.ActionType `json:"t"`
}

MessageDDL represents the ddl changes.

func (*MessageDDL) Decode

func (m *MessageDDL) Decode(data []byte) error

Decode the DDL message.

func (*MessageDDL) Encode

func (m *MessageDDL) Encode() ([]byte, error)

Encode the DDL message.

type MessageRow

type MessageRow struct {
	Update     map[string]Column `json:"u,omitempty"`
	PreColumns map[string]Column `json:"p,omitempty"`
	Delete     map[string]Column `json:"d,omitempty"`
}

MessageRow represents the row changes in same commit ts.

func (*MessageRow) Decode

func (m *MessageRow) Decode(data []byte) error

Decode the Row message.

func (*MessageRow) Encode

func (m *MessageRow) Encode() ([]byte, error)

Encode the Row message.

type SortItem

type SortItem struct {
	ItemType ItemType
	Data     interface{}
	Schema   string
	Table    string
	RowID    int64
	TS       uint64
}

SortItem represents a DDL item or Row changed item.

func (*SortItem) LessThan

func (s *SortItem) LessThan(other *SortItem) bool

LessThan return whether it has smaller commit ts than other item.

type TableBuffer

type TableBuffer struct {
	KvPairs []kv.Row

	KvEncoder kv.Encoder
	// contains filtered or unexported fields
}

TableBuffer represents the kv buffer of this table. we restore one tableBuffer in one goroutine. this is the concurrent unit of log restore.

func NewTableBuffer

func NewTableBuffer(tbl table.Table, allocators autoid.Allocators, flushKVPairs int, flushKVSize int64) *TableBuffer

NewTableBuffer creates TableBuffer.

func (*TableBuffer) Append

func (t *TableBuffer) Append(item *SortItem) error

Append appends the item to this buffer.

func (*TableBuffer) Clear

func (t *TableBuffer) Clear()

Clear reset the buffer.

func (*TableBuffer) IsEmpty

func (t *TableBuffer) IsEmpty() bool

IsEmpty tells buffer is empty.

func (*TableBuffer) ReloadMeta

func (t *TableBuffer) ReloadMeta(tbl table.Table, allocator autoid.Allocators)

ReloadMeta reload columns after 1. table buffer created. 2. every ddl executed.

func (*TableBuffer) ResetTableInfo

func (t *TableBuffer) ResetTableInfo()

ResetTableInfo set tableInfo to nil for next reload.

func (*TableBuffer) ShouldApply

func (t *TableBuffer) ShouldApply() bool

ShouldApply tells whether we should flush memory kv buffer to storage.

func (*TableBuffer) TableID

func (t *TableBuffer) TableID() int64

TableID returns the table id of this buffer.

func (*TableBuffer) TableInfo

func (t *TableBuffer) TableInfo() table.Table

TableInfo returns the table info of this buffer.

Jump to

Keyboard shortcuts

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