Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R] Improve efficiency of decimal casting #20043

Closed
asfimport opened this issue Dec 20, 2021 · 1 comment
Closed

[R] Improve efficiency of decimal casting #20043

asfimport opened this issue Dec 20, 2021 · 1 comment

Comments

@asfimport
Copy link
Collaborator

asfimport commented Dec 20, 2021

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.

@asfimport
Copy link
Collaborator Author

Dragoș Moldovan-Grünfeld / @dragosmg:
I think row 981 is the issue as std::stod converts a string to double

p_data[i] = std::stod(decimals_arr.FormatValue(i).c_str());

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

No branches or pull requests

1 participant