@@ -190,24 +190,13 @@ DT = data.table(A=1:10,B=rnorm(10),C=paste("a",1:100010,sep=""))
190190test(301.1, nrow(DT[,sum(B),by=C])==100010)
191191
192192# Test := by key, and that := to the key by key unsets the key. Make it non-trivial in size too.
193- local({
194- old = options(datatable.optimize=0L); on.exit(options(old))
195- set.seed(1)
196- DT = data.table(a=sample(1:100, 1e6, replace=TRUE), b=sample(1:1000, 1e6, replace=TRUE), key="a")
197- test(637.1, DT[, m:=sum(b), by=a][1:3], data.table(a=1L, b=c(156L, 808L, 848L), m=DT[J(1), sum(b)], key="a"))
198- test(637.2, key(DT[J(43L), a:=99L]), NULL)
199- setkey(DT, a)
200- test(637.3, key(DT[, a:=99L, by=a]), NULL)
201- })
202- local({
203- options(datatable.optimize=2L); on.exit(options(old))
204- set.seed(1)
205- DT = data.table(a=sample(1:100, 1e6, replace=TRUE), b=sample(1:1000, 1e6, replace=TRUE), key="a")
206- test(638.1, DT[, m:=sum(b), by=a][1:3], data.table(a=1L, b=c(156L, 808L, 848L), m=DT[J(1), sum(b)], key="a"))
207- test(638.2, key(DT[J(43L), a:=99L]), NULL)
208- setkey(DT,a)
209- test(638.3, key(DT[, a:=99L, by=a]), NULL)
210- })
193+ set.seed(1)
194+ DT = data.table(a=sample(1:100, 1e6, replace=TRUE), b=sample(1:1000, 1e6, replace=TRUE), key="a")
195+ opt = c(0L,2L)
196+ test(637.1, levels=opt, copy(DT)[, m:=sum(b), by=a][1:3], data.table(a=1L, b=c(156L, 808L, 848L), m=DT[J(1), sum(b)], key="a"))
197+ test(637.2, levels=opt, key(copy(DT)[J(43L), a:=99L]), NULL)
198+ setkey(DT, a)
199+ test(637.3, levels=opt, key(copy(DT)[, a:=99L, by=a]), NULL)
211200
212201# Test X[Y] slowdown, #2216
213202# Many minutes in 1.8.2! Now well under 1s, but 10s for very wide tolerance for CRAN. We'd like CRAN to tell us if any changes
0 commit comments