metautil

package
v5.1.0+incompatible Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// LockFile represents file name
	LockFile = "backup.lock"
	// MetaFile represents file name
	MetaFile = "backupmeta"
	// MetaJSONFile represents backup meta json file name
	MetaJSONFile = "backupmeta.json"
	// MaxBatchSize represents the internal channel buffer size of MetaWriter and MetaReader.
	MaxBatchSize = 1024

	// MetaFileSize represents the limit size of one MetaFile
	MetaFileSize = 128 * units.MiB
)
View Source
const (
	// MetaV1 represents the old version of backupmeta.
	// because the old version doesn't have version field, so set it to 0 for compatibility.
	MetaV1 = iota
	// MetaV2 represents the new version of backupmeta.
	MetaV2
)

Variables

This section is empty.

Functions

func NewSizedMetaFile

func NewSizedMetaFile(sizeLimit int) *sizedMetaFile

NewSizedMetaFile represents the sizedMetaFile.

Types

type AppendOp

type AppendOp int

AppendOp represents the operation type of meta.

const (
	// AppendMetaFile represents the MetaFile type.
	AppendMetaFile AppendOp = 0
	// AppendDataFile represents the DataFile type.
	// it records the file meta from tikv.
	AppendDataFile AppendOp = 1
	// AppendSchema represents the schema from tidb.
	AppendSchema AppendOp = 2
	// AppendDDL represents the ddls before last backup.
	AppendDDL AppendOp = 3
)

type MetaReader

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

MetaReader wraps a reader to read both old and new version of backupmeta.

func NewMetaReader

func NewMetaReader(backpMeta *backuppb.BackupMeta, storage storage.ExternalStorage) *MetaReader

NewMetaReader creates MetaReader.

func (*MetaReader) ReadDDLs

func (reader *MetaReader) ReadDDLs(ctx context.Context) ([]byte, error)

ReadDDLs reads the ddls from the backupmeta. This function is compatible with the old backupmeta.

func (*MetaReader) ReadSchemasFiles

func (reader *MetaReader) ReadSchemasFiles(ctx context.Context, output chan<- *Table) error

ReadSchemasFiles reads the schema and datafiles from the backupmeta. This function is compatible with the old backupmeta.

type MetaWriter

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

MetaWriter represents wraps a writer, and the MetaWriter should be compatible with old version of backupmeta.

func NewMetaWriter

func NewMetaWriter(storage storage.ExternalStorage, metafileSizeLimit int, useV2Meta bool) *MetaWriter

NewMetaWriter creates MetaWriter.

func (*MetaWriter) ArchiveSize

func (writer *MetaWriter) ArchiveSize() uint64

ArchiveSize represents the size of ArchiveSize.

func (*MetaWriter) Backupmeta

func (writer *MetaWriter) Backupmeta() *backuppb.BackupMeta

Backupmeta clones a backupmeta.

func (*MetaWriter) FinishWriteMetas

func (writer *MetaWriter) FinishWriteMetas(ctx context.Context, op AppendOp) error

FinishWriteMetas close the channel in StartWriteMetasAsync and flush the buffered data.

func (*MetaWriter) Send

func (writer *MetaWriter) Send(m interface{}, op AppendOp) error

Send sends the item to buffer.

func (*MetaWriter) StartWriteMetasAsync

func (writer *MetaWriter) StartWriteMetasAsync(ctx context.Context, op AppendOp)

StartWriteMetasAsync writes four kind of meta into backupmeta. 1. file 2. schema 3. ddl 4. rawRange( raw kv ) when useBackupMetaV2 enabled, it will generate multi-level index backupmetav2. else it will generate backupmeta as before for compatibility. User should call FinishWriteMetas after StartWriterMetasAsync.

func (*MetaWriter) Update

func (writer *MetaWriter) Update(f func(m *backuppb.BackupMeta))

Update updates some property of backupmeta.

type Table

type Table struct {
	DB              *model.DBInfo
	Info            *model.TableInfo
	Crc64Xor        uint64
	TotalKvs        uint64
	TotalBytes      uint64
	Files           []*backuppb.File
	TiFlashReplicas int
	Stats           *handle.JSONTable
}

Table wraps the schema and files of a table.

func (*Table) NoChecksum

func (tbl *Table) NoChecksum() bool

NoChecksum checks whether the table has a calculated checksum.

Jump to

Keyboard shortcuts

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