A version of vctrs::vec_size() limited to the types that are supported at the C++ level. We currently handle record-style vectors (e.g., POSIXlt) at the R level such that by the time they get to C++ they are just a data.frame. This version also supports long vectors.
| 380 | // they get to C++ they are just a data.frame. This version also |
| 381 | // supports long vectors. |
| 382 | static inline R_xlen_t vec_size(SEXP x) { |
| 383 | if (Rf_inherits(x, "data.frame")) { |
| 384 | if (Rf_length(x) > 0) { |
| 385 | return Rf_xlength(VECTOR_ELT(x, 0)); |
| 386 | } else { |
| 387 | // This will expand the rownames if attr(x, "row.names") is ALTREP; |
| 388 | // however, this is probably not an important performance consideration |
| 389 | // since zero-column data.frames do not occur in many workflows. |
| 390 | return Rf_xlength(Rf_getAttrib(x, R_RowNamesSymbol)); |
| 391 | } |
| 392 | } else { |
| 393 | return Rf_xlength(x); |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | } // namespace r |
| 398 | } // namespace arrow |
no outgoing calls
no test coverage detected