Timothée HENRY
Timothée HENRY

Reputation: 14604

R data table binary search not finding rows

> str(t2)
Classes ‘data.table’ and 'data.frame':  15349956 obs. of  2 variables:
 $ id      :Class 'integer64'  num [1:15349956] 4.26e-319 4.26e-319 4.26e-319 4.26e-319 4.26e-319 ...
     $ category: int  706 706 706 706 706 706 706 706 706 706 ...
     - attr(*, ".internal.selfref")=<externalptr> 
     - attr(*, "sorted")= chr  "id" "category"

> dput(head(t2))
structure(list(id = structure(c(4.26111856912241e-319, 4.26111856912241e-319, 
4.26111856912241e-319, 4.26111856912241e-319, 4.26111856912241e-319, 
4.26111856912241e-319), class = "integer64"), category = c(706L, 
706L, 706L, 706L, 706L, 706L)), .Names = c("id", "category"), sorted = c("id", 
"category"), class = c("data.table", "data.frame"), row.names = c(NA, 
-6L))


   > head(t2)

      id category
1: 86246      706
2: 86246      706
3: 86246      706

4: 86246      706
5: 86246      706
6: 86246      706

> t2[J(86246,706), nomatch=0]
Empty data.table (0 rows) of 2 cols: id,category

Why is the binary search not finding the rows that we see in t2 head ?

Upvotes: 2

Views: 96

Answers (1)

Arun
Arun

Reputation: 118799

This is now implemented in v1.9.3 (available from R-Forge), see NEWS :

o bit64::integer64 now works in grouping and joins, #5369. Thanks to James Sams for highlighting UPCs and Clayton Stanley.
Reminder: fread() has been able to detect and read integer64 for a while.

On OP's example above:

t2[J(as.integer64(86246),706), nomatch=0L]
#       id category
# 1: 86246      706
# 2: 86246      706
# 3: 86246      706
# 4: 86246      706
# 5: 86246      706
# 6: 86246      706

Upvotes: 2

Related Questions