paleolimbot commented on code in PR #683:
URL: https://github.com/apache/arrow-nanoarrow/pull/683#discussion_r1848730957


##########
src/nanoarrow/common/inline_types.h:
##########
@@ -916,13 +922,14 @@ static inline void ArrowDecimalInit(struct ArrowDecimal* 
decimal, int32_t bitwid
   memset(decimal->words, 0, sizeof(decimal->words));
   decimal->precision = precision;
   decimal->scale = scale;
+  // n_words will be 0 for bitwidth == 32

Review Comment:
   Is there any way to avoid the `n_words == 0` situation? (Or could it be 
explained in a comment somewhere how it works?).
   
   Alternatively, could we special-case the bit in 
`ArrowArrayViewGetDecimalUnsafe()` to populate the `ArrowDecimal` as if it were 
a 64-bit decimal by copying the appropriate bytes? Or update the words to be 
smaller (seems hard)?



##########
src/nanoarrow/common/array_test.cc:
##########
@@ -3821,6 +3901,80 @@ TEST(ArrayViewTest, 
ArrayViewTestGetIntervalMonthDayNano) {
   ArrowArrayRelease(&array);
 }
 
+TEST(ArrayViewTest, ArrayViewTestGetDecimal32) {

Review Comment:
   Is there any way we can avoid some of the copy/paste here by something like:
   
   ```c
   void TestArrayViewGetDecimal(ArrowType type, int precision, int scale) { ... 
}
   void TestArrayViewDecimalArrowRoundtrip(ArrowType type, int precision, int 
scale, BuilderT builder) { ... }
   
   TEST(ArrayViewTest, ArrayViewTestGetDecimal32) {
     TestArrayViewGetDecimal(...);
   #if defined(BUILD_TESTS_WITH_ARROW)
     TestArrayViewDecimalArrowRoundtrip();
   #endif
   }
   ```



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