Skip to content

Commit c2b7711

Browse files
committed
Implement UnsafeAppendBoolToBitmap for dictionary and REE builders
For more context: https://github.com/apache/arrow-go/pull/558/changes#r2758798540 This commit introduces an implementation of `UnsafeAppendBoolToBitmap()` to `dictionaryBuilder` and `RunEndEncodedBuilder`. The current implementation pulled from `arrow/array/builder.go` would leave the builders in invalid states that would panic when trying to finish a record batch. For `dictionaryBuilder`, we defer the implementation to the inner `indexBuilder`, which will in turn increase the logical length of the inner buffer and set the bit. For `RunEndEncodedBuilder` I decided to just panic after talking to @felipecrv since the semantics of what it should do are not clear.
1 parent a6c0a5e commit c2b7711

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

arrow/array/dictionary.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,12 @@ func (b *dictionaryBuilder) AppendEmptyValues(n int) {
646646
}
647647
}
648648

649+
func (b *dictionaryBuilder) UnsafeAppendBoolToBitmap(v bool) {
650+
b.length += 1
651+
b.nulls += 1
652+
b.idxBuilder.UnsafeAppendBoolToBitmap(v)
653+
}
654+
649655
func (b *dictionaryBuilder) Reserve(n int) {
650656
b.idxBuilder.Reserve(n)
651657
}

arrow/array/encoded.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ func (b *RunEndEncodedBuilder) AppendNulls(n int) {
398398
}
399399
}
400400

401+
func (b *RunEndEncodedBuilder) UnsafeAppendBoolToBitmap(v bool) {
402+
panic("Calling UnsafeAppendBoolToBitmap on a run-end encoded array is logically unsound.")
403+
}
404+
401405
func (b *RunEndEncodedBuilder) NullN() int {
402406
return UnknownNullCount
403407
}

0 commit comments

Comments
 (0)