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#93 from hlin09/hlin09
[SPARKR-15] Adds function Filter() to extract elements that satisfy a predicate.
- Loading branch information
Showing
6 changed files
with
149 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,34 @@ | ||
% Generated by roxygen2 (4.0.2): do not edit by hand | ||
\docType{methods} | ||
\name{Filter,function,RDD-method} | ||
\alias{Filter,function,RDD-method} | ||
\alias{filter} | ||
\alias{filter,function,RDD-method} | ||
\title{This function returns a new RDD containing only the elements that satisfy | ||
a predicate (i.e. returning TRUE in a given logical function). | ||
The same as `filter()' in Spark.} | ||
\usage{ | ||
\S4method{Filter}{`function`,RDD}(f, x) | ||
filter(f, x) | ||
\S4method{filter}{`function`,RDD}(f, x) | ||
} | ||
\arguments{ | ||
\item{f}{A unary predicate function.} | ||
\item{x}{The RDD to be filtered.} | ||
} | ||
\description{ | ||
This function returns a new RDD containing only the elements that satisfy | ||
a predicate (i.e. returning TRUE in a given logical function). | ||
The same as `filter()' in Spark. | ||
} | ||
\examples{ | ||
\dontrun{ | ||
sc <- sparkR.init() | ||
rdd <- parallelize(sc, 1:10) | ||
unlist(collect(Filter(function (x) { x < 3 }, rdd))) # c(1, 2) | ||
} | ||
} | ||
|
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,28 @@ | ||
% Generated by roxygen2 (4.0.2): do not edit by hand | ||
\docType{methods} | ||
\name{distinct} | ||
\alias{distinct} | ||
\alias{distinct,RDD,missingOrInteger-method} | ||
\title{Removes the duplicates from RDD.} | ||
\usage{ | ||
distinct(rdd, numPartitions) | ||
|
||
\S4method{distinct}{RDD,missingOrInteger}(rdd, numPartitions) | ||
} | ||
\arguments{ | ||
\item{rdd}{The RDD to remove duplicates from.} | ||
|
||
\item{numPartitions}{Number of partitions to create.} | ||
} | ||
\description{ | ||
This function returns a new RDD containing the distinct elements in the | ||
given RDD. The same as `distinct()' in Spark. | ||
} | ||
\examples{ | ||
\dontrun{ | ||
sc <- sparkR.init() | ||
rdd <- parallelize(sc, c(1,2,2,3,3,3)) | ||
sort(unlist(collect(distinct(rdd)))) # c(1, 2, 3) | ||
} | ||
} | ||
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,32 @@ | ||
% Generated by roxygen2 (4.0.2): do not edit by hand | ||
\docType{methods} | ||
\name{mapValues} | ||
\alias{mapValues} | ||
\alias{mapValues,RDD,function-method} | ||
\title{Applies a function to all values of the elements, without modifying the keys.} | ||
\usage{ | ||
mapValues(X, FUN) | ||
|
||
\S4method{mapValues}{RDD,`function`}(X, FUN) | ||
} | ||
\arguments{ | ||
\item{X}{The RDD to apply the transformation.} | ||
|
||
\item{FUN}{the transformation to apply on the value of each element.} | ||
} | ||
\value{ | ||
a new RDD created by the transformation. | ||
} | ||
\description{ | ||
The same as `mapValues()' in Spark. | ||
} | ||
\examples{ | ||
\dontrun{ | ||
sc <- sparkR.init() | ||
rdd <- parallelize(sc, 1:10) | ||
makePairs <- lapply(rdd, function(x) { list(x, x) }) | ||
collect(mapValues(makePairs, function(x) { x * 2) }) | ||
Output: list(list(1,2), list(2,4), list(3,6), ...) | ||
} | ||
} | ||