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


##########
src/nanoarrow/array_inline.h:
##########
@@ -445,6 +445,179 @@ static inline ArrowErrorCode 
ArrowArrayFinishElement(struct ArrowArray* array) {
   return NANOARROW_OK;
 }
 
+static inline int8_t ArrowArrayViewIsNull(struct ArrowArrayView* array_view, 
int64_t i) {
+  const uint8_t* validity_buffer = array_view->buffer_views[0].data.as_uint8;
+  i += array_view->array->offset;
+  switch (array_view->storage_type) {
+    case NANOARROW_TYPE_NA:
+      return 0x01;
+    case NANOARROW_TYPE_DENSE_UNION:
+    case NANOARROW_TYPE_SPARSE_UNION:
+      // Not supported yet
+      return 0xff;

Review Comment:
   I think I personally would have expected it to forward to whatever array was 
specified by the type ID (along with `ArrowArrayViewGetXXX()`). For somebody 
attempting to do a rowwise append of (e.g.) an integer column, I'd expect them 
to do something like:
   
   ```c
   if (ArrowArrayViewIsNull(array_view, i)) {
     // whatever the rowwise format's version of "set this column as null" is
   } else {
     int64_t value = ArrowArrayViewGetInt(array_view, i)
     // whatever the rowwise format's version of "set this column as int" is
   }
   ```
   
   If one treats every value of a union as non-null, users have to special case 
unions?



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