eddelbuettel commented on issue #67:
URL: https://github.com/apache/arrow-nanoarrow/issues/67#issuecomment-1337421412
Hi @paleolimbot -- the list in #71 looks great, and the recent PR also
containing streams are very useful too. Sadly there is still too much
different in `nanoarrow` relative to your various predecessor projects (with
still work) for me to make a switch. I took the above and extended it
minimally. I get what looks like a reasonable Arrow object but trying to
materialize it into a `tibble` blows up (whereas this works just fine as it
should with the predecessors):
```sh
> rl <- rcppnanoarrow::createArray()
> unclass(rl)
$schema
<pointer: 0x55e569b9d0f0>
attr(,"class")
[1] "arch_schema"
$array_data
<pointer: 0x55e5690ec1a0>
attr(,"class")
[1] "arch_array_data"
> arrow::as_arrow_table(arch::from_arch_array(rl, arrow::RecordBatch))
Table
3 rows x 2 columns
$intCol <int32>
$dblCol <double>
> tibble::as_tibble(arrow::as_arrow_table(arch::from_arch_array(rl,
arrow::RecordBatch)))
*** caught segfault ***
address (nil), cause 'memory not mapped'
Traceback:
1: vec_slice(x, seq_len(n))
2: vec_head(as.data.frame(x), n)
3: df_head(x, n)
4: tbl_format_setup.tbl(x, width, ..., n = n, max_extra_cols =
max_extra_cols, max_footer_lines = max_footer_lines, focus = focus)
5: tbl_format_setup_dispatch(x, width, ..., n = n, max_extra_cols =
max_extra_cols, max_footer_lines = max_footer_lines, focus = focus)
6: tbl_format_setup(x, width = width, ..., n = n, max_extra_cols =
max_extra_cols, max_footer_lines = max_footer_lines, focus = attr(x,
"pillar_focus"))
7: format_tbl(x, width, ..., n = n, max_extra_cols = max_extra_cols,
max_footer_lines = max_footer_lines)
8: format.tbl(x, width = width, ..., n = n, max_extra_cols =
max_extra_cols, max_footer_lines = max_footer_lines)
9: format(x, width = width, ..., n = n, max_extra_cols = max_extra_cols,
max_footer_lines = max_footer_lines)
10: writeLines(format(x, width = width, ..., n = n, max_extra_cols =
max_extra_cols, max_footer_lines = max_footer_lines))
11: print_tbl(x, width, ..., n = n, max_extra_cols = max_extra_cols,
max_footer_lines = max_footer_lines)
12: print.tbl(x)
13: (function (x, ...) UseMethod("print"))(x)
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:
```
The simple helper function to create the object is below, it is a simple
extension of the example stub you posted. Can you spot what I am missing here?
(And I tried to different s3 classes for dispatch.)
<details>
Simple Rcpp-wrapped object creator below. It uses a list for convenience to
transport the two external pointers to schema and array data, following prior
practice in narrow/sparrow/carrow/...
```c++
//' @export
// [[Rcpp::export]]
Rcpp::List createArray() {
const int ncol = 2;
const int nrow = 3;
auto schemaxp = Rcpp::XPtr<struct ArrowSchema>(new struct ArrowSchema);
schemaxp.attr("class") = "arch_schema";
auto schema = schemaxp.get();
ArrowSchemaInit(schema, NANOARROW_TYPE_STRUCT);
ArrowSchemaAllocateChildren(schema, ncol);
auto arrayxp = Rcpp::XPtr<struct ArrowArray>(new struct ArrowArray);
arrayxp.attr("class") = "arch_array_data";
auto array = arrayxp.get();
ArrowArrayInit(array, NANOARROW_TYPE_STRUCT);
ArrowArrayAllocateChildren(array, ncol);
array->length = nrow;
array->null_count = -1;
// ...fill in schema.children and array.children
ArrowSchemaInit(schema->children[0], NANOARROW_TYPE_INT32);
ArrowSchemaSetName(schema->children[0], "intCol");
ArrowArrayInit(array->children[0], NANOARROW_TYPE_INT32);
ArrowArrayAppendInt(array->children[0], 21);
ArrowArrayAppendInt(array->children[0], 42);
ArrowArrayAppendInt(array->children[0], 63);
ArrowSchemaInit(schema->children[1], NANOARROW_TYPE_DOUBLE);
ArrowSchemaSetName(schema->children[1], "dblCol");
ArrowArrayInit(array->children[1], NANOARROW_TYPE_DOUBLE);
ArrowArrayAppendDouble(array->children[1], 21.1);
ArrowArrayAppendDouble(array->children[1], 42.2);
ArrowArrayAppendDouble(array->children[1], 63.3);
Rcpp::List as = Rcpp::List::create(Rcpp::Named("schema") = schemaxp,
Rcpp::Named("array_data") = arrayxp);
//as.attr("class") = "nanoarrow_array";
as.attr("class") = "arch_array";
return as;
}
```
</details>
--
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]