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

 ##########
 File path: R/pkg/inst/worker/worker.R
 ##########
 @@ -181,17 +185,37 @@ 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") {
+            outputs[[length(outputs) + 1L]] <- output
 
 Review comment:
   ```r
   outputA <- list()
   outputB <- list()
   
   testA <- function() {
     options(digits.secs = 6) # milliseconds
     start.time <- Sys.time()
     output <- list()
     for (i in 1:10000) {
       output[[length(output) + 1L]] <- 1
     }
     end.time <- Sys.time()
     time.taken <- end.time - start.time
     print(time.taken)
     output
   }
   
   
   
   testB <- function() {
     options(digits.secs = 6) # milliseconds
     start.time <- Sys.time()
     output <- list()
     for (i in 1:10000) {
       output <- append(output, 1)
     }
     end.time <- Sys.time()
     time.taken <- end.time - start.time
     print(time.taken)
     output
   }
   
   require(testthat)
   
   outputA <- testA()
   outputB <- testB()
   
   expect_equal(outputA, outputB)
   ```
   
   Looks direct assignement is faster:
   
   ```
   Time difference of 0.008903027 secs
   Time difference of 0.5212681 secs
   ```

----------------------------------------------------------------
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