zeroshade commented on code in PR #34454:
URL: https://github.com/apache/arrow/pull/34454#discussion_r1128369139
##########
go/arrow/internal/testing/types/extension_types.go:
##########
@@ -18,26 +18,181 @@
package types
import (
+ "bytes"
"encoding/binary"
"fmt"
"reflect"
+ "strings"
+
+ "github.com/goccy/go-json"
"github.com/apache/arrow/go/v12/arrow"
"github.com/apache/arrow/go/v12/arrow/array"
+ "github.com/apache/arrow/go/v12/arrow/memory"
+ "github.com/google/uuid"
"golang.org/x/xerrors"
)
+type UUIDBuilder struct {
+ *array.ExtensionBuilder
+ dtype *UUIDType
+}
+
+func NewUUIDBuilder(mem memory.Allocator, dtype arrow.ExtensionType)
*UUIDBuilder {
+ b := &UUIDBuilder{
+ ExtensionBuilder: array.NewExtensionBuilder(mem, dtype),
+ dtype: dtype.(*UUIDType),
+ }
+ return b
+}
+
+func (b *UUIDBuilder) Append(v uuid.UUID) {
+ b.ExtensionBuilder.Builder.(*array.FixedSizeBinaryBuilder).Append(v[:])
+}
+
+func (b *UUIDBuilder) UnsafeAppend(v uuid.UUID) {
+
b.ExtensionBuilder.Builder.(*array.FixedSizeBinaryBuilder).UnsafeAppend(v[:])
+}
+
+func (b *UUIDBuilder) AppendValues(v []uuid.UUID, valid []bool) {
+ data := make([][]byte, len(v))
+ for i, v := range v {
+ data[i] = v[:]
+ }
+
b.ExtensionBuilder.Builder.(*array.FixedSizeBinaryBuilder).AppendValues(data,
valid)
+}
+
+func (b *UUIDBuilder) UnmarshalOne(dec *json.Decoder) error {
+ t, err := dec.Token()
Review Comment:
Ah, I realized we don't need to manually create default implementations of
`UnmarshalOne` etc. because we embed the underlying Storage Builder anyways, so
you're right. It will call the underlying one automatically if you don't
implement it. All good here then!
--
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]