return an altrep R vector that shadows the array if possible
| 1042 | |
| 1043 | // return an altrep R vector that shadows the array if possible |
| 1044 | SEXP MakeAltrepVector(const std::shared_ptr<ChunkedArray>& chunked_array) { |
| 1045 | // using altrep if |
| 1046 | // - the arrow.use_altrep is set to TRUE or unset (implicit TRUE) |
| 1047 | // - the chunked array has at least one element |
| 1048 | if (arrow::r::GetBoolOption("arrow.use_altrep", true) && chunked_array->length() > 0) { |
| 1049 | switch (chunked_array->type()->id()) { |
| 1050 | case arrow::Type::DOUBLE: |
| 1051 | return altrep::AltrepVectorPrimitive<REALSXP>::Make(chunked_array); |
| 1052 | |
| 1053 | case arrow::Type::INT32: |
| 1054 | return altrep::AltrepVectorPrimitive<INTSXP>::Make(chunked_array); |
| 1055 | |
| 1056 | case arrow::Type::STRING: |
| 1057 | return altrep::AltrepVectorString<StringType>::Make(chunked_array); |
| 1058 | |
| 1059 | case arrow::Type::LARGE_STRING: |
| 1060 | return altrep::AltrepVectorString<LargeStringType>::Make(chunked_array); |
| 1061 | |
| 1062 | case arrow::Type::DICTIONARY: |
| 1063 | return altrep::AltrepFactor::Make(chunked_array); |
| 1064 | |
| 1065 | default: |
| 1066 | break; |
| 1067 | } |
| 1068 | } |
| 1069 | |
| 1070 | return R_NilValue; |
| 1071 | } |
| 1072 | |
| 1073 | bool is_arrow_altrep(SEXP x) { |
| 1074 | if (ALTREP(x)) { |
no test coverage detected