aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/ClickHouse/ch-go/proto/cmd/ch-gen-col/main.go.tmpl
blob: 574e5d35bd07544fb2716842d2b2254acec3a992 (plain) (blame)
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
{{- /*gotype: github.com/ClickHouse/ch-go/proto/cmd/ch-gen-col.Variant*/ -}}
// Code generated by ./cmd/ch-gen-col, DO NOT EDIT.

package proto

// {{ .Type }} represents {{ .Name }} column.
type {{ .Type }} []{{ .ElemType }}

// Compile-time assertions for {{ .Type }}.
var (
	_ ColInput  = {{ .Type }}{}
	_ ColResult = (*{{ .Type }})(nil)
	_ Column    = (*{{ .Type }})(nil)
)

// Rows returns count of rows in column.
func (c {{ .Type }}) Rows() int {
	return len(c)
}

// Reset resets data in row, preserving capacity for efficiency.
func (c *{{ .Type }}) Reset() {
	*c = (*c)[:0]
}

// Type returns ColumnType of {{ .Name }}.
func ({{ .Type }}) Type() ColumnType {
	return {{ .ColumnType }}
}

{{ if not .Time }}
// Row returns i-th row of column.
func (c {{ .Type }}) Row(i int) {{ .ElemType }} {
	return c[i]
}

// Append {{ .ElemType }} to column.
func (c *{{ .Type }}) Append(v {{ .ElemType }})  {
	*c = append(*c, v)
}

// Append {{ .ElemType }} slice to column.
func (c *{{ .Type }}) AppendArr(vs []{{ .ElemType }})  {
	*c = append(*c, vs...)
}

// LowCardinality returns LowCardinality for {{ .Name }} .
func (c *{{ .Type }}) LowCardinality() *ColLowCardinality[{{ .ElemType }}] {
	return &ColLowCardinality[{{ .ElemType }}]{
		index: c,
	}
}

// Array is helper that creates Array of {{ .ElemType }}.
func (c *{{ .Type }}) Array() *ColArr[{{ .ElemType }}] {
	return &ColArr[{{ .ElemType }}]{
		Data: c,
	}
}

// Nullable is helper that creates Nullable({{ .ElemType }}).
func (c *{{ .Type }}) Nullable() *ColNullable[{{ .ElemType }}] {
	return &ColNullable[{{ .ElemType }}]{
		Values: c,
	}
}

// NewArr{{ .Name }} returns new Array({{ .Name }}).
func NewArr{{ .Name }}() *ColArr[{{ .ElemType }}] {
	return &ColArr[{{ .ElemType }}]{
		Data: new({{ .Type }}),
	}
}

{{ end }}