Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions arrow/array/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,34 @@ func (b *RecordBuilder) Reserve(size int) {
}
}

// Resize adjusts the space allocated by all the field builders to n elements.
// If n is greater than an individual builder Cap(), additional memory will be
// allocated. If n is smaller, the allocated memory may reduced.
//
// As a special case, if n equals to -1, all field builders will be resized
// to the size of the shortest one.
func (b *RecordBuilder) Resize(n int) {
if n >= 0 {
for _, f := range b.fields {
f.Resize(n)
}
} else if n == -1 && len(b.fields) > 0 {
minLen := b.fields[0].Len()
var resizeNeeded bool

for _, f := range b.fields[1 : ] {
if f.Len() < minLen {
resizeNeeded = true
minLen = f.Len()
}
}

if resizeNeeded {
b.Resize(minLen)
}
}
}

// NewRecordBatch creates a new record batch from the memory buffers and resets the
// RecordBuilder so it can be used to build a new record batch.
//
Expand Down
Loading