Skip to content

Commit 8596a0a

Browse files
committed
final edits
1 parent 8805697 commit 8596a0a

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

r/R/vctr.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#' storage type is an `integer()` that is a sequence along the total length
3030
#' of the vctr and there are attributes that are required to resolve these
3131
#' indices to an array + offset. Sequences typically have a very compact
32-
#' representation in recent version of R such that this has a cheap storage
32+
#' representation in recent versions of R such that this has a cheap storage
3333
#' footprint even for large arrays. The attributes are currently:
3434
#'
3535
#' - `schema`: The [nanoarrow_schema][as_nanoarrow_schema] shared by each chunk.

r/man/as_nanoarrow_vctr.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

r/src/vctr.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <Rinternals.h>
2121

2222
#include "nanoarrow.h"
23+
#include "nanoarrow/r.h"
2324

2425
SEXP nanoarrow_c_vctr_chunk_offsets(SEXP array_list) {
2526
int num_chunks = Rf_length(array_list);
@@ -30,7 +31,7 @@ SEXP nanoarrow_c_vctr_chunk_offsets(SEXP array_list) {
3031

3132
struct ArrowArray* array;
3233
for (int i = 0; i < num_chunks; i++) {
33-
array = (struct ArrowArray*)R_ExternalPtrAddr(VECTOR_ELT(array_list, i));
34+
array = nanoarrow_array_from_xptr(VECTOR_ELT(array_list, i));
3435
cumulative_offset += array->length;
3536
if (cumulative_offset > INT_MAX) {
3637
Rf_error("Can't build nanoarrow_vctr with length > INT_MAX"); // # nocov
@@ -90,6 +91,10 @@ SEXP nanoarrow_c_vctr_as_slice(SEXP indices_sexp) {
9091
return slice_sexp;
9192
}
9293

94+
// It may be possible to check for the R ALTREP sequence type,
95+
// which would eliminate the need for the below check for
96+
// sequential values.
97+
9398
int buf[1024];
9499
INTEGER_GET_REGION(indices_sexp, 0, 1024, buf);
95100
slice[0] = buf[0];

r/tests/testthat/test-convert-array.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ test_that("convert to vector works for nanoarrow_vctr()", {
177177
schema <- infer_nanoarrow_schema(vctr)
178178
expect_identical(schema$format, "u")
179179

180-
# Check nested conversion from a data.frame
180+
# Check conversion of a struct array
181181
df <- data.frame(x = c("one", "two", "three"))
182182
array <- as_nanoarrow_array(df)
183183

@@ -187,7 +187,6 @@ test_that("convert to vector works for nanoarrow_vctr()", {
187187
schema <- infer_nanoarrow_schema(vctr)
188188
expect_identical(schema$format, "+s")
189189

190-
191190
vctr <- convert_array(array, nanoarrow_vctr(na_struct(list(x = na_string()))))
192191
expect_s3_class(vctr, "nanoarrow_vctr")
193192
expect_length(vctr, 3)

0 commit comments

Comments
 (0)