paleolimbot commented on code in PR #507:
URL: https://github.com/apache/arrow-nanoarrow/pull/507#discussion_r1628281083
##########
src/nanoarrow/nanoarrow.h:
##########
@@ -372,6 +374,15 @@ ArrowErrorCode ArrowSchemaSetTypeDecimal(struct
ArrowSchema* schema, enum ArrowT
int32_t decimal_precision,
int32_t decimal_scale);
+/// \brief Set the format field of a run-end encoded schema
+///
+/// Returns EINVAL for scale <= 0 or for run_end_type that is not
Review Comment:
```suggestion
/// Returns EINVAL for run_end_type that is not
```
##########
src/nanoarrow/nanoarrow.h:
##########
@@ -372,6 +374,15 @@ ArrowErrorCode ArrowSchemaSetTypeDecimal(struct
ArrowSchema* schema, enum ArrowT
int32_t decimal_precision,
int32_t decimal_scale);
+/// \brief Set the format field of a run-end encoded schema
+///
+/// Returns EINVAL for scale <= 0 or for run_end_type that is not
+/// NANOARROW_TYPE_INT16, NANOARROW_TYPE_INT32 or NANOARROW_TYPE_INT64.
+/// Schema must have been initialized using ArrowSchemaInit() or
ArrowSchemaDeepCopy().
+/// The run-end encoded array's logical length must be updated manually.
Review Comment:
```suggestion
/// The caller must call `ArrowSchemaSetTypeXXX(schema->children[1])` to
/// set the value type. Note that when building arrays using the
`ArrowArrayAppendXXX()`
/// functions, the run-end encoded array's logical length must be updated
manually.
```
##########
src/nanoarrow/array.c:
##########
@@ -1163,6 +1236,36 @@ static int ArrowArrayViewValidateFull(struct
ArrowArrayView* array_view,
}
}
+ if (array_view->storage_type == NANOARROW_TYPE_RUN_END_ENCODED) {
+ struct ArrowArrayView* run_ends_view = array_view->children[0];
+ int64_t last_run_end = ArrowArrayViewGetIntUnsafe(run_ends_view, 0);
+ if (last_run_end < 1) {
+ ArrowErrorSet(error,
+ "All run ends must be greater than 0 but the first run end
is %ld",
+ (long)last_run_end);
+ return EINVAL;
+ }
Review Comment:
This check might be good to keep in `ArrowArrayViewValidateDefault()`
(because it's a check that only happens once per array regardless of the array
length).
--
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]