Uh oh!
There was an error while loading. Please reload this page.
ARROW-16977: [R] Update dataset row counting so no integer overflow on large datasets - #13514
Conversation
Uh oh!
There was an error while loading. Please reload this page.
nealrichardson
left a comment
There was a problem hiding this comment.
Thanks! Two questions:
- I don't see a test of the
r_vec_size()behavior in this PR or the other one. What is our assurance that it behaves as we want? - I noticed that this function previously returned
int64_t, so I wondered whether cpp11 just automatically handled that in the way we wanted. [Turns out someone 🤦 already found out that this doesn't behave nicely], and that we need to handle it ourselves like you have done here. Unfortunately, we have about 20 other functions that return int64_t that would be subject to the same overflow problem. (I searched^int64_tinr/src/to find them.) Would you mind fixing them all in this PR too?
nealrichardson
commented
Jul 6, 2022
Also, it looks like you need to install the package/run the codegen script so that arrowExports.cpp gets updated. |
thisisnic
commented
Jul 7, 2022
I added some in an earlier version of the previous PR, but they took ages to run locally (though were successful), and on CI just crashed it entirely. I removed them, but couldn't think of an alternative. Do you have any suggestions?
Done. |
nealrichardson
commented
Jul 7, 2022
You could tack onto one of the tests that is guarded by |
| ) | ||
| }) | ||
| test_that("num_rows method not susceptible to integer overflow", { |
There was a problem hiding this comment.
These large memory tests are slow, so I don't think you need two versions, I think you can keep just the Table version.
If you want to test more places r_vec_size is used, you can get $nbytes() on the arrays/chunkedarrays, as well as length(). You can also get array$data() and check its length (that one might not be covered yet...) and get $buffers from that, and check them too.
There was a problem hiding this comment.
I've removed the RecordBatch test, added in tests for a few more fields, as well as updating a couple of utility functions that these changes broke. The one thing I didn't do is getting array$data() and actually, I'm wondering if overflow is possible with that? From my understanding, an array's maximum size would be the maximum integer value, or am I getting mixed up there?
There was a problem hiding this comment.
LargeString/Binary at least have a buffer size that can go up to MAX_INT64, that's why they exist.
There was a problem hiding this comment.
@nealrichardson Would you mind expanding on that a bit? There's something I'm missing here or misunderstanding.
There was a problem hiding this comment.
On the format, see https://github.com/apache/arrow/blob/master/format/Schema.fbs#L155-L171 and https://arrow.apache.org/docs/format/Columnar.html.
In R:
# Here's a simple integer array
> a <- Array$create(1:5)
> a$data()
ArrayData
> a$data()$buffers
[[1]]
NULL
[[2]]
Buffer
# the first buffer is for the null bitmask, but it's empty because there are no NAs
> a$data()$buffers[[2]]
Buffer
> a$data()$buffers[[2]]$size
[1] 20
> a$data()$buffers[[2]]$capacity
[1] 20
# here's a string array
> strings <- Array$create(letters)
# note it has 3 buffers, one for the data and one for the offsets
> strings$data()$buffers
[[1]]
NULL
[[2]]
Buffer
[[3]]
Buffer
> strings$data()$buffers[[2]]$size
[1] 108
> strings$data()$buffers[[3]]$size
[1] 26
# let's make a LargeString array using the helper from the test suite
> make_big_string <- function() {
+ # This creates a character vector that would exceed the capacity of BinaryArray
+ rep(purrr::map_chr(2047:2050, ~ paste(sample(letters, ., replace = TRUE), collapse = "")), 2^18)
+ }
> big <- Array$create(make_big_string())
> big$type
LargeUtf8
large_string
> big$data()$buffers
[[1]]
NULL
[[2]]
Buffer
[[3]]
Buffer
> big$data()$buffers[[2]]$size
[1] 8388616
# the data buffer is > MAX_INT32 so it overflows (on master)
> big$data()$buffers[[3]]$size
[1] -2146959360
There was a problem hiding this comment.
Thank you for that! Worked out what it was - I'd completely forgotten R's issues with 64 bit integers for a moment there.
ursabot
commented
Jul 15, 2022
Benchmark runs are scheduled for baseline = 5d86e9f and contender = 87d1889. 87d1889 is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
…Hub issue numbers (#34260) Rewrite the Jira issue numbers to the GitHub issue numbers, so that the GitHub issue numbers are automatically linked to the issues by pkgdown's auto-linking feature. Issue numbers have been rewritten based on the following correspondence. Also, the pkgdown settings have been changed and updated to link to GitHub. I generated the Changelog page using the `pkgdown::build_news()` function and verified that the links work correctly. --- ARROW-6338#5198ARROW-6364#5201ARROW-6323#5169ARROW-6278#5141ARROW-6360#5329ARROW-6533#5450ARROW-6348#5223ARROW-6337#5399ARROW-10850#9128ARROW-10624#9092ARROW-10386#8549ARROW-6994#23308ARROW-12774#10320ARROW-12670#10287ARROW-16828#13484ARROW-14989#13482ARROW-16977#13514ARROW-13404#10999ARROW-16887#13601ARROW-15906#13206ARROW-15280#13171ARROW-16144#13183ARROW-16511#13105ARROW-16085#13088ARROW-16715#13555ARROW-16268#13550ARROW-16700#13518ARROW-16807#13583ARROW-16871#13517ARROW-16415#13190ARROW-14821#12154ARROW-16439#13174ARROW-16394#13118ARROW-16516#13163ARROW-16395#13627ARROW-14848#12589ARROW-16407#13196ARROW-16653#13506ARROW-14575#13160ARROW-15271#13170ARROW-16703#13650ARROW-16444#13397ARROW-15016#13541ARROW-16776#13563ARROW-15622#13090ARROW-18131#14484ARROW-18305#14581ARROW-18285#14615 * Closes: #33631 Authored-by: SHIMA Tatsuya <ts1s1andn@gmail.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
Follow up to #13482 after this one was missed.