FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

is.sorted is slow for determining whether jval is sorted by key · Issue #4498 · Rdatatable/data.table · GitHub

is.sorted is slow for determining whether jval is sorted by key #4498

Description

From SO:

https://stackoverflow.com/questions/62019120/why-does-data-table-notation-for-column-retrieval-affect-speed/62028864#62028864

x <- as.data.table(as.character(rnorm(20000000,1,0.5)))
setkey(x,V1)

tic(); x[,.(V1)]; toc()
# 25.08 sec elapsed

(timing is even worse on my machine)

The bottleneck appears to be this line:

if (haskey(x) && all(key(x) %chin% names(jval)) && suppressWarnings(is.sorted(jval, by=key(x)))) # TO DO: perhaps this usage of is.sorted should be allowed internally then (tidy up and make efficient)

IINM we can tell the output is sorted because V1 is the key and it appears as a name -- no need to compute the sort order all over again.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Highbreaking-changeissues whose solution would require breaking existing behavior

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL