Add nodes to convert between csp structs and arrow record batches #680
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 447 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.365
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #680"
general
weight: 0.35
AdamGlustein
Add
record_batches_to_structandstruct_to_record_batchesnodesTwo new C++-backed nodes for bidirectional conversion between
csp.Structand ArrowRecordBatch:-
struct_to_record_batches—ts[List[T]]→ts[List[pa.RecordBatch]]-
record_batches_to_struct—ts[List[pa.RecordBatch]]→ts[List[T]]Both use the Arrow C Data Interface (PyCapsule protocol) to cross the Python/C++ boundary without serialization overhead. Scalar and temporal fields are read/written entirely in C++. Numpy array fields use bulk memory transfers rather than per-element iteration.
### Supported types
bool,int8/16/32/64,uint8/16/32/64,double,str,bytes,datetime,timedelta,date,time,csp.Enum, nestedcsp.Struct,Numpy1DArray[T], andNumpyNDArray[T].### Performance
Read and write paths are columnar: each column is processed in a single
readAll()/writeAll()call per batch rather than row-by-row virtual dispatch, reducing virtual call count from N×M (rows × columns) to M. ThereadAll()path uses anull_count==0fast path that skips per-row validity checks entirely. Fixed-size writers useUnsaafter a singlefeAppend
Reserve()to skip per-row capacity and status checks. Nested struct readers pre-allocate all child structs before delegating to childreadAll()calls column by column.Throughput on 100k numeric rows (int64 + float64): ~6.4M rows/sec read, ~800k rows/sec write (write dominated by CSP graph overhead).
Stress tests comparing reading compressed parquet files through both the Parquet adapter (
ParquetReader.subscribe_all) and the Arrow path (RecordBatchPullInputAdapter→record_batches_to_struct):| Scenario | Arrow | Parquet | Speedup |
|---|---|---|---|
| 500k rows, 10 timestamps (50k rows/ts) | 4.0M rows/s | 1.8M rows/s | 2.3x |
| 100k rows, 1k timestamps (100 rows/ts) | 2.6M rows/s | 2.0M rows/s | 1.3x |
| 1M rows, 10k timestamps (100 rows/ts) | 2.4M rows/s | 2.1M rows/s | 1.15x |
| 100k rows, 100k timestamps (1 row/ts) | 76k rows/s | 2.0M rows/s | 26x slower |
Arrow's advantage grows with larger batches per timestamp. The 1-row-per-timestamp case exposes per-tick overhead from
RecordBatchPullInputAdaptercreating and converting individual single-row batches — the Parquet adapter handles this natively since its C++ reader emits one struct per row without intermediate Arrow batches.### Example