Skip to content

Commit a749d8d

Browse files
committed
prototype method
1 parent 6abc01e commit a749d8d

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

Diff for: r/src/vctr_builder_other.h

+16-5
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,35 @@ class OtherBuilder : public VctrBuilder {
4949

5050
ArrowErrorCode PushNext(SEXP array_shelter, const ArrowArray* array,
5151
ArrowError* error) override {
52-
// Fill this in
52+
SEXP schema_borrowed_xptr = PROTECT(
53+
R_MakeExternalPtr(const_cast<ArrowSchema*>(schema_), R_NilValue, R_NilValue));
54+
Rf_setAttrib(schema_borrowed_xptr, R_ClassSymbol, nanoarrow_cls_schema);
55+
56+
SEXP array_borrowed_xptr = PROTECT(R_MakeExternalPtr(
57+
const_cast<ArrowArray*>(array), schema_borrowed_xptr, array_shelter));
58+
Rf_setAttrib(array_borrowed_xptr, R_ClassSymbol, nanoarrow_cls_array);
59+
60+
SEXP fun = PROTECT(Rf_install("convert_fallback_other"));
61+
SEXP call =
62+
PROTECT(Rf_lang5(fun, array_borrowed_xptr, R_NilValue, R_NilValue, ptype_sexp_));
63+
SEXP chunk_sexp = PROTECT(Rf_eval(call, nanoarrow_ns_pkg));
64+
Append(chunk_sexp);
65+
UNPROTECT(5);
66+
5367
return NANOARROW_OK;
5468
}
5569

5670
ArrowErrorCode Finish(ArrowError* error) override {
5771
if (chunks_tail_ == chunks_sexp_) {
58-
Rprintf("zero chunks\n");
5972
// Zero chunks (return the ptype)
6073
// Probably need to ensure the ptype has zero elements
61-
SetValue(GetPtype());
74+
SetValue(ptype_sexp_);
6275

6376
} else if (chunks_tail_ == CDR(chunks_sexp_)) {
64-
Rprintf("one chunk\n");
6577
// One chunk (return the chunk)
6678
SetValue(CAR(chunks_tail_));
6779

6880
} else {
69-
Rprintf("many chunks\n");
7081
// Many chunks (concatenate or rbind)
7182
SEXP fun;
7283
if (Rf_inherits(ptype_sexp_, "data.frame")) {

0 commit comments

Comments
 (0)