brancz commented on code in PR #37309:
URL: https://github.com/apache/arrow/pull/37309#discussion_r1302967306
##########
go/arrow/array/dictionary.go:
##########
@@ -1674,6 +1674,135 @@ func (u *unifier) GetResultWithIndexType(indexType
arrow.DataType) (arrow.Array,
return MakeFromData(dictData), nil
}
+type binaryUnifier struct {
+ mem memory.Allocator
+ memoTable *hashing.BinaryMemoTable
+}
+
+// NewBinaryDictionaryUnifier constructs and returns a new dictionary unifier
for dictionaries
+// of binary values, using the provided allocator for allocating the unified
dictionary
+// and the memotable used for building it.
+func NewBinaryDictionaryUnifier(alloc memory.Allocator) DictionaryUnifier {
+ return &binaryUnifier{
+ mem: alloc,
+ memoTable: hashing.NewBinaryMemoTable(0, 0,
NewBinaryBuilder(alloc, arrow.BinaryTypes.Binary)),
+ }
+}
+
+func (u *binaryUnifier) Release() {
+ u.memoTable.Release()
+}
+
+func (u *binaryUnifier) Unify(dict arrow.Array) (err error) {
+ if !arrow.TypeEqual(arrow.BinaryTypes.Binary, dict.DataType()) {
+ return fmt.Errorf("dictionary type different from unifier: %s,
expected: %s", dict.DataType(), arrow.BinaryTypes.Binary)
+ }
Review Comment:
I was just following the `DictionaryUnifier` interface. If we want to do
that, we should export the `binaryUnifier` struct. Happy to go with either.
Also happy to add additional functions that are type safe in addition.
--
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]