[
https://issues.apache.org/jira/browse/ARROW-5035?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17662057#comment-17662057
]
Rok Mihevc commented on ARROW-5035:
-----------------------------------
This issue has been migrated to [issue
#21530|https://github.com/apache/arrow/issues/21530] on GitHub. Please see the
[migration documentation|https://github.com/apache/arrow/issues/14542] for
further details.
> [C#] ArrowBuffer.Builder<bool> is broken
> ----------------------------------------
>
> Key: ARROW-5035
> URL: https://issues.apache.org/jira/browse/ARROW-5035
> Project: Apache Arrow
> Issue Type: Improvement
> Components: C#
> Reporter: Eric Erhardt
> Priority: Major
> Fix For: 1.0.0
>
>
> If someone creates and uses `ArrowBuffer.Builder<bool>` in their code to
> create an ArrowBuffer filled with Boolean values, it is currently producing
> the wrong results.
> The reason it is producing the wrong results is because it is taking the
> `sizeof(bool)` (which is 1) and using that for how many bytes to write into
> the backing buffer for each element being added to the builder. However, in
> Arrow, Boolean values are stored in a bit-wise fashion allowing for 8 Boolean
> values in a single byte. Thus, when I add 4 `true` values to the buffer, I
> expect to get a buffer with 1 byte in it with the value 0x0F. However, I am
> getting a buffer with 4 bytes in it, each with value 0x01.
> One way to fix this would be to throw in `ArrowBuffer.Builder<T>`'s
> constructor if `T` == `bool` and instead create a new class
> `ArrowBuffer.BooleanBuilder`, which will create Boolean buffers correctly.
> Looking at the current implementation, I think it would be rather hard to
> special case `typeof(bool)` all over in the `Builder` class, but if someone
> wanted to take that approach and made it work, that would be great too.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)