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

rbindlist support fill=TRUE with use.names=FALSE and use it in merge.R ToDo of #678 #5263

Merged
merged 12 commits into from
Nov 23, 2021
5 changes: 3 additions & 2 deletions R/merge.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ merge.data.table = function(x, y, by = NULL, by.x = NULL, by.y = NULL, all = FAL
othercolsx = setdiff(nm_x, by)
if (length(othercolsx)) {
tmp = rep.int(NA_integer_, length(missingyidx))
# TO DO: use set() here instead..
yy = cbind(yy, x[tmp, othercolsx, with = FALSE])
nx = c(names(yy), names(x[tmp, othercolsx, with = FALSE]))
nx = make.unique(nx)
set(yy, NULL, tail(nx, -ncol(yy)), x[tmp, othercolsx, with = FALSE])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a noticeable memory advantage to looping over the RHS columns instead of creating the whole with=FALSE subset table?

it looks like the advantage is we can do the tmp subset once & apply it to all columns...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guessed that saving this tmp object and doing indexing twice is preferred over using additional memory. Rethinking it again, I might have figured out what the ToDo meant initially where using set omits this object/indexing anyway.

}
# empty data.tables (nrow =0, ncol>0) doesn't skip names anymore in new rbindlist
# takes care of #24 without having to save names. This is how it should be, IMHO.
Expand Down