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

Creating data.table with long vectors does not produce error at creation #2751

Closed
renkun-ken opened this issue Apr 16, 2018 · 3 comments
Closed
Labels
longvec Long Vector support

Comments

@renkun-ken
Copy link
Member

It seems that data.table does not support long vectors at the moment. When I create a data.table with long vectors, it should trigger an error at creation rather than when I use it somewhere else.

> library(data.table)
> d <- data.table(x = seq(1, .Machine$integer.max + 1))
Warning message:
In setattr(value, "row.names", .set_row_names(nr)) :
  NAs introduced by coercion to integer range
<simpleError in dim.data.table(obj): long vectors not supported yet: ../../src/include/Rinlinedfuns.h:138>
> d
Error in dim.data.table(x) : 
  long vectors not supported yet: ../../src/include/Rinlinedfuns.h:138

A less obvious example is rbindlist several data.tables each does not have long vectors but together exceeds max integer.

library(data.table)

d1 <- data.table(x = seq(1, .Machine$integer.max / 2))
d2 <- data.table(x = seq(1, .Machine$integer.max / 2))
d3 <- data.table(x = seq(1, .Machine$integer.max / 2))

d <- rbindlist(list(d1, d2, d3))

which will end up in an error:

Error in vapply(x, length, 0L) : values must be type 'integer',
 but FUN(X[[1]]) result is type 'double'

If a user does not keep in mind that data.table does not support long vectors yet or R uses double to represent the length of a long vector instead of an integer, the error message can be very confusing.

@MichaelChirico
Copy link
Member

Are you using the latest dev?

I get a different, much more helpful error:

Error in rbindlist(list(d1, d2, d3)) :

Total rows in the list is 3221225469 which is larger than the maximum number of rows, currently 2147483647

@MichaelChirico
Copy link
Member

I believe duplicate of #2340

@renkun-ken
Copy link
Member Author

Thanks, the error message in dev is much more helpful.

@jangorecki jangorecki added the longvec Long Vector support label Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
longvec Long Vector support
Projects
None yet
Development

No branches or pull requests

3 participants