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

GForce double brackets #3209

Closed
renkun-ken opened this issue Dec 13, 2018 · 0 comments · Fixed by #3788
Closed

GForce double brackets #3209

renkun-ken opened this issue Dec 13, 2018 · 0 comments · Fixed by #3788
Labels
GForce issues relating to optimized grouping calculations (GForce)
Milestone

Comments

@renkun-ken
Copy link
Member

I'm not sure if there's a reason that [[ is not gforce-optimized while [ is?

library(data.table)

dt <- data.table(group = rep(1:10, each = 100))
dt[, x := rnorm(.N)]
dt[, y := rnorm(.N)]

dt[, .(x1 = x[1], y = y[1]), keyby = group, verbose = TRUE]
#> Detected that j uses these columns: x,y 
#> Finding groups using forderv ... 0.008s elapsed (0.034s cpu) 
#> Finding group sizes from the positions (can be avoided to save RAM) ... 0.000s elapsed (0.000s cpu) 
#> lapply optimization is on, j unchanged as 'list(x[1], y[1])'
#> GForce optimized j to 'list(`g[`(x, 1), `g[`(y, 1))'
#> Making each group and running j (GForce TRUE) ... 0.000s elapsed (0.001s cpu)
#>     group          x1          y
#>  1:     1  0.53517123 -0.9882846
#>  2:     2  0.51018979 -0.2830759
#>  3:     3  1.24404772  0.3771081
#>  4:     4  0.04945898  0.2840527
#>  5:     5 -0.94713301  0.5256134
#>  6:     6  1.05691797 -0.7430845
#>  7:     7  0.53789528 -0.4212249
#>  8:     8  0.69661191 -0.0915251
#>  9:     9  1.74234732 -0.6924493
#> 10:    10  1.11381907  0.2091079

dt[, .(x1 = x[[1]], y = y[[1]]), keyby = group, verbose = TRUE]
#> Detected that j uses these columns: x,y 
#> Finding groups using forderv ... 0.000s elapsed (0.000s cpu) 
#> Finding group sizes from the positions (can be avoided to save RAM) ... 0.000s elapsed (0.000s cpu) 
#> lapply optimization is on, j unchanged as 'list(x[[1]], y[[1]])'
#> GForce is on, left j unchanged
#> Old mean optimization is on, left j unchanged.
#> Making each group and running j (GForce FALSE) ... 
#>   memcpy contiguous groups took 0.000s for 10 groups
#>   eval(j) took 0.000s for 10 calls
#> 0.000s elapsed (0.000s cpu)
#>     group          x1          y
#>  1:     1  0.53517123 -0.9882846
#>  2:     2  0.51018979 -0.2830759
#>  3:     3  1.24404772  0.3771081
#>  4:     4  0.04945898  0.2840527
#>  5:     5 -0.94713301  0.5256134
#>  6:     6  1.05691797 -0.7430845
#>  7:     7  0.53789528 -0.4212249
#>  8:     8  0.69661191 -0.0915251
#>  9:     9  1.74234732 -0.6924493
#> 10:    10  1.11381907  0.2091079
@MichaelChirico MichaelChirico added the GForce issues relating to optimized grouping calculations (GForce) label Feb 25, 2019
MichaelChirico pushed a commit that referenced this issue Aug 24, 2019
@mattdowle mattdowle added this to the 1.12.4 milestone Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GForce issues relating to optimized grouping calculations (GForce)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants