clickhouse

package
v1.0.1-0...-b7751fa Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsClickhouseShadow

func IsClickhouseShadow(path string) bool

func TablePathEncode

func TablePathEncode(str string) string

Types

type BackupPartition

type BackupPartition struct {
	Partition                         string `json:"Partition"`
	Name                              string `json:"Name"`
	Path                              string `json:"Path"`
	HashOfAllFiles                    string `json:"hash_of_all_files"`
	HashOfUncompressedFiles           string `json:"hash_of_uncompressed_files"`
	UncompressedHashOfCompressedFiles string `json:"uncompressed_hash_of_compressed_files"`
	Active                            uint8  `json:"active"`
}

BackupPartition - struct representing Clickhouse partition

type BackupTable

type BackupTable struct {
	Database   string
	Name       string
	Partitions []BackupPartition
}

BackupTable - struct to store additional information on partitions

type BackupTables

type BackupTables []BackupTable

BackupTables - slice of BackupTable

func (BackupTables) Sort

func (bt BackupTables) Sort()

Sort - sorting BackupTables slice orderly by name

type ClickHouse

type ClickHouse struct {
	Config *config.ClickHouseConfig
	// contains filtered or unexported fields
}

ClickHouse - provide

func (*ClickHouse) ApplyPartitionsChanges

func (ch *ClickHouse) ApplyPartitionsChanges(table PartDiff) error

ApplyPartitionsChanges - add/remove partitions to/from the live table

func (*ClickHouse) AttachPartitions

func (ch *ClickHouse) AttachPartitions(table BackupTable) error

AttachPartitions - execute ATTACH command for specific table

func (*ClickHouse) Chown

func (ch *ClickHouse) Chown(filename string) error

Chown - set permission on file to clickhouse user This is necessary that the ClickHouse will be able to read parts files on restore

func (*ClickHouse) Close

func (ch *ClickHouse) Close() error

Close - closing connection to ClickHouse

func (*ClickHouse) ComputePartitionsDelta

func (ch *ClickHouse) ComputePartitionsDelta(restoreTables []BackupTable, liveTables []Table) ([]PartDiff, error)

ComputePartitionsDelta - computes the data partitions to be added and removed between live and backup tables

func (*ClickHouse) Connect

func (ch *ClickHouse) Connect() error

Connect - establish connection to ClickHouse

func (*ClickHouse) CopyData

func (ch *ClickHouse) CopyData(table BackupTable) error

CopyData - copy partitions for specific table to detached folder

func (*ClickHouse) CopyDataDiff

func (ch *ClickHouse) CopyDataDiff(diff PartDiff) error

CopyDataDiff - copy only partitions that will be attached to "detached" folder

func (*ClickHouse) CreateDatabase

func (ch *ClickHouse) CreateDatabase(database string) error

CreateDatabase - create ClickHouse database

func (*ClickHouse) CreateTable

func (ch *ClickHouse) CreateTable(table Table, query string, dropTable bool) error

CreateTable - create ClickHouse table

func (*ClickHouse) FreezeTable

func (ch *ClickHouse) FreezeTable(table Table) error

FreezeTable - freeze all partitions for table This way available for ClickHouse sience v19.1

func (*ClickHouse) FreezeTableOldWay

func (ch *ClickHouse) FreezeTableOldWay(table Table) error

FreezeTableOldWay - freeze all partitions in table one by one This way using for ClickHouse below v19.1

func (*ClickHouse) GetBackupTables

func (ch *ClickHouse) GetBackupTables(backupName string) (map[string]BackupTable, error)

GetBackupTables - return list of backups of tables that can be restored

func (*ClickHouse) GetConn

func (ch *ClickHouse) GetConn() *sqlx.DB

GetConn - return current connection

func (*ClickHouse) GetDataPath

func (ch *ClickHouse) GetDataPath() (string, error)

GetDataPath - return ClickHouse data_path

func (*ClickHouse) GetPartitions

func (ch *ClickHouse) GetPartitions(table Table) ([]Partition, error)

GetPartitions - return slice of all partitions for a table

func (*ClickHouse) GetTables

func (ch *ClickHouse) GetTables() ([]Table, error)

GetTables - return slice of all tables suitable for backup

func (*ClickHouse) GetVersion

func (ch *ClickHouse) GetVersion() (int, error)

GetVersion - returned ClickHouse version in number format Example value: 19001005

type PartDiff

type PartDiff struct {
	BTable           BackupTable
	PartitionsAdd    []Partition
	PartitionsRemove []Partition
}

PartDiff - Data part discrepancies infos

type Partition

type Partition struct {
	Partition                         string `db:"partition"`
	Name                              string `db:"name"`
	Path                              string `db:"path"`
	HashOfAllFiles                    string `db:"hash_of_all_files"`
	HashOfUncompressedFiles           string `db:"hash_of_uncompressed_files"`
	UncompressedHashOfCompressedFiles string `db:"uncompressed_hash_of_compressed_files"`
	Active                            uint8  `db:"active"`
}

Partition - partition info from system.parts

type Table

type Table struct {
	Database string `db:"database" json:"database"`
	Name     string `db:"name" json:"table"`
	Skip     bool   `json:"skip"`
}

Table - ClickHouse table struct

Jump to

Keyboard shortcuts

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