ckdb

package
v1.6.65 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Distributed EngineType = iota
	MergeTree
	ReplicatedMergeTree
	AggregatingMergeTree
	ReplicatedAggregatingMergeTree
	ReplacingMergeTree
	SummingMergeTree

	EngineByconityOffset
	CnchMergeTree            = MergeTree + EngineByconityOffset
	CnchAggregatingMergeTree = AggregatingMergeTree + EngineByconityOffset
	CnchReplacingMergeTree   = ReplacingMergeTree + EngineByconityOffset
	CnchSummingMergeTree     = SummingMergeTree + EngineByconityOffset
)
View Source
const (
	DF_STORAGE_POLICY     = "df_storage"
	DF_CLUSTER            = "df_cluster"
	DF_REPLICATED_CLUSTER = "df_replicated_cluster"
	DF_TIMEZONE           = "Asia/Shanghai"
	CKDBTypeClickhouse    = "clickhouse"
	CKDBTypeByconity      = "byconity"
)
View Source
const (
	DEFAULT_ORG_ID    = 1
	INVALID_ORG_ID    = 0
	DEFAULT_TEAM_ID   = 1
	INVALID_TEAM_ID   = 0
	ORG_ID_LEN        = 4 // length of 'xxxx'
	ORG_ID_PREFIX_LEN = 5 // length of 'xxxx_'
	MAX_ORG_ID        = 1024
)
View Source
const (
	METRICS_DB    = "flow_metrics"
	LOCAL_SUBFFIX = "_local"
)
View Source
const DEFAULT_COLUMN_COUNT = 256

Variables

This section is empty.

Functions

func IsDefaultOrgID

func IsDefaultOrgID(orgID uint16) bool

func IsValidOrgID

func IsValidOrgID(orgID uint16) bool

func OrgDatabasePrefix

func OrgDatabasePrefix(orgID uint16) string

Types

type Block

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

func NewBlock

func NewBlock(batch driver.Batch) *Block

func (*Block) Send

func (b *Block) Send() error

func (*Block) Write

func (b *Block) Write(v ...interface{})

func (*Block) WriteAll

func (b *Block) WriteAll() error

func (*Block) WriteBool

func (b *Block) WriteBool(v bool)

func (*Block) WriteDateTime

func (b *Block) WriteDateTime(v uint32)

func (*Block) WriteIPv4

func (b *Block) WriteIPv4(v uint32)

func (*Block) WriteIPv6

func (b *Block) WriteIPv6(v net.IP)

type CodecType

type CodecType uint8
const (
	CodecDefault CodecType = iota // lz4
	CodecLZ4
	CodecLZ4HC
	CodecZSTD
	CodecT64
	CodecDelta
	CodecDoubleDelta
	CodecGorilla
	CodecNone
)

func (CodecType) String

func (t CodecType) String() string

type ColdStorage

type ColdStorage struct {
	Enabled   bool
	Type      DiskType
	Name      string
	TTLToMove int // after 'TTLToMove' hours, then move data to cold storage
}

func GetColdStorage

func GetColdStorage(coldStorages map[string]*ColdStorage, db, table string) *ColdStorage

type Column

type Column struct {
	Name     string     // 列名
	Type     ColumnType // 数据类型
	TypeArgs string
	Codec    CodecType // 压缩算法
	Index    IndexType // 二级索引
	GroupBy  bool      // 在AggregatingMergeTree表中用于group by的字段
	Comment  string    // 列注释
}

func NewColumn

func NewColumn(name string, t ColumnType) *Column

func NewColumnWithGroupBy

func NewColumnWithGroupBy(name string, t ColumnType) *Column

func NewColumns

func NewColumns(names []string, t ColumnType) []*Column

func NewColumnsWithComment

func NewColumnsWithComment(nameComments [][2]string, t ColumnType) []*Column

nameComments: 需要同时创建的列列表,列表元素是长度为2的字符串数组, 第一个元素是列名,第二个是注释内容

func (*Column) MakeModifyTimeZoneSQL

func (c *Column) MakeModifyTimeZoneSQL(database, table, timeZone string) string

func (*Column) SetCodec

func (c *Column) SetCodec(ct CodecType) *Column

func (*Column) SetComment

func (c *Column) SetComment(comment string) *Column

func (*Column) SetGroupBy

func (c *Column) SetGroupBy() *Column

func (*Column) SetIndex

func (c *Column) SetIndex(i IndexType) *Column

func (*Column) SetTypeArgs

func (c *Column) SetTypeArgs(args string) *Column

type ColumnType

type ColumnType uint8
const (
	UInt64 ColumnType = iota
	UInt64Nullable
	UInt32
	UInt32Nullable
	UInt16
	UInt16Nullable
	UInt8
	UInt8Nullable
	Int64
	Int64Nullable
	Int32
	Int32Nullable
	Int16
	Int16Nullable
	Int8
	Int8Nullable
	Float64
	Float64Nullable
	String
	IPv6
	IPv4
	ArrayString
	ArrayUInt8
	ArrayUInt16
	ArrayUInt32
	ArrayInt64
	ArrayFloat64
	DateTime
	DateTime64
	DateTime64ms
	DateTime64us
	FixString8
	LowCardinalityString
	ArrayLowCardinalityString
	ENUM8
)

func (ColumnType) HasDFTimeZone

func (t ColumnType) HasDFTimeZone() bool

func (ColumnType) String

func (t ColumnType) String() string

type DiskType

type DiskType uint8
const (
	Volume DiskType = iota
	Disk
)

func (DiskType) String

func (t DiskType) String() string

type EngineType

type EngineType uint8

func (EngineType) String

func (t EngineType) String() string

type IndexType

type IndexType uint8
const (
	IndexNone IndexType = iota
	IndexMinmax
	IndexSet
	IndexBloomfilter
	IndexTokenbf
)

func (IndexType) String

func (t IndexType) String() string

type Table

type Table struct {
	Version         string       // 表版本,用于表结构变更时,做自动更新
	ID              uint8        // id
	Database        string       // 所属数据库名
	DBType          string       // clickhouse or byconity
	LocalName       string       // 本地表名
	GlobalName      string       // 全局表名
	Columns         []*Column    // 表列结构
	TimeKey         string       // 时间字段名,用来设置partition和ttl
	SummingKey      string       // When using SummingMergeEngine, this field is used for Summing aggregation
	TTL             int          // 数据默认保留时长。 单位:小时
	ColdStorage     ColdStorage  // 冷存储配置
	PartitionFunc   TimeFuncType // partition函数作用于Time,
	Cluster         string       // 对应的cluster
	StoragePolicy   string       // 存储策略
	Engine          EngineType   // 表引擎
	OrderKeys       []string     // 排序的key
	PrimaryKeyCount int          // 一级索引的key的个数, 从orderKeys中数前n个,
}

func (*Table) MakeGlobalTableCreateSQL

func (t *Table) MakeGlobalTableCreateSQL() string

func (*Table) MakeLocalTableCreateSQL

func (t *Table) MakeLocalTableCreateSQL() string

func (*Table) MakeOrgGlobalTableCreateSQL

func (t *Table) MakeOrgGlobalTableCreateSQL(orgID uint16) string

func (*Table) MakeOrgLocalTableCreateSQL

func (t *Table) MakeOrgLocalTableCreateSQL(orgID uint16) string

func (*Table) MakeOrgPrepareTableInsertSQL

func (t *Table) MakeOrgPrepareTableInsertSQL(orgID uint16) string

func (*Table) MakePrepareTableInsertSQL

func (t *Table) MakePrepareTableInsertSQL() string

func (*Table) MakeViewsCreateSQLForDeepflowSystem

func (t *Table) MakeViewsCreateSQLForDeepflowSystem(orgID uint16) []string

database 'xxxx_deepflow_system' adds 'deepflow_system' view pointing to the 'deepflow_system_agent' and 'deepflow_system_server' table

func (*Table) OrgDatabase

func (t *Table) OrgDatabase(orgID uint16) string

type TimeFuncType

type TimeFuncType uint8
const (
	TimeFuncNone TimeFuncType = iota
	TimeFuncMinute
	TimeFuncTenMinute
	TimeFuncHour
	TimeFuncTwoHour
	TimeFuncFourHour
	TimeFuncTwelveHour
	TimeFuncDay
	TimeFuncWeek
	TimeFuncMonth
	TimeFuncYYYYMM
	TimeFuncYYYYMMDD
)

func (TimeFuncType) String

func (t TimeFuncType) String(timeKey string) string

Jump to

Keyboard shortcuts

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