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

setindexv could accept list of characters to create multiple indices #2695

Closed
jangorecki opened this issue Mar 22, 2018 · 3 comments
Closed
Assignees
Milestone

Comments

@jangorecki
Copy link
Member

It could be internally optimized for speed but for now it will be enough to run in loop.
API to create index on a field and second index on a, b fields:

setindexv(DT, list("a",c("a","b"))
@jangorecki jangorecki changed the title setindexv coul accept a list to create multiple indices setindexv could accept list of characters to create multiple indices Mar 22, 2018
@MichaelChirico
Copy link
Member

MichaelChirico commented Mar 29, 2018

I'm just about done writing this.... but I'm thinking, is this really any more convenient than sapply(list('a', c('a', 'b')), setindexv, x = DT)?

i have the following so far:

setindexv <- function(x, cols, verbose=getOption("datatable.verbose")) {
  if (is.list(cols)) {
    sapply(cols, function(index_i) setkeyv(x, index_i, verbose, physical=FALSE))
  } else {
    setkeyv(x, cols, verbose, physical=FALSE)
  }
}

@jangorecki
Copy link
Member Author

jangorecki commented Mar 29, 2018

Single DT should be returned from setindexv, no matter if we set one index or many. A little more convenient :) and we are going to use same API in fread already. It would be awkward if user will learn setting up index on fread and then would be surprised it is not working with setindexv. If you are deving this why no self assign issue?

@MichaelChirico
Copy link
Member

MichaelChirico commented Mar 29, 2018 via email

@mattdowle mattdowle added this to the v1.10.6 milestone Mar 31, 2018
mattdowle pushed a commit that referenced this issue Mar 31, 2018
…2711)

* Closes #2695 -- setindexv creates multiple indices when passed list

* Deprecated set2key and key2. Spotted as an aside thanks to codecov in this PR.

* Removed internal, unused and not-exported get2key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants