Documentation ¶
Index ¶
- Constants
- Variables
- func GetExtension(ext string) string
- func GetOptionFactory(ctx context.Context, engine string) func(db string, tbl string, account string) TableOptions
- func SetPathBuilder(ctx context.Context, pathBuilder string) error
- func String2Bytes(s string) (ret []byte)
- func Time2DatetimeString(t time.Time) string
- type AccountDatePathBuilder
- func (b *AccountDatePathBuilder) Build(account string, typ MergeLogType, ts time.Time, db string, tblName string) string
- func (b *AccountDatePathBuilder) BuildETLPath(db, name, account string) string
- func (b *AccountDatePathBuilder) GetName() string
- func (b *AccountDatePathBuilder) NewLogFilename(name, nodeUUID, nodeType string, ts time.Time, extension string) string
- func (b *AccountDatePathBuilder) NewMergeFilename(timestampStart, timestampEnd, extension string) string
- func (b *AccountDatePathBuilder) ParsePath(ctx context.Context, path string) (Path, error)
- func (b *AccountDatePathBuilder) SupportAccountStrategy() bool
- func (b *AccountDatePathBuilder) SupportMergeSplit() bool
- type ColType
- type Column
- func DatetimeColumn(name, comment string) Column
- func Int64Column(name, comment string) Column
- func JsonColumn(name, comment string) Column
- func SpanIDStringColumn(name, comment string) Column
- func StringColumn(name, comment string) Column
- func StringDefaultColumn(name, defaultVal, comment string) Column
- func StringWithPrecision(name string, precision int, comment string) Column
- func TextColumn(name, comment string) Column
- func UInt64Column(name, comment string) Column
- func UuidStringColumn(name, comment string) Column
- func ValueColumn(name, comment string) Column
- type CsvOptions
- type CsvTableOptions
- type DBTablePathBuilder
- func (m *DBTablePathBuilder) Build(account string, typ MergeLogType, ts time.Time, db string, name string) string
- func (m *DBTablePathBuilder) BuildETLPath(db, name, account string) string
- func (m *DBTablePathBuilder) GetName() string
- func (m *DBTablePathBuilder) NewLogFilename(name, nodeUUID, nodeType string, ts time.Time, extension string) string
- func (m *DBTablePathBuilder) NewMergeFilename(timestampStart, timestampEnd, extension string) string
- func (m *DBTablePathBuilder) ParsePath(ctx context.Context, path string) (Path, error)
- func (m *DBTablePathBuilder) SupportAccountStrategy() bool
- func (m *DBTablePathBuilder) SupportMergeSplit() bool
- type ETLPath
- type ExportRequests
- type FilePathCfg
- type MergeLogType
- type NoopTableOptions
- type Path
- type PathBuilder
- type PathBuilderConfig
- type PathBuilderOption
- type Row
- func (r *Row) Clone() *Row
- func (r *Row) CsvPrimaryKey() string
- func (r *Row) Free()
- func (r *Row) GetAccount() string
- func (r *Row) GetCsvStrings() []string
- func (r *Row) GetRawColumn() []any
- func (r *Row) ParseRow(cols []string) error
- func (r *Row) Reset()
- func (r *Row) SetColumnVal(col Column, val any)
- func (r *Row) SetVal(col string, val any)
- func (r *Row) Size() (size int64)
- func (r *Row) ToStrings() []string
- type RowField
- type RowRequest
- type RowWriter
- type Table
- func (tbl *Table) Clone() *Table
- func (tbl *Table) GetDatabase() string
- func (tbl *Table) GetIdentify() string
- func (tbl *Table) GetName() string
- func (tbl *Table) GetRow(ctx context.Context) *Row
- func (tbl *Table) GetTableOptions(ctx context.Context) TableOptions
- func (tbl *Table) ToCreateSql(ctx context.Context, ifNotExists bool) string
- type TableOptions
- type View
- type ViewOption
- type ViewSingleCondition
- type WhereCondition
- type WriteRequest
- type WriterFactory
Constants ¶
const AccountAll = ETLParamAccountAll
const CsvExtension = ".csv"
const ETLParamAccountAll = "*"
const ETLParamTypeAll = MergeLogTypeALL
const ExternalFilePath = "__mo_filepath"
const FilenameElems = 3
const FilenameElemsV2 = 4
const FilenameIdxType = 2
const FilenameSeparator = "_"
const PathElems = 7
const PathIdxAccount = 0
const PathIdxFilename = 6
const PathIdxTable = 5
const TaeExtension = ".tae"
Variables ¶
var CommonCsvOptions = &CsvOptions{
FieldTerminator: ',',
EncloseRune: '"',
Terminator: '\n',
}
var ETLParamTSAll = time.Time{}
var ExternalTableEngine = "EXTERNAL"
var NSecString = func() string { timeMu.Lock() nsec := time.Now().Nanosecond() timeMu.Unlock() return fmt.Sprintf("%09d", nsec) }
var NormalTableEngine = "TABLE"
Functions ¶
func GetExtension ¶
func GetOptionFactory ¶
func String2Bytes ¶
func Time2DatetimeString ¶
Types ¶
type AccountDatePathBuilder ¶
type AccountDatePathBuilder struct {
PathBuilderConfig
}
func NewAccountDatePathBuilder ¶
func NewAccountDatePathBuilder(opts ...PathBuilderOption) *AccountDatePathBuilder
func (*AccountDatePathBuilder) Build ¶
func (b *AccountDatePathBuilder) Build(account string, typ MergeLogType, ts time.Time, db string, tblName string) string
func (*AccountDatePathBuilder) BuildETLPath ¶
func (b *AccountDatePathBuilder) BuildETLPath(db, name, account string) string
BuildETLPath implement PathBuilder
# account | typ | ts | table | filename like: * /* /*/*/* /metric /*.csv
func (*AccountDatePathBuilder) GetName ¶
func (b *AccountDatePathBuilder) GetName() string
func (*AccountDatePathBuilder) NewLogFilename ¶
func (*AccountDatePathBuilder) NewMergeFilename ¶
func (b *AccountDatePathBuilder) NewMergeFilename(timestampStart, timestampEnd, extension string) string
func (*AccountDatePathBuilder) SupportAccountStrategy ¶
func (b *AccountDatePathBuilder) SupportAccountStrategy() bool
func (*AccountDatePathBuilder) SupportMergeSplit ¶
func (b *AccountDatePathBuilder) SupportMergeSplit() bool
type Column ¶
type Column struct { Name string ColType ColType // Precision default 0, usually for varchar Precision int Default string Comment string Alias string // only use in view }
func DatetimeColumn ¶
func Int64Column ¶
func JsonColumn ¶
func SpanIDStringColumn ¶
func StringColumn ¶
func StringDefaultColumn ¶
func StringWithPrecision ¶
func TextColumn ¶
func UInt64Column ¶
func UuidStringColumn ¶
func ValueColumn ¶
func (*Column) ToCreateSql ¶
ToCreateSql return column scheme in create sql
- case 1: `column_name` varchar(36) DEFAULT "def_val" COMMENT "what am I, with default."
- case 2: `column_name` varchar(36) NOT NULL COMMENT "what am I. Without default, SO NOT NULL."
type CsvOptions ¶
type CsvTableOptions ¶
func (*CsvTableOptions) FormatDdl ¶
func (o *CsvTableOptions) FormatDdl(ddl string) string
func (*CsvTableOptions) GetCreateOptions ¶
func (o *CsvTableOptions) GetCreateOptions() string
func (*CsvTableOptions) GetTableOptions ¶
func (o *CsvTableOptions) GetTableOptions(builder PathBuilder) string
type DBTablePathBuilder ¶
type DBTablePathBuilder struct{}
func NewDBTablePathBuilder ¶
func NewDBTablePathBuilder() *DBTablePathBuilder
func (*DBTablePathBuilder) Build ¶
func (m *DBTablePathBuilder) Build(account string, typ MergeLogType, ts time.Time, db string, name string) string
func (*DBTablePathBuilder) BuildETLPath ¶
func (m *DBTablePathBuilder) BuildETLPath(db, name, account string) string
BuildETLPath implement PathBuilder
like: system/metric_*.csv
func (*DBTablePathBuilder) GetName ¶
func (m *DBTablePathBuilder) GetName() string
func (*DBTablePathBuilder) NewLogFilename ¶
func (*DBTablePathBuilder) NewMergeFilename ¶
func (m *DBTablePathBuilder) NewMergeFilename(timestampStart, timestampEnd, extension string) string
func (*DBTablePathBuilder) SupportAccountStrategy ¶
func (m *DBTablePathBuilder) SupportAccountStrategy() bool
func (*DBTablePathBuilder) SupportMergeSplit ¶
func (m *DBTablePathBuilder) SupportMergeSplit() bool
type ETLPath ¶
type ETLPath struct {
// contains filtered or unexported fields
}
func NewETLPath ¶
NewETLPath
path like: sys/[log|merged]/yyyy/mm/dd/table/***.csv ## idx: 0 1 2 3 4 5 6 filename like: {timestamp}_{node_uuid}_{node_type}.csv ## or: {timestamp_start}_{timestamp_end}_merged.csv
type ExportRequests ¶
type ExportRequests []WriteRequest
type FilePathCfg ¶
func (*FilePathCfg) LogsFilePathFactory ¶
type MergeLogType ¶
type MergeLogType string
const MergeLogTypeALL MergeLogType = "*"
const MergeLogTypeLogs MergeLogType = "logs"
const MergeLogTypeMerged MergeLogType = "merged"
func (MergeLogType) String ¶
func (t MergeLogType) String() string
type NoopTableOptions ¶
type NoopTableOptions struct{}
func (NoopTableOptions) FormatDdl ¶
func (o NoopTableOptions) FormatDdl(ddl string) string
func (NoopTableOptions) GetCreateOptions ¶
func (o NoopTableOptions) GetCreateOptions() string
func (NoopTableOptions) GetTableOptions ¶
func (o NoopTableOptions) GetTableOptions(PathBuilder) string
type PathBuilder ¶
type PathBuilder interface { // Build directory path Build(account string, typ MergeLogType, ts time.Time, db string, name string) string // BuildETLPath return path for EXTERNAL table 'infile' options // // like: {account}/merged/*/*/*/{name}/*.csv BuildETLPath(db, name, account string) string // ParsePath // // switch path { // case "{timestamp_writedown}_{node_uuid}_{ndoe_type}.csv": // case "{timestamp_start}_{timestamp_end}_merged.csv" // } ParsePath(ctx context.Context, path string) (Path, error) NewMergeFilename(timestampStart, timestampEnd, extension string) string NewLogFilename(name, nodeUUID, nodeType string, ts time.Time, extension string) string // SupportMergeSplit const. if false, not support SCV merge|split task SupportMergeSplit() bool // SupportAccountStrategy const SupportAccountStrategy() bool // GetName const GetName() string }
PathBuilder hold strategy to build filepath
func PathBuilderFactory ¶
func PathBuilderFactory(pathBuilder string) PathBuilder
type PathBuilderConfig ¶
type PathBuilderConfig struct {
// contains filtered or unexported fields
}
type PathBuilderOption ¶
type PathBuilderOption func(*PathBuilderConfig)
func WithDatabase ¶
func WithDatabase(with bool) PathBuilderOption
func (PathBuilderOption) Apply ¶
func (opt PathBuilderOption) Apply(cfg *PathBuilderConfig)
type Row ¶
func (*Row) CsvPrimaryKey ¶
func (*Row) GetAccount ¶
GetAccount return r.Columns[r.AccountIdx] if r.AccountIdx >= 0 and r.Table.PathBuilder.SupportAccountStrategy, else return "sys"
func (*Row) GetRawColumn ¶
func (*Row) SetColumnVal ¶
type RowRequest ¶
type RowRequest struct {
// contains filtered or unexported fields
}
func NewRowRequest ¶
func NewRowRequest(writer RowWriter) *RowRequest
func (*RowRequest) GetContent ¶
func (r *RowRequest) GetContent() string
func (*RowRequest) Handle ¶
func (r *RowRequest) Handle() (int, error)
type Table ¶
type Table struct { Account string Database string Table string Columns []Column PrimaryKeyColumn []Column Engine string Comment string // PathBuilder help to desc param 'infile' PathBuilder PathBuilder // AccountColumn help to split data in account's filepath AccountColumn *Column // TableOptions default is nil, see GetTableOptions TableOptions TableOptions // SupportUserAccess default false. if true, user account can access. SupportUserAccess bool // SupportConstAccess default false. if true, use Table.Account SupportConstAccess bool // contains filtered or unexported fields }
func GetAllTable ¶
func GetAllTable() []*Table
func RegisterTableDefine ¶
RegisterTableDefine return old one, if already registered
func (*Table) GetDatabase ¶
func (*Table) GetIdentify ¶
GetIdentify return identify like database.table
func (*Table) GetTableOptions ¶
func (tbl *Table) GetTableOptions(ctx context.Context) TableOptions
type TableOptions ¶
type TableOptions interface { FormatDdl(ddl string) string // GetCreateOptions return option for `create {option}table`, which should end with ' ' GetCreateOptions() string GetTableOptions(PathBuilder) string }
type View ¶
type ViewOption ¶
type ViewOption func(view *View)
func SupportUserAccess ¶
func SupportUserAccess(support bool) ViewOption
func WithColumn ¶
func WithColumn(c Column) ViewOption
func (ViewOption) Apply ¶
func (opt ViewOption) Apply(view *View)
type ViewSingleCondition ¶
func (*ViewSingleCondition) String ¶
func (tbl *ViewSingleCondition) String() string
type WhereCondition ¶
type WhereCondition interface {
String() string
}