@@ -1770,43 +1770,7 @@ replace_dot_alias = function(e) {
17701770 GForce = FALSE
17711771 } else {
17721772 # Apply GForce
1773- <<<<<<< HEAD
1774- .gforce_ok = function (q ) { # TODO: move outside and test directly
1775- if (dotN(q )) return (TRUE ) # #334
1776- # run GForce for gfuns(x, ...) where x is a column of .SD
1777- # is.symbol() is for #1369, #1974 and #2949
1778- if (! (is.call(q ) && is.symbol(q1 <- q [[1L ]]) && is.symbol(q2 <- q [[2L ]]) && q1 %chin % gfuns )) return (FALSE )
1779- if (! q2 %chin % names(SDenv $ .SDall ) && q2 != " .I" ) return (FALSE ) # 875
1780- if (q1 == " weighted.mean" ) return (TRUE ) # 3977; the weight argument can be a symbol
1781- if (length(q )== 2L ) return (TRUE ) # e.g. sum(colA) (i.e. no arguments)
1782- # establish named arguments; e.g. if both na.rm and n have been passed to first/last, either one could appear first
1783- f = get(q1 ) # maybe a lookup table would be faster than get() but speed should be insignificant here up-front one-time
1784- if (! is.primitive(f )) q = match.call(f , q )
1785- # else the gfuns which are primitive functions (which match.call doesn't support and errors) are
1786- # all of the form fun(..., na.rm=FALSE) so the na.rm arg has to be named in full by the user and
1787- # so will be named in q already
1788- for (argnum in seq.int(3L , length(q ))) {
1789- arg = if (is.null(names(q ))) " " else names(q )[argnum ]
1790- if (arg == " na.rm" ) next
1791- if (q1 == " shift" ) {
1792- if (arg == " fill" && (is.symbol(q $ fill ) || is.atomic(q $ fill ))) next
1793- if (arg == " type" && (is.symbol(q $ type ) || is.atomic(q $ type ))) next # test 2224.01
1794- if (arg == " n" ) next # negative n is supported by optimized shift, and in test 2224.01 n=-1 appears as a call to '-'()
1795- }
1796- if (arg == " n" ) {
1797- if (! is.atomic(q $ n ) || ! isTRUE(q $ n > 0L )) return (FALSE ) # n<=0 not optimized for first/last, [, [[
1798- next
1799- }
1800- if (arg != " " ) return (FALSE ) # e.g. trim= and fill's give.names= are not yet optimized
1801- if (length(q [[argnum ]])!= 1L || ! is.atomic(q [[argnum ]])) return (FALSE ) # test 173.1: DT[,B[B>3],by=A], and test 823: sum(b,a)
1802- if (q1 == " [[" && ! eval(call(' is.atomic' , q2 ), envir = x )) return (FALSE ) # test 1581.16: dt[, .(l=l[[1L]]), by=a]
1803- }
1804- TRUE
1805- }
1806- if (jsub [[1L ]]== " list" ) {
1807- =======
18081773 if (jsub %iscall % " list" ) {
1809- >>>>>>> master
18101774 GForce = TRUE
18111775 for (ii in seq.int(from = 2L , length.out = length(jsub )- 1L )) {
18121776 if (! .gforce_ok(jsub [[ii ]], SDenv $ .SDall )) {GForce = FALSE ; break }
@@ -1897,12 +1861,9 @@ replace_dot_alias = function(e) {
18971861 assign(" .N" , len__ , thisEnv ) # For #334
18981862 # fix for #1683
18991863 if (use.I ) assign(" .I" , seq_len(nrow(x )), thisEnv )
1900- <<<<<<< HEAD
19011864 ans = gforce(thisEnv , jsub , o__ , f__ , len__ , irows , # irows needed for #971
19021865 .Call(CsubsetVector , groups , grpcols ), # just a list() subset to make C level neater; doesn't copy column contents
19031866 lhs ) # for now this just prevents := with new feature first/last n>1; in future see TODO below
1904- =======
1905- ans = gforce(thisEnv , jsub , o__ , f__ , len__ , irows ) # irows needed for #971.
19061867 gi = if (length(o__ )) o__ [f__ ] else f__
19071868 g = lapply(grpcols , function (i ) .Call(CsubsetVector , groups [[i ]], gi )) # use CsubsetVector instead of [ to preserve attributes #5567
19081869
@@ -1943,7 +1904,6 @@ replace_dot_alias = function(e) {
19431904 }
19441905 }
19451906 ans = c(g , ans )
1946- >>>>>>> master
19471907 } else {
19481908 ans = .Call(Cdogroups , x , xcols , groups , grpcols , jiscols , xjiscols , grporder , o__ , f__ , len__ , jsub , SDenv , cols , newnames , ! missing(on ), verbose , showProgress )
19491909 }
@@ -3059,13 +3019,8 @@ gfuns = c(gdtfuns,
30593019`g[` = `g[[` = function (x , n ) .Call(Cgnthvalue , x , as.integer(n )) # n is of length=1 here.
30603020ghead = function (x , n ) .Call(Cghead , x , as.integer(n ))
30613021gtail = function (x , n ) .Call(Cgtail , x , as.integer(n ))
3062- <<<<<<< HEAD
30633022gfirst = function (x , n = 1L , na.rm = FALSE ) .Call(Cgfirst , x , as.integer(n ), na.rm )
30643023glast = function (x , n = 1L , na.rm = FALSE ) .Call(Cglast , x , as.integer(n ), na.rm )
3065- =======
3066- gfirst = function (x ) .Call(Cgfirst , x )
3067- glast = function (x ) .Call(Cglast , x )
3068- >>>>>>> master
30693024gsum = function (x , na.rm = FALSE ) .Call(Cgsum , x , na.rm )
30703025gmean = function (x , na.rm = FALSE ) .Call(Cgmean , x , na.rm )
30713026gweighted.mean = function (x , w , ... , na.rm = FALSE ) {
0 commit comments