| 12345678910111213141516171819202122232425262728293031323334353637 |
- package main
- import (
- "fmt"
- "github.com/apache/arrow/go/arrow/array"
- "github.com/apache/arrow/go/arrow/memory"
- )
- func main() {
- // create LSB packed bits with the following pattern:
- // 01010011 11000101
- data := memory.NewBufferBytes([]byte{0xca, 0xa3})
- // create LSB packed validity (null) bitmap, where every 4th element is null:
- // 11101110 11101110
- nullBitmap := memory.NewBufferBytes([]byte{0x77, 0x77})
- // Create a boolean array and lazily determine NullN using UnknownNullCount
- bools := array.NewBoolean(16, data, nullBitmap, array.UnknownNullCount)
- defer bools.Release()
- // Show the null count
- fmt.Printf("NullN() = %d\n", bools.NullN())
- // Enumerate the values.
- n := bools.Len()
- for i := 0; i < n; i++ {
- fmt.Printf("bools[%d] = ", i)
- if bools.IsNull(i) {
- fmt.Println("(null)")
- } else {
- fmt.Printf("%t\n", bools.Value(i))
- }
- }
- }
|