Skip to content

Under-allocation of truelength after subsetting #3228

Description

@renkun-ken

The allocation behavior seems to be changed. The truelength() is largely reduced after any subsetting. Massive adding columns to the under-allocated data.table in other environment would fail to apply to the original object.

library(data.table)

dt <- data.table(id = 1:1000)
dt[, x := rnorm(.N)]
truelength(dt)
#> [1] 1025

dt1 <- dt[x > 0]
truelength(dt1)
#> [1] 66

Activity

  1. mattdowle commented on Dec 15, 2018

    @mattdowle
    Member

    Thanks. I see the issue. CsubsetDT does the over-allocation inside it at C level. It needs the alloc.col option passing down from R level. Will do.

  2. added this to the 1.12.0 milestone on Dec 15, 2018
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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions