-
Notifications
You must be signed in to change notification settings - Fork 2
/
null_int32_column_handler.go
51 lines (42 loc) · 1.17 KB
/
null_int32_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
package column_handler
import (
"database/sql"
"github.com/apache/arrow/go/v12/arrow"
"github.com/apache/arrow/go/v12/arrow/array"
)
type NullInt32ColumnHandler struct {
values []int32
notNull []bool
batchSize int64
variable *sql.NullInt32
field arrow.Field
index int
}
func NewNullInt32ColumnHandler(name string, index int, batchSize int64) *NullInt32ColumnHandler {
res := &NullInt32ColumnHandler{
variable: new(sql.NullInt32),
field: arrow.Field{
Name: name,
Nullable: true,
Type: arrow.PrimitiveTypes.Int32,
},
index: index,
batchSize: batchSize,
values: make([]int32, batchSize),
notNull: make([]bool, batchSize),
}
return res
}
func (th *NullInt32ColumnHandler) GetVariable() interface{} {
return th.variable
}
func (th *NullInt32ColumnHandler) SetVariable(row int64) {
th.values[row] = th.variable.Int32
th.notNull[row] = th.variable.Valid
}
func (th *NullInt32ColumnHandler) GetField() arrow.Field {
return th.field
}
func (th *NullInt32ColumnHandler) AppendValues(builder *array.RecordBuilder, rows int64) {
builder.Field(th.index).(*array.Int32Builder).AppendValues(th.values[:rows], th.notNull[:rows])
}