twest822 commented on issue #410:
URL: https://github.com/apache/arrow-dotnet/issues/410#issuecomment-5318920758
Yep. Which makes code of the form
```C#
float[] data = ...; // caller gets a populated array from somewhere
ArrowBuffer buffer = new(data.ReinterpretCast<byte>());
FloatArray array = new(buffer, ArrowBuffer.Empty, buffer.Length, 0, 0); //
same pattern for .ctor(double), sbyte, Int16, Int32, Int64, byte, UInt16,
UInt32, UInt64, ...
```
natural even though what Arrow wants is `buffer.Length / sizeof(float)`
because `ArrowBuffer.Length` is in bytes. A variation on this `sizeof(T)`
omission was, indeed, what prompted filing this issue.
Besides documentation and checking `PrimitiveArray<T>..ctor(length)` doesn't
overrun the end of the provided `ArrowBuffer`, another mitigation is offering
wrapping constructors (or builders) in the direction of
```C#
public FloatArray(float[] data) { ... }
```
which shifts the API towards abstracting away Arrow's reinterpretations
around `ReadOnlyMemory<byte>`. That feels reasonable to me from what I know.
But also feels like probably a separate change candidate rather than part of
the fix here.
--
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]