Skip to content

Commit c055186

Browse files
sbinetwesm
authored andcommitted
[Go] add Release, Reserve and Resize to array.Builder interface
1 parent 4aaff04 commit c055186

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

go/arrow/array/builder.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const (
3131

3232
// Builder provides an interface to build arrow arrays.
3333
type Builder interface {
34+
// Retain increases the reference count by 1.
35+
// Retain may be called simultaneously from multiple goroutines.
36+
Retain()
37+
3438
// Release decreases the reference count by 1.
3539
Release()
3640

@@ -47,6 +51,14 @@ type Builder interface {
4751
// AppendNull adds a new null value to the array being built.
4852
AppendNull()
4953

54+
// Reserve ensures there is enough space for appending n elements
55+
// by checking the capacity and calling Resize if necessary.
56+
Reserve(n int)
57+
58+
// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
59+
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
60+
Resize(n int)
61+
5062
// NewArray creates a new array from the memory buffers used
5163
// by the builder and resets the Builder so it can be used to build
5264
// a new array.

go/arrow/array/null.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,13 @@ func (b *NullBuilder) AppendNull() {
8686
b.builder.nulls++
8787
}
8888

89+
func (*NullBuilder) Reserve(size int) {}
90+
func (*NullBuilder) Resize(size int) {}
91+
8992
func (*NullBuilder) init(cap int) {}
9093
func (*NullBuilder) resize(newBits int, init func(int)) {}
9194

92-
// NewArray creates a List array from the memory buffers used by the builder and resets the NullBuilder
95+
// NewArray creates a Null array from the memory buffers used by the builder and resets the NullBuilder
9396
// so it can be used to build a new array.
9497
func (b *NullBuilder) NewArray() Interface {
9598
return b.NewNullArray()

0 commit comments

Comments
 (0)