| 127 | } |
| 128 | |
| 129 | std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options( |
| 130 | std::string func_name, cpp11::list options) { |
| 131 | if (func_name == "filter") { |
| 132 | using Options = arrow::compute::FilterOptions; |
| 133 | auto out = std::make_shared<Options>(Options::Defaults()); |
| 134 | SEXP keep_na = options["keep_na"]; |
| 135 | if (!Rf_isNull(keep_na) && cpp11::as_cpp<bool>(keep_na)) { |
| 136 | out->null_selection_behavior = Options::EMIT_NULL; |
| 137 | } |
| 138 | return out; |
| 139 | } |
| 140 | |
| 141 | if (func_name == "take") { |
| 142 | using Options = arrow::compute::TakeOptions; |
| 143 | auto out = std::make_shared<Options>(Options::Defaults()); |
| 144 | return out; |
| 145 | } |
| 146 | |
| 147 | if (func_name == "array_sort_indices") { |
| 148 | using Order = arrow::compute::SortOrder; |
| 149 | using Options = arrow::compute::ArraySortOptions; |
| 150 | // false means descending, true means ascending |
| 151 | auto order = cpp11::as_cpp<bool>(options["order"]); |
| 152 | auto out = |
| 153 | std::make_shared<Options>(Options(order ? Order::Descending : Order::Ascending)); |
| 154 | return out; |
| 155 | } |
| 156 | |
| 157 | if (func_name == "sort_indices") { |
| 158 | using Key = arrow::compute::SortKey; |
| 159 | using Order = arrow::compute::SortOrder; |
| 160 | using Options = arrow::compute::SortOptions; |
| 161 | auto names = cpp11::as_cpp<std::vector<std::string>>(options["names"]); |
| 162 | // false means descending, true means ascending |
| 163 | // cpp11 does not support bool here so use int |
| 164 | auto orders = cpp11::as_cpp<std::vector<int>>(options["orders"]); |
| 165 | // Use resize + assignment to avoid vector growth operations that trigger |
| 166 | // false positive -Wmaybe-uninitialized warnings in GCC 14 with std::variant |
| 167 | std::vector<Key> keys(names.size(), Key("", Order::Ascending)); |
| 168 | for (size_t i = 0; i < names.size(); i++) { |
| 169 | keys[i] = Key(names[i], (orders[i] > 0) ? Order::Descending : Order::Ascending); |
| 170 | } |
| 171 | auto out = std::make_shared<Options>(std::move(keys)); |
| 172 | return out; |
| 173 | } |
| 174 | |
| 175 | if (func_name == "all" || func_name == "hash_all" || func_name == "any" || |
| 176 | func_name == "hash_any" || func_name == "approximate_median" || |
| 177 | func_name == "hash_approximate_median" || func_name == "mean" || |
| 178 | func_name == "hash_mean" || func_name == "min_max" || func_name == "hash_min_max" || |
| 179 | func_name == "min" || func_name == "hash_min" || func_name == "max" || |
| 180 | func_name == "hash_max" || func_name == "sum" || func_name == "hash_sum" || |
| 181 | func_name == "product" || func_name == "hash_product") { |
| 182 | using Options = arrow::compute::ScalarAggregateOptions; |
| 183 | auto out = std::make_shared<Options>(Options::Defaults()); |
| 184 | if (!Rf_isNull(options["min_count"])) { |
| 185 | out->min_count = cpp11::as_cpp<int>(options["min_count"]); |
| 186 | } |
no test coverage detected