HyukjinKwon commented on a change in pull request #23746: [SPARK-26761][SQL][R] 
Vectorized R gapply() and gapplyCollect() implementation
URL: https://github.com/apache/spark/pull/23746#discussion_r255377360
 
 

 ##########
 File path: R/pkg/inst/worker/worker.R
 ##########
 @@ -181,17 +185,35 @@ if (isEmpty != 0) {
                     colNames, computeFunc, data)
        } else {
         # gapply mode
+        outputs <- list()
         for (i in 1:length(data)) {
           # Timing reading input data for execution
           inputElap <- elapsedSecs()
           output <- compute(mode, partition, serializer, deserializer, 
keys[[i]],
                       colNames, computeFunc, data[[i]])
           computeElap <- elapsedSecs()
-          outputResult(serializer, output, outputCon)
+          if (deserializer == "arrow") {
+            requireNamespace("arrow", quietly = TRUE)
+            outputs[[length(outputs) + 1L]] <- output
+          } else {
+            outputResult(serializer, output, outputCon)
+          }
           outputElap <- elapsedSecs()
           computeInputElapsDiff <-  computeInputElapsDiff + (computeElap - 
inputElap)
           outputComputeElapsDiff <- outputComputeElapsDiff + (outputElap - 
computeElap)
         }
+
+        if (deserializer == "arrow") {
+          requireNamespace("arrow", quietly = TRUE)
+          # See 
https://stat.ethz.ch/pipermail/r-help/2010-September/252046.html
+          # rbind.fill might be an anternative to make it faster if plyr is 
installed.
+          combined <- do.call("rbind", outputs)
 
 Review comment:
   Seems `rbind(iris(dataframe, ...)` not working .. :(. 
   
   Yea, in terms of strings as factors ..  for input, it should be okay about 
`stringsAsFactors` because it's directly converted from Arrow batch.
   
   For output, yes, I think there might be a concern about strings as factors. 
I currently assume the given function should always return the same 
`data.frame`s to combine. So I guess it's okay. I would like to leave this 
concern separate if you don't mind. We don't take care of factors in JVM side 
anyway.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to