WillAyd commented on code in PR #808: URL: https://github.com/apache/arrow-nanoarrow/pull/808#discussion_r2368765260
########## src/nanoarrow/common/inline_array.h: ########## @@ -43,8 +43,17 @@ static inline struct ArrowBuffer* ArrowArrayBuffer(struct ArrowArray* array, int switch (i) { case 0: return &private_data->bitmap.buffer; + case 1: + return private_data->buffers; default: - return private_data->buffers + i - 1; + if (array->n_buffers > 3 && i == (array->n_buffers - 1)) { Review Comment: What does this first condition do that isn't covered by the second? ########## src/nanoarrow/common/array.c: ########## @@ -463,47 +471,54 @@ static ArrowErrorCode ArrowArrayFinalizeBuffers(struct ArrowArray* array) { } for (int64_t i = 0; i < array->n_children; i++) { - NANOARROW_RETURN_NOT_OK(ArrowArrayFinalizeBuffers(array->children[i])); + if (ArrowArrayIsInternal(array->children[i])) { + NANOARROW_RETURN_NOT_OK(ArrowArrayFinalizeBuffers(array->children[i])); + } } - if (array->dictionary != NULL) { + if (array->dictionary != NULL && ArrowArrayIsInternal(array->dictionary)) { NANOARROW_RETURN_NOT_OK(ArrowArrayFinalizeBuffers(array->dictionary)); } return NANOARROW_OK; } -static void ArrowArrayFlushInternalPointers(struct ArrowArray* array) { +static ArrowErrorCode ArrowArrayFlushInternalPointers(struct ArrowArray* array) { struct ArrowArrayPrivateData* private_data = (struct ArrowArrayPrivateData*)array->private_data; - const bool is_binary_view = private_data->storage_type == NANOARROW_TYPE_STRING_VIEW || - private_data->storage_type == NANOARROW_TYPE_BINARY_VIEW; - const int32_t nfixed_buf = is_binary_view ? 2 : NANOARROW_MAX_FIXED_BUFFERS; + if (array->n_buffers > NANOARROW_MAX_FIXED_BUFFERS) { Review Comment: Is this condition safe from the case where you have a string/binary view but still only 3 buffers in total that are being managed? -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org