paleolimbot commented on code in PR #710:
URL: https://github.com/apache/arrow-nanoarrow/pull/710#discussion_r1966541426
##########
src/nanoarrow/common/inline_array.h:
##########
@@ -310,7 +313,23 @@ static inline ArrowErrorCode
_ArrowArrayAppendEmptyInternal(struct ArrowArray* a
NANOARROW_RETURN_NOT_OK(_ArrowArrayAppendBits(array, i, 0, n));
}
continue;
+ case NANOARROW_BUFFER_TYPE_VIEW_OFFSET: {
+ NANOARROW_RETURN_NOT_OK(ArrowBufferReserve(buffer, size_bytes * n));
+
+ if (array->length == 0) {
+ const int64_t zero_val = 0;
+ for (int64_t j = 0; j < n; j++) {
+ ArrowBufferAppendUnsafe(buffer, &zero_val, size_bytes);
+ }
Review Comment:
`ArrowBufferFill()` like above?
##########
src/nanoarrow/common/inline_array.h:
##########
@@ -772,6 +792,31 @@ static inline ArrowErrorCode
ArrowArrayFinishElement(struct ArrowArray* array) {
return EINVAL;
}
break;
+ case NANOARROW_TYPE_LIST_VIEW: {
+ child_length = array->children[0]->length;
+ if (child_length > INT32_MAX) {
+ return EOVERFLOW;
+ }
+
+ const int32_t last_valid_offset =
(int32_t)private_data->list_view_offset;
+ NANOARROW_RETURN_NOT_OK(
+ ArrowBufferAppendInt32(ArrowArrayBuffer(array, 1),
last_valid_offset));
+ NANOARROW_RETURN_NOT_OK(ArrowBufferAppendInt32(
+ ArrowArrayBuffer(array, 2), (int32_t)child_length -
last_valid_offset));
+ private_data->list_view_offset = (int32_t)child_length;
Review Comment:
```suggestion
private_data->list_view_offset = child_length;
```
##########
src/nanoarrow/common/inline_array.h:
##########
@@ -310,7 +313,23 @@ static inline ArrowErrorCode
_ArrowArrayAppendEmptyInternal(struct ArrowArray* a
NANOARROW_RETURN_NOT_OK(_ArrowArrayAppendBits(array, i, 0, n));
}
continue;
+ case NANOARROW_BUFFER_TYPE_VIEW_OFFSET: {
+ NANOARROW_RETURN_NOT_OK(ArrowBufferReserve(buffer, size_bytes * n));
+
+ if (array->length == 0) {
+ const int64_t zero_val = 0;
+ for (int64_t j = 0; j < n; j++) {
+ ArrowBufferAppendUnsafe(buffer, &zero_val, size_bytes);
+ }
+ } else {
+ for (int64_t j = 0; j < n; j++) {
+ ArrowBufferAppendUnsafe(
+ buffer, buffer->data + size_bytes * (array->length + j - 1),
size_bytes);
+ }
Review Comment:
Can this just be zero? (If I remember correctly, the view offsets don't have
to be in order, and this is an empty element?).
##########
src/nanoarrow/common/array.c:
##########
@@ -1157,9 +1175,31 @@ static int ArrowArrayViewValidateDefault(struct
ArrowArrayView* array_view,
return EINVAL;
}
}
+
+ if ((array_view->storage_type == NANOARROW_TYPE_LIST_VIEW) &&
Review Comment:
I think you can skip any check in default validation...the full validation
check is the one that I would personally expect to run for the "check all
elements" case and the first/last item size check that's here isn't something
we do for lists or strings (unless I'm missing something or the full check
somehow depends on this!)
--
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]