-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
Support for long vectors #239
Labels
feature request
New features
Comments
Well, I finally encountered this... time to fix. :-D R$ n <- 1.1e7
x <- replicate(200, xts::.xts(double(n), seq_len(n)), simplify = FALSE)
y <- do.call(merge, x)
## Error in merge.xts(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, :
## negative length vectors are not allowed This is because The lack of long vector support also crashes x <- xts::.xts(matrix(0.0, nrow = 1.1e7, ncol = 200), seq_len(1.1e7))
# then:
# zoo::na.locf(x) # segfaults
## *** caught segfault ***
## address 0x7f5deb095848, cause 'memory not mapped'
##
## Traceback:
## 1: na.locf.xts(x)
## 2: zoo::na.locf(x)
This is likely a problem in multiple places in the C code. |
joshuaulrich
added a commit
that referenced
this issue
Mar 7, 2023
R added support for long vectors in version 3.0.0. The xts C code had not been updated to take advantage of this feature. That meant xts objects were limited to matrices with less than 2^32-1 elements. Most of the changes are fall into these categories: 1. Change index counters from 'int' to 'R_xlen_t' 2. Use xlength() instead of LENGTH() or length() to get length 3. Use xlengthgets() instead of lengthgets() to set length There are a few non-functional changes to move type declaration closer to where the variable is used. See #239.
More test cases: n <- 1.1e9
x <- xts::.xts(matrix(seq_len(n*2), nrow = n, ncol = 2), seq_len(n))
y <- merge(x, x[,2])
y <- zoo::coredata(x)
y <- lag(x)
y <- diff(x) # due to lag.xts()
y <- x[ seq_len(n*2),]
y <- x[-seq_len(n*2),]
xts::isOrdered(seq_len(n*2))
xts:::naCheck(seq_len(n*2))
y <- rbind(x, x) #### negative length vectors are not allowed
y <- xts::make.index.unique(x)
# zoo::na.locf(x) ### segfaults
# na.omit(x) ### killed
|
joshuaulrich
added a commit
that referenced
this issue
Mar 11, 2023
This also requires a change in the lag() and coredata() zoo functions. They have been added to the 1.8-12 development version of zoo. See #239.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
R-3.0.0 added support for vectors longer than the maximum positive value for a signed 32-bit integer (
2^31-1
~ 2.147e9). It would be nice to support these in internal C code, but it is not particularly urgent.The smallest xts object that would need this functionality would have
2^31
rows. That object would occupy 16GB of RAM if the index and the data were integers, and 32GB of RAM if they were both doubles.I doubt many (if any) users have xts objects that large at the moment, but would be nice to address this.
The text was updated successfully, but these errors were encountered: