zeroshade commented on code in PR #37309:
URL: https://github.com/apache/arrow/pull/37309#discussion_r1301831569


##########
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)
+       }
+
+       typedDict := dict.(*Binary)
+       for i := 0; i < dict.Len(); i++ {
+               if dict.IsNull(i) {
+                       u.memoTable.GetOrInsertNull()
+                       continue
+               }
+
+               if _, _, err = 
u.memoTable.GetOrInsertBytes(typedDict.Value(i)); err != nil {
+                       return err
+               }
+       }
+       return
+}
+
+func (u *binaryUnifier) UnifyAndTranspose(dict arrow.Array) (transposed 
*memory.Buffer, err error) {
+       if !arrow.TypeEqual(arrow.BinaryTypes.Binary, dict.DataType()) {
+               return nil, fmt.Errorf("dictionary type different from unifier: 
%s, expected: %s", dict.DataType(), arrow.BinaryTypes.Binary)
+       }

Review Comment:
   same comment as above



-- 
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]

Reply via email to