Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

libvroom integration: Add bulk extraction API for non-ALTREP mode #2

@jimhester

Description

@jimhester

Problem

In non-ALTREP mode (immediate materialization), vroom extracts fields one at a time:

for (size_t row = 0; row < num_rows; ++row) {
    string val = idx.get(row, col);  // Individual call per row
    result[row] = Rf_mkCharLen(val.data(), val.size());
}

This creates function call overhead and prevents optimization opportunities.

Proposed Solution

Add a bulk extraction API for entire columns:

// Instead of N individual get() calls:
std::vector<std::string_view> extract_column(size_t col) const {
    std::vector<std::string_view> result;
    result.reserve(num_rows());
    
    // Single pass through column data
    for (size_t row = 0; row < num_rows(); ++row) {
        auto span = idx_.get_field(row, col);
        result.emplace_back(buffer_ + span.start, span.length());
    }
    return result;
}

Benefits

  • Pre-allocation of output vector
  • Sequential memory access pattern
  • Potential SIMD acceleration for field extraction
  • Reduced function call overhead

Implementation Notes

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions