apache / arrow-nanoarrow

Helpers for Arrow C Data & Arrow C Stream interfaces
https://arrow.apache.org/nanoarrow
Apache License 2.0
169 stars 35 forks source link

test: test with the `HalfFloatType` from arrow #503

Closed cocoa-xu closed 3 months ago

cocoa-xu commented 4 months ago

Hi this PR adds an extra test case that tests ArrowFloatToHalfFloat and ArrowArrayViewGet{Double,Int,UInt}Unsafe with the HalfFloatType from arrow.

https://github.com/apache/arrow/blob/255dbf990c3d3e5fb1270a2a11efe0af2be195ab/cpp/src/arrow/type.h#L704-L713

And sorry that I didn't know there's a HalfFloatType in arrow-cpp when I was doing #501 🥲.

~Sadly that we cannot simply append TestGetFromNumericArrayView<HalfFloatType>(); at the end of the ArrayViewTestGetNumeric test suite because we have to convert floats to half-floats using ArrowFloatToHalfFloat before calling builder.Append (otherwise we'll get weird values back in the subsequent ArrowArrayViewGet{Double,Int,UInt}Unsafe calls).~

Added some simple C++ magic and we can simply append TestGetFromNumericArrayView<HalfFloatType>(); at the end of the ArrayViewTestGetNumeric test suite now.

cocoa-xu commented 4 months ago

and reduce that where possible

Not a problem, I added a helper function and it should look better now. :)

There is also a few places this could be enabled in the integration tests if you have the bandwidth (no pressure!)

It's done now ;)