thorfour opened a new pull request, #36759:
URL: https://github.com/apache/arrow/pull/36759

   
   <!--
   Thanks for opening a pull request!
   If this is your first pull request you can find detailed information on how 
   to contribute here:
     * [New Contributor's 
Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
     * [Contributing 
Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
   
   
   If this is not a [minor 
PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). 
Could you open an issue for this pull request on GitHub? 
https://github.com/apache/arrow/issues/new/choose
   
   Opening GitHub issues ahead of time contributes to the 
[Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.)
 of the Apache Arrow project.
   
   Then could you also rename the pull request title in the following format?
   
       GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   or
   
       MINOR: [${COMPONENT}] ${SUMMARY}
   
   In the case of PARQUET issues on JIRA the title also supports:
   
       PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   -->
   
   ### Rationale for this change
   
   The hashing.MemoTable provides an interface with 
   ```go
       GetOrInsert(val interface{}) (idx int, existed bool, err error)
   ```
   This can cause a costly allocation for binary dictionaries as is detailed in 
issue #36671 
   
   Instead we can change the `BinaryDictionaryBuilder` to use a different type 
of builder that uses a memotable that allows the static `[]byte` type as part 
of the `GetOrInsert` function to prevent that allocation when converting from 
`[]byte` to `interface{}`.
   
   Originally I attempted to replace the memotable with a generic `MemoTable[T 
any]` but because there are two different implementations of memo tables one 
being for binary memo tables, I tried splitting the generic implementations in 
two. That code can bee seen on [this 
branch](https://github.com/thorfour/arrow/tree/go-generic-memotable). This runs 
into the problem that the util function attempts to convert the memo table back 
into its implementation: 
https://github.com/apache/arrow/blob/de8df23a8cd9737b4df5bb1b68fc12a54f252d0d/go/arrow/array/util.go#L268
 which Go doesn't allow due to the generic binary memo table being more 
restrictive than the basic one. So to move forward with replacing the memotable 
with generics I believe we would need a single implementation of the memo table 
but would also require things like the builders to be generic as well. 
   
   ### What changes are included in this PR?
   
   Adds a `binaryDictionaryBuilder` that is a identical copy to the 
`dictionaryBuilder` except is uses `[]byte` instead of `interface{}`
   
   For binary dictionary types it now uses the the `binaryDictionaryBuilder` 
type to avoid the conversion of `[]byte` to `interface{}` 
   
   ### Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are 
they covered by existing tests)?
   -->
   
   No additional tests have been added for this yet, current test coverage 
exercises the new builders. But wanted to ensure this was a valid path forward 
before investing more time in test coverage if deemed necessary.
   
   ### Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please uncomment the line 
below and explain which changes are breaking.
   -->
   <!-- **This PR includes breaking changes to public APIs.** -->
   
   <!--
   Please uncomment the line below (and provide explanation) if the changes fix 
either (a) a security vulnerability, (b) a bug that caused incorrect or invalid 
data to be produced, or (c) a bug that causes a crash (even when the API 
contract is upheld). We use this to highlight fixes to issues that may affect 
users without their knowledge. For this reason, fixing bugs that cause errors 
don't count, since those are usually obvious.
   -->
   <!-- **This PR contains a "Critical Fix".** -->


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