Skip to content

[R] Improve efficiency of decimal casting #20043

@asfimport

Description

@asfimport

Status Ingest_some_nulls(SEXP data, const std::shared_ptr<arrow::Array>& array,
R_xlen_t start, R_xlen_t n, size_t chunk_index) const {
auto p_data = REAL(data) + start;
const auto& decimals_arr = checked_cast<const arrow::Decimal128Array&>(*array);
auto ingest_one = [&](R_xlen_t i) {
p_data[i] = std::stod(decimals_arr.FormatValue(i).c_str());
return Status::OK();
};
auto null_one = [&](R_xlen_t i) {
p_data[i] = NA_REAL;
return Status::OK();
};
return IngestSome(array, n, ingest_one, null_one);
}

"this looks quite inefficient (it roundtrips through a string representation instead of creating a double directly)."

from: #11898 (comment)

Reporter: Jonathan Keane / @jonkeane

Related issues:

PRs and other links:

Note: This issue was originally created as ARROW-15167. Please see the migration documentation for further details.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions