blob: 1a82509149907552f8f7a5d3017a0806cb4b25a4 (
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
|
package proto
import (
"fmt"
"github.com/go-faster/errors"
)
// Nothing represents NULL value.
type Nothing struct{}
// ColNothing represents column of null values.
// Value is row count.
//
// https://clickhouse.com/docs/ru/sql-reference/data-types/special-data-types/nothing
type ColNothing int
func (c *ColNothing) Append(_ Nothing) {
*c++
}
func (c *ColNothing) AppendArr(vs []Nothing) {
*c = ColNothing(int(*c) + len(vs))
}
func (c ColNothing) Row(i int) Nothing {
if i >= int(c) {
panic(fmt.Sprintf("[%d] of [%d]Nothing", i, c))
}
return Nothing{}
}
func (c ColNothing) Type() ColumnType {
return ColumnTypeNothing
}
func (c ColNothing) Rows() int {
return int(c)
}
func (c *ColNothing) DecodeColumn(r *Reader, rows int) error {
*c = ColNothing(rows)
if rows == 0 {
return nil
}
if _, err := r.ReadRaw(rows); err != nil {
return errors.Wrap(err, "read")
}
return nil
}
func (c *ColNothing) Reset() {
*c = 0
}
func (c *ColNothing) Nullable() *ColNullable[Nothing] {
return &ColNullable[Nothing]{
Values: c,
}
}
func (c *ColNothing) Array() *ColArr[Nothing] {
return &ColArr[Nothing]{
Data: c,
}
}
func (c ColNothing) EncodeColumn(b *Buffer) {
if c == 0 {
return
}
b.PutRaw(make([]byte, c))
}
|