zeroshade commented on code in PR #37309:
URL: https://github.com/apache/arrow/pull/37309#discussion_r1301830815
##########
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:
Since we're going to require a binary dictionary, any reason to not just
take in a `*array.Binary` and push the type check onto the consumer?
--
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]