#[doc(hidden)]pub unsafe fn gather_column(src: SEXP, idx: &[usize]) -> SEXPExpand description
Gather the rows at idx (0-based, in order) out of a typed column SEXP into a
new dense SEXP of length idx.len(), where out[j] = src[idx[j]].
The row-selecting inverse of scatter_column: where scatter_column
places a dense column’s values at sparse positions, gather_column pulls a
dense subset out of a column by row index. Used by DataFrame::select_rows
to densify a flattened sub-frame before the enum reader recurses.
Contiguous primitive columns (real/integer/logical/raw/complex) are copied as
a slice gather via gather_native; string and list columns are copied
element-by-element because they are write-barriered arrays of SEXP pointers,
not flat buffers. The output type mirrors the input; any other type falls back
to a logical NA column (normal data.frame columns never reach it).
Column attributes (class/levels for factor / Date / POSIXct) are not
copied — the caller restores those after rooting the gathered column.
§Safety
Must be called on the R main thread. src must be a valid SEXP and every
index in idx must be < xlength(src). The returned SEXP is unprotected;
the caller must root it (e.g. via SET_VECTOR_ELT into a protected list)
before performing any allocation.