-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormatter.go
78 lines (70 loc) · 1.63 KB
/
Formatter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
type Formatter interface {
Init(output_file string, columns map[string]FormatterColumn, indexes []FormatterIndex, group_analyzers []GroupAnalyzer) error
GetFeatures() int
WriteRow(map[string]*string) error
Close()
}
const (
FMT_FEATURE_GENERATED_AS = 1
)
type GeneratorData struct {
Format string `json:"format"`
PrimaryType string `json:"primary_type"`
Tags []string `json:"tags"`
Version int `json:"ver"`
LinkedColumn string `json:"linked_col"`
CustomData any `json:"custom_data"`
}
type FormatterColumn struct {
Name string
ForceString bool
Tags []string
IsInvisible bool
// expression used to generate the targeted value
AlwaysGeneratedAs string
Generator interface {
GetGeneratorInfo() GeneratorInfo
}
// data of the analyzer that generated this column
GeneratorData *GeneratorData
// analyzers that will pass on it to generate new columns
Analyzers []Analyzer
}
const (
FMT_TYPE_UNKNOWN = -1
FMT_TYPE_STR = 0
FMT_TYPE_INT8 = 1
FMT_TYPE_UINT8 = 2
FMT_TYPE_INT16 = 3
FMT_TYPE_UINT16 = 4
FMT_TYPE_INT32 = 5
FMT_TYPE_UINT32 = 6
FMT_TYPE_INT64 = 7
FMT_TYPE_UINT64 = 8
FMT_TYPE_ENUM = 9
)
type FormatterIndex struct {
ColumnName string
IndexName string
Reversed bool
}
func StrType2FmtType(typ string) int8 {
switch typ {
case "str":
return FMT_TYPE_STR
case "int8":
return FMT_TYPE_INT8
case "int16":
return FMT_TYPE_INT16
case "int32":
return FMT_TYPE_INT32
case "int64":
return FMT_TYPE_INT64
case "uint16":
return FMT_TYPE_UINT16
case "uint32":
return FMT_TYPE_UINT32
}
return FMT_TYPE_UNKNOWN
}