slice.go 515 B

12345678910111213141516171819202122232425262728293031
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/apache/arrow/go/arrow/array"
  5. "github.com/apache/arrow/go/arrow/memory"
  6. )
  7. func main() {
  8. pool := memory.NewGoAllocator()
  9. b := array.NewFloat64Builder(pool)
  10. defer b.Release()
  11. b.AppendValues(
  12. []float64{1, 2, 3, -1, 4, 5},
  13. []bool{true, true, true, false, true, true},
  14. )
  15. arr := b.NewFloat64Array()
  16. defer arr.Release()
  17. fmt.Printf("array = %v\n", arr)
  18. sli := array.NewSlice(arr, 2, 5).(*array.Float64)
  19. defer sli.Release()
  20. fmt.Printf("slice = %v\n", sli)
  21. }