Skip to main content

Module dataframe_builder

Module dataframe_builder 

Source
Expand description

Closure-per-column DataFrame builder.

RDataFrameBuilder assembles an R data.frame from a set of typed columns, each with its own element type and fill closure. It is the heterogeneous-column analogue of with_r_matrix: you declare columns, the builder allocates the backing storage with strict PROTECT discipline, fills it, and assembles the data.frame on the R thread.

§Fill strategy (parallel with rayon, serial otherwise)

The builder type and its surface are available regardless of the rayon feature (#1055). Only the fill pass differs:

  • With rayon — the whole job is flattened into a single work-list of (column_index, row-range) items and filled in one work-stealing par_iter pass (see RDataFrameBuilder docs for the scheduling argument).
  • Without rayon — each column is filled in one full-range serial pass.

Both paths produce an identical data.frame. Nothing else in the builder depends on rayon: with_r_thread, Sendable, RNativeType, the PROTECT discipline, and the assembly step are all rayon-independent. The Send + Sync bounds on the fill closures are simply unused when rayon is absent.

Structs§

ColPtr 🔒
Send+Sync wrapper for a raw column-data pointer carried across the flatten boundary. The pointer addresses R-owned memory for native columns or a Vec<Option<String>> backing buffer for character columns. Disjointness (per column and per row-range within a column) is the caller’s invariant — see the safety argument on RDataFrameBuilder.
ColumnReg 🔒
One registered column: a serial allocation step plus the range filler that the flattened work-list (or serial loop) dispatches.
RDataFrameBuilder
Builder for assembling an R data.frame from per-column fill closures.

Enums§

ColumnKind 🔒
How a column’s R storage is materialized after the fill.

Type Aliases§

RangeFiller 🔒
Type-erased “fill this row-range of this column” closure.