Skip to content

Commit

Permalink
Remove three now superfluous declarations, remove src/borrowed.c (#2376)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddelbuettel authored Apr 4, 2024
1 parent 7b7f81e commit 70fd58f
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 219 deletions.
145 changes: 0 additions & 145 deletions apis/r/src/borrowed.c

This file was deleted.

4 changes: 0 additions & 4 deletions apis/r/src/rinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ Rcpp::XPtr<ArrowArray> array_owning_xptr(void) {

namespace tdbs = tiledbsoma;

Rcpp::XPtr<ArrowSchema> schema_setup_struct(Rcpp::XPtr<ArrowSchema> schxp, int64_t n_children);
Rcpp::XPtr<ArrowArray> array_setup_struct(Rcpp::XPtr<ArrowArray> arrxp, int64_t n_children);


//' @noRd
// [[Rcpp::export(soma_array_reader_impl)]]
SEXP soma_array_reader(const std::string& uri,
Expand Down
2 changes: 0 additions & 2 deletions apis/r/src/riterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

#include "rutilities.h" // local declarations
#include "xptr-utils.h" // xptr taggging utilitie
Rcpp::XPtr<ArrowSchema> schema_setup_struct(Rcpp::XPtr<ArrowSchema> schxp, int64_t n_children);
Rcpp::XPtr<ArrowArray> array_setup_struct(Rcpp::XPtr<ArrowArray> arrxp, int64_t n_children);

namespace tdbs = tiledbsoma;

Expand Down
68 changes: 0 additions & 68 deletions apis/r/src/rutilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,74 +204,6 @@ Rcpp::XPtr<ArrowSchema> schema_setup_struct(Rcpp::XPtr<ArrowSchema> schxp, int64
return schxp;
}

extern "C" {
void ArrowArrayReleaseInternal(struct ArrowArray *array); // non-static in nanoarrow.c
ArrowErrorCode ArrowArraySetStorageType(struct ArrowArray* array, // ditto
enum ArrowType storage_type);
}

Rcpp::XPtr<ArrowArray> array_setup_struct(Rcpp::XPtr<ArrowArray> arrxp, int64_t n_children) {
ArrowArray* array = arrxp.get();
auto storage_type = NANOARROW_TYPE_STRUCT;

array->length = 0;
array->null_count = 0;
array->offset = 0;
array->n_buffers = 0;
array->n_children = 0;
array->buffers = NULL;
array->children = NULL;
array->dictionary = NULL;
array->release = &ArrowArrayReleaseInternal;
array->private_data = NULL;

auto private_data = (struct ArrowArrayPrivateData*) ArrowMalloc(sizeof(struct ArrowArrayPrivateData));
if (private_data == NULL) {
array->release = NULL;
Rcpp::stop("Error allocating array private data");
}
ArrowBitmapInit(&private_data->bitmap);
ArrowBufferInit(&private_data->buffers[0]);
ArrowBufferInit(&private_data->buffers[1]);
private_data->buffer_data[0] = NULL;
private_data->buffer_data[1] = NULL;
private_data->buffer_data[2] = NULL;
array->private_data = private_data;
array->buffers = (const void**)(&private_data->buffer_data);
int result = ArrowArraySetStorageType(array, storage_type);
if (result != NANOARROW_OK) {
array->release(array);
Rcpp::stop("Error setting array storage type");
}

ArrowLayoutInit(&private_data->layout, storage_type);
// We can only know this not to be true when initializing based on a schema so assume this to be true.
private_data->union_type_id_is_child_index = 1;


// remainder from ArrowArrayAllocateChildren()
if (array->children != NULL) Rcpp::stop("Error allocating array children as pointer not null");

if (n_children == 0) {
return arrxp;
}

auto ptr = (struct ArrowArray**) ArrowMalloc(n_children * sizeof(struct ArrowArray*));
Rcpp::XPtr<ArrowArray*> array_ptrxp = make_xptr(ptr, false);
array->children = array_ptrxp.get();
if (array->children == NULL) Rcpp::stop("Failed to allocated ArrayArray*");

memset(array->children, 0, n_children * sizeof(struct ArrowArray*));

for (int64_t i = 0; i < n_children; i++) {
array->children[i] = array_owning_xptr();
if (array->children[i] == NULL) Rcpp::stop("Error allocation array child %ld", i);
array->children[i]->release = NULL;
}
array->n_children = n_children;
return arrxp;
}


// formerly stats.cpp

Expand Down

0 comments on commit 70fd58f

Please sign in to comment.