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

Use existing index even when auto index is disabled #1422

Closed
jangorecki opened this issue Nov 2, 2015 · 3 comments
Closed

Use existing index even when auto index is disabled #1422

jangorecki opened this issue Nov 2, 2015 · 3 comments
Assignees
Milestone

Comments

@jangorecki
Copy link
Member

If you have auto.index=TRUE your code will always create index when filtering in i for supported cases but many times the dataset is just temporary processing data which will be gone after exit of function. In those cases there is not point to create index. On the other hand I have dataset where I've manually set indexes and those I would like to use (via == or %in%).
Currently datatable.auto.index option seems to affect both cases so cannot be turned on.

library(data.table)
options("datatable.auto.index"=TRUE)
options("datatable.verbose"=TRUE)
d = data.table(k=1)
set2key(d, k)
forder took 0.004 sec
d[k==1]
# Using existing index 'k'
# Starting bmerge ...done in 0 secs
#    k
#1: 1
options("datatable.auto.index"=FALSE)
d = data.table(k=1)
set2key(d, k)
# forder took 0 sec
d[k==1]
#    k
#1: 1
@cooldome
Copy link

Upvoting the request, I also had use cases were wanted to manually maintain secondary keys and not to rely on automatic secondary keys construction. Unfortunately, options("datatable.auto.index"=FALSE) disables a use of already available secondary keys.

@arunsrinivasan arunsrinivasan changed the title Allow to auto use index but don't allow to auto create it Use existing index even when auto index is disabled Nov 26, 2015
@jangorecki jangorecki mentioned this issue Mar 26, 2016
33 tasks
@jangorecki jangorecki added this to the v1.9.8 milestone Apr 19, 2016
@jangorecki
Copy link
Member Author

jangorecki commented Apr 19, 2016

Added to 1.9.8 milestone as it will be useful to have when presenting difference of use of index vs not using index. So allows to avoid helper functions like the one with_index I've used in Scaling data.table using index. Now in 1.9.7 we have index used on joins so it is good to be able to present that feature nicely.
Proposing a new option with following default options("datatable.use.index"=TRUE), combined with datatable.auto.index will give fine control.

@jangorecki jangorecki self-assigned this Apr 19, 2016
@jangorecki
Copy link
Member Author

jangorecki commented Apr 20, 2016

Minor change to vignette can be viewed here.

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

No branches or pull requests

3 participants