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
# extra layer over bmerge to provide ready to use row indices (or NULL for 1:nrow)
82
83
# NULL to avoid extra copies in downstream code, it turned out that avoiding copies precisely is costly and enormously complicates code, need #4409 and/or handle 1:nrow in subsetDT
83
84
dtmerge=function(x, i, on, how, mult, join.many, void=FALSE, verbose) {
if (void) { ## void=T is only for the case when we want raise error for mult='error', and that would happen in above line
105
111
return(invisible(NULL))
106
-
} elseif (how=="semi"||how=="anti") { ## semi and anti short-circuit
107
-
irows= which(if (how=="semi") ans$lens!=0Lelseans$lens==0L) ## we will subset i rather than x, thus assign to irows, not to xrows
108
-
if (length(irows)==length(ans$lens)) irows=NULL
112
+
} elseif (how=="semi"||how=="anti") { ## semi and anti short-circuit
113
+
## we will subset i rather than x, thus assign to irows, not to xrows
114
+
if (how=="semi")
115
+
irows= which(ans$lens!=0L)
116
+
else
117
+
irows= which(ans$lens==0L)
118
+
if (length(irows) == length(ans$lens)) irows=NULL
109
119
return(list(ans=ans, irows=irows))
110
-
} elseif (mult=="all"&&!ans$allLen1&&!join.many&&## join.many, like allow.cartesian, check
111
-
!(length(ans$starts)==1L&&ans$lens==nrow(x)) &&## special case of scalar i match to const duplicated x, not handled by anyDuplicate: data.table(x=c(1L,1L))[data.table(x=1L), on="x"]
} elseif (mult=="all"&&!ans$allLen1&&!join.many&&## join.many, like allow.cartesian, check
121
+
!(length(ans$starts)==1L&&ans$lens==nrow(x)) &&## special case of scalar i match to const duplicated x, not handled by anyDuplicate: data.table(x=c(1L,1L))[data.table(x=1L), on="x"]
stopf("Joining resulted in many-to-many join. Perform quality check on your data, use mult!='all', or set 'datatable.join.many' option to TRUE to allow rows explosion.")
115
125
}
@@ -120,14 +130,14 @@ dtmerge = function(x, i, on, how, mult, join.many, void=FALSE, verbose) {
120
130
len.x= length(xrows) ## as of now cannot optimize to NULL, search for #4409 here
0 commit comments