You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
seti argument takes integer rows identifiers already, so there is space to put index optimisation there.
Index can already be utilised by passing dt[, which=TRUE] results to set's i arg.
library(data.table)
dt= data.table(a=1:4, b=5:2)
setindex(dt, b)
dt[b%in%3:4, which=TRUE, verbose=TRUE]
#Optimized subsetting with index 'b'#on= matches existing index, using index#Starting bmerge ...done in 0.000s elapsed (0.000s cpu) #Reordering 2 rows after bmerge done in ... 0 secs#[1] 2 3
This of course will include overhead of [, but if set is used to the same subset of rows on multiple columns then the overhead will be implied only once. What we could eventually improve here is to reduce overhead of [ by figuring out that dt[a==b, which=TRUE] call was made, and redirect it early to C. The thing is that there are multiple kind of queries that could be optimised in such a way. Ultimately we need to move [ to C, or make it more modular #852, so different kinds of queries can be more easily/sooner redirected to C.
Activity
jangorecki commentedon Mar 17, 2019
setiargument takes integer rows identifiers already, so there is space to put index optimisation there.Index can already be utilised by passing
dt[, which=TRUE]results to set'siarg.This of course will include overhead of
[, but ifsetis used to the same subset of rows on multiple columns then the overhead will be implied only once. What we could eventually improve here is to reduce overhead of[by figuring out thatdt[a==b, which=TRUE]call was made, and redirect it early to C. The thing is that there are multiple kind of queries that could be optimised in such a way. Ultimately we need to move[to C, or make it more modular #852, so different kinds of queries can be more easily/sooner redirected to C.