Skip to content

order could utilize existing index #3023

Open

Description

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

Activity

  1. changed the title [-]order could utilize existing index[/-] [+]`order` could utilize existing index[/+] on Aug 30, 2018
  2. self-assigned this
    on Apr 14, 2020
  3. jangorecki commented on Apr 19, 2020

    @jangorecki
    MemberAuthor

    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.

  4. jangorecki commented on May 11, 2020

    @jangorecki
    MemberAuthor

    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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions