forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apache#163 from sun-rui/SPARKR-153_1
[SPARKR-153] phase 1: implement fold() and aggregate().
- Loading branch information
Showing
5 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
% Generated by roxygen2 (4.0.2): do not edit by hand | ||
\docType{methods} | ||
\name{aggregateRDD} | ||
\alias{aggregateRDD} | ||
\alias{aggregateRDD,RDD,RDD-method} | ||
\alias{aggregateRDD,RDD-method} | ||
\title{Aggregate an RDD using the given combine functions and a neutral "zero value".} | ||
\usage{ | ||
aggregateRDD(rdd, zeroValue, seqOp, combOp) | ||
|
||
\S4method{aggregateRDD}{RDD}(rdd, zeroValue, seqOp, combOp) | ||
} | ||
\arguments{ | ||
\item{rdd}{An RDD.} | ||
|
||
\item{zeroValue}{A neutral "zero value".} | ||
|
||
\item{seqOp}{A function to aggregate the RDD elements. It may return a different | ||
result type from the type of the RDD elements.} | ||
|
||
\item{combOp}{A function to aggregate results of seqOp.} | ||
} | ||
\value{ | ||
The aggregation result. | ||
} | ||
\description{ | ||
Aggregate the elements of each partition, and then the results for all the | ||
partitions, using given combine functions and a neutral "zero value". | ||
} | ||
\examples{ | ||
\dontrun{ | ||
sc <- sparkR.init() | ||
rdd <- parallelize(sc, list(1, 2, 3, 4)) | ||
zeroValue <- list(0, 0) | ||
seqOp <- function(x, y) { list(x[[1]] + y, x[[2]] + 1) } | ||
combOp <- function(x, y) { list(x[[1]] + y[[1]], x[[2]] + y[[2]]) } | ||
aggregateRDD(rdd, zeroValue, seqOp, combOp) # list(10, 4) | ||
} | ||
} | ||
\seealso{ | ||
reduce | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
% Generated by roxygen2 (4.0.2): do not edit by hand | ||
\docType{methods} | ||
\name{fold} | ||
\alias{fold} | ||
\alias{fold,RDD,RDD-method} | ||
\alias{fold,RDD-method} | ||
\title{Fold an RDD using a given associative function and a neutral "zero value".} | ||
\usage{ | ||
fold(rdd, zeroValue, op) | ||
|
||
\S4method{fold}{RDD}(rdd, zeroValue, op) | ||
} | ||
\arguments{ | ||
\item{rdd}{An RDD.} | ||
|
||
\item{zeroValue}{A neutral "zero value".} | ||
|
||
\item{op}{An associative function for the folding operation.} | ||
} | ||
\value{ | ||
The folding result. | ||
} | ||
\description{ | ||
Aggregate the elements of each partition, and then the results for all the | ||
partitions, using a given associative function and a neutral "zero value". | ||
} | ||
\examples{ | ||
\dontrun{ | ||
sc <- sparkR.init() | ||
rdd <- parallelize(sc, list(1, 2, 3, 4, 5)) | ||
fold(rdd, 0, "+") # 15 | ||
} | ||
} | ||
\seealso{ | ||
reduce | ||
} | ||
|