| 63 | } |
| 64 | |
| 65 | void arrow::r::validate_slice_length(R_xlen_t length, int64_t available) { |
| 66 | if (length == NA_INTEGER) { |
| 67 | cpp11::stop("Slice 'length' cannot be NA"); |
| 68 | } |
| 69 | if (length < 0) { |
| 70 | cpp11::stop("Slice 'length' cannot be negative"); |
| 71 | } |
| 72 | if (length > available) { |
| 73 | // For an unknown reason, cpp11::warning() crashes here; however, this |
| 74 | // should throw an exception if Rf_warning() jumps, so we need |
| 75 | // cpp11::safe[](). |
| 76 | cpp11::safe[Rf_warning]("Slice 'length' greater than available length"); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | // [[arrow::export]] |
| 81 | std::shared_ptr<arrow::Array> Array__Slice1(const std::shared_ptr<arrow::Array>& array, |