Github user sun-rui commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12426#discussion_r60359396
  
    --- Diff: R/pkg/R/context.R ---
    @@ -225,3 +225,26 @@ broadcast <- function(sc, object) {
     setCheckpointDir <- function(sc, dirName) {
       invisible(callJMethod(sc, "setCheckpointDir", 
suppressWarnings(normalizePath(dirName))))
     }
    +
    +#' @title Run a function over a list of elements, distributing the 
computations with Spark.
    +#'
    +#' @description
    +#' Applies a function in a manner that is similar to doParallel or lapply 
to elements of a list.
    +#' The computations are distributed using Spark. It is conceptually the 
same as the following code:
    +#'   unlist(lapply(list, func))
    +#'
    +#' @param list the list of elements
    +#' @param func a function that takes one argument.
    +#' @noRd
    +#' @examples
    +#' Here is a trivial example that double the values in a list
    +#'\dontrun{
    +#' doubled <- sparkLapply(1:10, function(x){2 * x})
    +#'}
    +sparkLapply <- function(list, func) {
    +  sc <- get(".sparkRjsc", envir = .sparkREnv)
    +  rdd <- parallelize(sc, list, length(list))
    --- End diff --
    
    dapply and spark.lapply have different schematics. No need to check 
class(list) here as a DataFrame can be treated as a list of columns. 
parallelize() will issue warning for DataFrame at here: 
https://github.com/apache/spark/blob/master/R/pkg/R/context.R#L110



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to