Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apacheGH-40517: [C#] Fix writing sliced arrays to IPC format (apache#…
…41197) ### Rationale for this change Fixes writing sliced arrays to IPC files or streams, so that they can be successfully read back in. Previously, writing such data would succeed but then couldn't be read. ### What changes are included in this PR? * Fixes `BinaryViewArray.GetBytes` to account for the array offset * Fixes `FixedSizeBinaryArray.GetBytes` to account for the array offset * Updates `ArrowStreamWriter` so that it writes slices of buffers when required, and handles slicing bitmap arrays by creating a copy if the offset isn't a multiple of 8 * Refactors `ArrowStreamWriter`, making the `ArrowRecordBatchFlatBufferBuilder` class responsible for building a list of field nodes as well as buffers. This was required to avoid having to duplicate logic for handling array types with child data between the `ArrowRecordBatchFlatBufferBuilder` class and the `CreateSelfAndChildrenFieldNodes` method, which I've removed. Note that after this change, we still write more data than required when writing a slice of a `ListArray`, `BinaryArray`, `ListViewArray`, `BinaryViewArray` or `DenseUnionArray`. When writing a `ListArray` for example, we write slices of the null bitmap and value offsets and write the full values array. Ideally we should write a slice of the values and adjust the value offsets so they start at zero. The C++ implementation for example handles this [here](https://github.com/apache/arrow/blob/18c74b0733c9ff473a211259cf10705b2c9be891/cpp/src/arrow/ipc/writer.cc#L316). I will make a follow-up issue for this once this PR is merged. ### Are these changes tested? Yes, I've added new unit tests for this. ### Are there any user-facing changes? Yes, this is a user-facing bug fix. * GitHub Issue: apache#40517 Authored-by: Adam Reeve <adreeve@gmail.com> Signed-off-by: Curt Hagenlocher <curt@hagenlocher.org>
- Loading branch information