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


##########
src/nanoarrow/array_inline.h:
##########
@@ -661,6 +661,44 @@ static inline ArrowErrorCode 
ArrowArrayFinishElement(struct ArrowArray* array) {
         }
       }
       break;
+
+    case NANOARROW_TYPE_RUN_END_ENCODED:
+      if (array->children[0]->length != array->children[1]->length) {
+        return EINVAL;
+      }
+      if (array->children[0]->null_count != 0) {
+        return EINVAL;
+      }
+      array->length = 0;
+      struct ArrowBuffer* data_buffer;
+      data_buffer = ArrowArrayBuffer(array->children[0], 1);
+      for (int64_t i = 0; i < array->children[0]->length; i++) {

Review Comment:
   Perhaps, but it is also very similar to the piece of code we have that 
updates the `null_count` based on the validity buffer, which I think happens in 
`ArrowArrayFinishBuilding()` (although that "feature" has caused me some 
personal confusion because I sometimes forget that it happens and wonder why 
the `null_count` isn't what I set it to be).
   
   The most backward compatible thing to do would be to not do *any* updating 
of lengths (i.e., force the caller to set the length of the parent 
run-end-encoded array). This would not necessarily be difficult to do because 
they would have to be keeping track of that length to append to the run-ends 
child (so they would have to keep a counter somewhere anyway). Perhaps for this 
PR the helper could be omitted and we can learn from the experience of 
implementing this elsewhere what the best intervention would be?



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