Skip to content

[R] Improve efficiency of decimal casting #20043

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;
constauto& 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());
returnStatus::OK();
};
auto null_one = [&](R_xlen_t i) {
p_data[i] = NA_REAL;
returnStatus::OK();
};
returnIngestSome(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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions