-
Notifications
You must be signed in to change notification settings - Fork 1
/
null_binary_column_handler.go
55 lines (47 loc) · 1.28 KB
/
null_binary_column_handler.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
package column_handler
import (
"github.com/Thor-x86/nullable"
"github.com/apache/arrow/go/v12/arrow"
"github.com/apache/arrow/go/v12/arrow/array"
)
type NullBinaryColumnHandler struct {
values [][]byte
notNull []bool
batchSize int64
variable *nullable.Bytes
field arrow.Field
index int
}
func NewNullBinaryColumnHandler(name string, index int, batchSize int64) *NullBinaryColumnHandler {
res := &NullBinaryColumnHandler{
variable: new(nullable.Bytes),
field: arrow.Field{
Name: name,
Nullable: true,
Type: arrow.BinaryTypes.Binary,
},
index: index,
batchSize: batchSize,
values: make([][]byte, batchSize),
notNull: make([]bool, batchSize),
}
return res
}
func (th *NullBinaryColumnHandler) GetVariable() interface{} {
return th.variable
}
func (th *NullBinaryColumnHandler) SetVariable(row int64) {
valuePointer := th.variable.Get()
if valuePointer == nil {
th.notNull[row] = false
} else {
th.values[row] = *valuePointer
th.notNull[row] = true
}
}
func (th *NullBinaryColumnHandler) GetField() arrow.Field {
return th.field
}
func (th *NullBinaryColumnHandler) AppendValues(builder *array.RecordBuilder, rows int64) {
builder.Field(th.index).(*array.BinaryBuilder).AppendValues(th.values[:rows], th.notNull[:rows])
}