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

order could utilize existing index #3023

Open
jangorecki opened this issue Aug 30, 2018 · 2 comments · May be fixed by #4458
Open

order could utilize existing index #3023

jangorecki opened this issue Aug 30, 2018 · 2 comments · May be fixed by #4458
Assignees

Comments

@jangorecki
Copy link
Member

jangorecki commented Aug 30, 2018

d = data.table(x=2:1)
d[order(x, na.last=FALSE)]
@jangorecki jangorecki changed the title order could utilize existing index order could utilize existing index Aug 30, 2018
@jangorecki jangorecki self-assigned this Apr 14, 2020
@jangorecki
Copy link
Member Author

jangorecki commented Apr 19, 2020

This issue could be automatically handled by #4386 but the problem is that forder strips out all attributes before even calling forderv. This happens because when we call

d = data.table(x=2:1)
d[order(x, na.last=FALSE)]

We technically call forder on integer vector x, not on a d data.table. To not duplicate the work, to address that, it is best to rely on #4386 and we have to make better input massaging when preparing arguments for forderv, retaining key/index attributes.
According to ideas in #4346 the proper way to address that would be to optimize from [.data.table directly to forderv, and not to forder.

@jangorecki
Copy link
Member Author

It should be possible to optimize as well d[order(x)] in cases where x does not have NAs, which can be a cheap to check if index exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant