emkornfield commented on a change in pull request #11514:
URL: https://github.com/apache/arrow/pull/11514#discussion_r744020732
##########
File path: go/arrow/array/util.go
##########
@@ -16,6 +16,38 @@
package array
+import (
+ "github.com/apache/arrow/go/arrow"
+ "github.com/apache/arrow/go/arrow/memory"
+)
+
+// RecordToStructArray constructs a struct array from the columns of the
record batch
+// by referencing them, zero-copy.
+func RecordToStructArray(rec Record) *Struct {
+ cols := make([]*Data, rec.NumCols())
+ for i, c := range rec.Columns() {
+ cols[i] = c.Data()
+ }
+
+ data := NewData(arrow.StructOf(rec.Schema().Fields()...),
int(rec.NumRows()), []*memory.Buffer{nil}, cols, 0, 0)
+ defer data.Release()
+
+ return NewStructData(data)
+}
+
+// RecordFromStructArray is a convenience function for converting a struct
array into
+// a record batch without copying the data. If the passed in schema is nil,
the fields
+// of the struct will be used to define the record batch. Otherwise the passed
in
+// schema will be used to create the record batch. If passed in, the schema
must match
+// the fields of the struct column.
+func RecordFromStructArray(in *Struct, schema *arrow.Schema) Record {
Review comment:
Please document what happens to the top level null-bitmap? Does it get
distributed to child arrays or dropped (from the implementation it looks like
it is dropped?)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]