Skip to content
Closed
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions arrow/array/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ func (b *builder) SetNull(i int) {
if i < 0 || i >= b.length {
panic("arrow/array: index out of range")
}
if bitutil.BitIsSet(b.nullBitmap.Bytes(), i) {
b.nulls++
}
bitutil.ClearBit(b.nullBitmap.Bytes(), i)
}

Expand Down
13 changes: 13 additions & 0 deletions arrow/array/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ func TestBuilder_SetNull(t *testing.T) {
b.SetNull(i)
}
}
assert.Equal(t, n/2, b.nulls)
assert.Equal(t, n/2, b.NullN())

b.SetNull(0)
assert.Equal(t, n/2, b.nulls)
assert.Equal(t, n/2, b.NullN())
b.SetNull(1)
assert.Equal(t, n/2+1, b.nulls)
assert.Equal(t, n/2+1, b.NullN())
b.SetNull(1)
assert.Equal(t, n/2+1, b.nulls)
assert.Equal(t, n/2+1, b.NullN())

for i := 0; i < n; i++ {
if i%2 == 0 {
Expand All @@ -120,4 +132,5 @@ func TestBuilder_SetNull(t *testing.T) {
assert.False(t, b.IsNull(i))
}
}
assert.True(t, b.IsNull(1))
}
4 changes: 4 additions & 0 deletions arrow/array/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,15 @@ func TestMapBuilder_SetNull(t *testing.T) {

bldr.SetNull(0)
bldr.SetNull(3)
assert.Equal(t, 2, bldr.NullN())
bldr.SetNull(3)
assert.Equal(t, 2, bldr.NullN())

arr = bldr.NewMapArray()
defer arr.Release()

assert.True(t, arr.IsNull(0))
assert.True(t, arr.IsValid(1))
assert.True(t, arr.IsNull(3))
assert.Equal(t, 2, arr.NullN())
}