class PairRDDFunctions[K, V] extends Logging with Serializable
Extra functions available on RDDs of (key, value) pairs through an implicit conversion.
- Alphabetic
- By Inheritance
- PairRDDFunctions
- Serializable
- Serializable
- Logging
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
aggregateByKey[U](zeroValue: U)(seqOp: (U, V) ⇒ U, combOp: (U, U) ⇒ U)(implicit arg0: ClassTag[U]): RDD[(K, U)]
Aggregate the values of each key, using given combine functions and a neutral "zero value".
Aggregate the values of each key, using given combine functions and a neutral "zero value". This function can return a different result type, U, than the type of the values in this RDD, V. Thus, we need one operation for merging a V into a U and one operation for merging two U's, as in scala.TraversableOnce. The former operation is used for merging values within a partition, and the latter is used for merging values between partitions. To avoid memory allocation, both of these functions are allowed to modify and return their first argument instead of creating a new U.
-
def
aggregateByKey[U](zeroValue: U, numPartitions: Int)(seqOp: (U, V) ⇒ U, combOp: (U, U) ⇒ U)(implicit arg0: ClassTag[U]): RDD[(K, U)]
Aggregate the values of each key, using given combine functions and a neutral "zero value".
Aggregate the values of each key, using given combine functions and a neutral "zero value". This function can return a different result type, U, than the type of the values in this RDD, V. Thus, we need one operation for merging a V into a U and one operation for merging two U's, as in scala.TraversableOnce. The former operation is used for merging values within a partition, and the latter is used for merging values between partitions. To avoid memory allocation, both of these functions are allowed to modify and return their first argument instead of creating a new U.
-
def
aggregateByKey[U](zeroValue: U, partitioner: Partitioner)(seqOp: (U, V) ⇒ U, combOp: (U, U) ⇒ U)(implicit arg0: ClassTag[U]): RDD[(K, U)]
Aggregate the values of each key, using given combine functions and a neutral "zero value".
Aggregate the values of each key, using given combine functions and a neutral "zero value". This function can return a different result type, U, than the type of the values in this RDD, V. Thus, we need one operation for merging a V into a U and one operation for merging two U's, as in scala.TraversableOnce. The former operation is used for merging values within a partition, and the latter is used for merging values between partitions. To avoid memory allocation, both of these functions are allowed to modify and return their first argument instead of creating a new U.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
cogroup[W1, W2, W3](other1: RDD[(K, W1)], other2: RDD[(K, W2)], other3: RDD[(K, W3)], numPartitions: Int): RDD[(K, (Iterable[V], Iterable[W1], Iterable[W2], Iterable[W3]))]
For each key k in
this
orother1
orother2
orother3
, return a resulting RDD that contains a tuple with the list of values for that key inthis
,other1
,other2
andother3
. -
def
cogroup[W1, W2](other1: RDD[(K, W1)], other2: RDD[(K, W2)], numPartitions: Int): RDD[(K, (Iterable[V], Iterable[W1], Iterable[W2]))]
For each key k in
this
orother1
orother2
, return a resulting RDD that contains a tuple with the list of values for that key inthis
,other1
andother2
. -
def
cogroup[W](other: RDD[(K, W)], numPartitions: Int): RDD[(K, (Iterable[V], Iterable[W]))]
For each key k in
this
orother
, return a resulting RDD that contains a tuple with the list of values for that key inthis
as well asother
. -
def
cogroup[W1, W2](other1: RDD[(K, W1)], other2: RDD[(K, W2)]): RDD[(K, (Iterable[V], Iterable[W1], Iterable[W2]))]
For each key k in
this
orother1
orother2
, return a resulting RDD that contains a tuple with the list of values for that key inthis
,other1
andother2
. -
def
cogroup[W](other: RDD[(K, W)]): RDD[(K, (Iterable[V], Iterable[W]))]
For each key k in
this
orother
, return a resulting RDD that contains a tuple with the list of values for that key inthis
as well asother
. -
def
cogroup[W1, W2, W3](other1: RDD[(K, W1)], other2: RDD[(K, W2)], other3: RDD[(K, W3)]): RDD[(K, (Iterable[V], Iterable[W1], Iterable[W2], Iterable[W3]))]
For each key k in
this
orother1
orother2
orother3
, return a resulting RDD that contains a tuple with the list of values for that key inthis
,other1
,other2
andother3
. -
def
cogroup[W1, W2](other1: RDD[(K, W1)], other2: RDD[(K, W2)], partitioner: Partitioner): RDD[(K, (Iterable[V], Iterable[W1], Iterable[W2]))]
For each key k in
this
orother1
orother2
, return a resulting RDD that contains a tuple with the list of values for that key inthis
,other1
andother2
. -
def
cogroup[W](other: RDD[(K, W)], partitioner: Partitioner): RDD[(K, (Iterable[V], Iterable[W]))]
For each key k in
this
orother
, return a resulting RDD that contains a tuple with the list of values for that key inthis
as well asother
. -
def
cogroup[W1, W2, W3](other1: RDD[(K, W1)], other2: RDD[(K, W2)], other3: RDD[(K, W3)], partitioner: Partitioner): RDD[(K, (Iterable[V], Iterable[W1], Iterable[W2], Iterable[W3]))]
For each key k in
this
orother1
orother2
orother3
, return a resulting RDD that contains a tuple with the list of values for that key inthis
,other1
,other2
andother3
. -
def
collectAsMap(): Map[K, V]
Return the key-value pairs in this RDD to the master as a Map.
Return the key-value pairs in this RDD to the master as a Map.
Warning: this doesn't return a multimap (so if you have multiple values to the same key, only one value per key is preserved in the map returned)
- Note
this method should only be used if the resulting data is expected to be small, as all the data is loaded into the driver's memory.
-
def
combineByKey[C](createCombiner: (V) ⇒ C, mergeValue: (C, V) ⇒ C, mergeCombiners: (C, C) ⇒ C): RDD[(K, C)]
Simplified version of combineByKeyWithClassTag that hash-partitions the resulting RDD using the existing partitioner/parallelism level.
Simplified version of combineByKeyWithClassTag that hash-partitions the resulting RDD using the existing partitioner/parallelism level. This method is here for backward compatibility. It does not provide combiner classtag information to the shuffle.
- See also
combineByKeyWithClassTag
-
def
combineByKey[C](createCombiner: (V) ⇒ C, mergeValue: (C, V) ⇒ C, mergeCombiners: (C, C) ⇒ C, numPartitions: Int): RDD[(K, C)]
Simplified version of combineByKeyWithClassTag that hash-partitions the output RDD.
Simplified version of combineByKeyWithClassTag that hash-partitions the output RDD. This method is here for backward compatibility. It does not provide combiner classtag information to the shuffle.
- See also
combineByKeyWithClassTag
-
def
combineByKey[C](createCombiner: (V) ⇒ C, mergeValue: (C, V) ⇒ C, mergeCombiners: (C, C) ⇒ C, partitioner: Partitioner, mapSideCombine: Boolean = true, serializer: Serializer = null): RDD[(K, C)]
Generic function to combine the elements for each key using a custom set of aggregation functions.
Generic function to combine the elements for each key using a custom set of aggregation functions. This method is here for backward compatibility. It does not provide combiner classtag information to the shuffle.
- See also
combineByKeyWithClassTag
-
def
combineByKeyWithClassTag[C](createCombiner: (V) ⇒ C, mergeValue: (C, V) ⇒ C, mergeCombiners: (C, C) ⇒ C)(implicit ct: ClassTag[C]): RDD[(K, C)]
Simplified version of combineByKeyWithClassTag that hash-partitions the resulting RDD using the existing partitioner/parallelism level.
-
def
combineByKeyWithClassTag[C](createCombiner: (V) ⇒ C, mergeValue: (C, V) ⇒ C, mergeCombiners: (C, C) ⇒ C, numPartitions: Int)(implicit ct: ClassTag[C]): RDD[(K, C)]
Simplified version of combineByKeyWithClassTag that hash-partitions the output RDD.
-
def
combineByKeyWithClassTag[C](createCombiner: (V) ⇒ C, mergeValue: (C, V) ⇒ C, mergeCombiners: (C, C) ⇒ C, partitioner: Partitioner, mapSideCombine: Boolean = true, serializer: Serializer = null)(implicit ct: ClassTag[C]): RDD[(K, C)]
Generic function to combine the elements for each key using a custom set of aggregation functions.
Generic function to combine the elements for each key using a custom set of aggregation functions. Turns an RDD[(K, V)] into a result of type RDD[(K, C)], for a "combined type" C
Users provide three functions:
createCombiner
, which turns a V into a C (e.g., creates a one-element list)mergeValue
, to merge a V into a C (e.g., adds it to the end of a list)mergeCombiners
, to combine two C's into a single one.
In addition, users can control the partitioning of the output RDD, and whether to perform map-side aggregation (if a mapper can produce multiple items with the same key).
- Note
V and C can be different -- for example, one might group an RDD of type (Int, Int) into an RDD of type (Int, Seq[Int]).
-
def
countApproxDistinctByKey(relativeSD: Double = 0.05): RDD[(K, Long)]
Return approximate number of distinct values for each key in this RDD.
Return approximate number of distinct values for each key in this RDD.
The algorithm used is based on streamlib's implementation of "HyperLogLog in Practice: Algorithmic Engineering of a State of The Art Cardinality Estimation Algorithm", available here.
- relativeSD
Relative accuracy. Smaller values create counters that require more space. It must be greater than 0.000017.
-
def
countApproxDistinctByKey(relativeSD: Double, numPartitions: Int): RDD[(K, Long)]
Return approximate number of distinct values for each key in this RDD.
Return approximate number of distinct values for each key in this RDD.
The algorithm used is based on streamlib's implementation of "HyperLogLog in Practice: Algorithmic Engineering of a State of The Art Cardinality Estimation Algorithm", available here.
- relativeSD
Relative accuracy. Smaller values create counters that require more space. It must be greater than 0.000017.
- numPartitions
number of partitions of the resulting RDD
-
def
countApproxDistinctByKey(relativeSD: Double, partitioner: Partitioner): RDD[(K, Long)]
Return approximate number of distinct values for each key in this RDD.
Return approximate number of distinct values for each key in this RDD.
The algorithm used is based on streamlib's implementation of "HyperLogLog in Practice: Algorithmic Engineering of a State of The Art Cardinality Estimation Algorithm", available here.
- relativeSD
Relative accuracy. Smaller values create counters that require more space. It must be greater than 0.000017.
- partitioner
partitioner of the resulting RDD
-
def
countApproxDistinctByKey(p: Int, sp: Int, partitioner: Partitioner): RDD[(K, Long)]
Return approximate number of distinct values for each key in this RDD.
Return approximate number of distinct values for each key in this RDD.
The algorithm used is based on streamlib's implementation of "HyperLogLog in Practice: Algorithmic Engineering of a State of The Art Cardinality Estimation Algorithm", available here.
The relative accuracy is approximately
1.054 / sqrt(2^p)
. Setting a nonzero (
spis greater than
p) would trigger sparse representation of registers, which may reduce the memory consumption and increase accuracy when the cardinality is small.
- p
The precision value for the normal set.
p
must be a value between 4 andsp
ifsp
is not zero (32 max).- sp
The precision value for the sparse set, between 0 and 32. If
sp
equals 0, the sparse representation is skipped.- partitioner
Partitioner to use for the resulting RDD.
-
def
countByKey(): Map[K, Long]
Count the number of elements for each key, collecting the results to a local Map.
Count the number of elements for each key, collecting the results to a local Map.
- Note
This method should only be used if the resulting map is expected to be small, as the whole thing is loaded into the driver's memory. To handle very large results, consider using rdd.mapValues(_ => 1L).reduceByKey(_ + _), which returns an RDD[T, Long] instead of a map.
-
def
countByKeyApprox(timeout: Long, confidence: Double = 0.95): PartialResult[Map[K, BoundedDouble]]
Approximate version of countByKey that can return a partial result if it does not finish within a timeout.
Approximate version of countByKey that can return a partial result if it does not finish within a timeout.
The confidence is the probability that the error bounds of the result will contain the true value. That is, if countApprox were called repeatedly with confidence 0.9, we would expect 90% of the results to contain the true count. The confidence must be in the range [0,1] or an exception will be thrown.
- timeout
maximum time to wait for the job, in milliseconds
- confidence
the desired statistical confidence in the result
- returns
a potentially incomplete result, with error bounds
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
flatMapValues[U](f: (V) ⇒ TraversableOnce[U]): RDD[(K, U)]
Pass each value in the key-value pair RDD through a flatMap function without changing the keys; this also retains the original RDD's partitioning.
-
def
foldByKey(zeroValue: V)(func: (V, V) ⇒ V): RDD[(K, V)]
Merge the values for each key using an associative function and a neutral "zero value" which may be added to the result an arbitrary number of times, and must not change the result (e.g., Nil for list concatenation, 0 for addition, or 1 for multiplication.).
-
def
foldByKey(zeroValue: V, numPartitions: Int)(func: (V, V) ⇒ V): RDD[(K, V)]
Merge the values for each key using an associative function and a neutral "zero value" which may be added to the result an arbitrary number of times, and must not change the result (e.g., Nil for list concatenation, 0 for addition, or 1 for multiplication.).
-
def
foldByKey(zeroValue: V, partitioner: Partitioner)(func: (V, V) ⇒ V): RDD[(K, V)]
Merge the values for each key using an associative function and a neutral "zero value" which may be added to the result an arbitrary number of times, and must not change the result (e.g., Nil for list concatenation, 0 for addition, or 1 for multiplication.).
-
def
fullOuterJoin[W](other: RDD[(K, W)], numPartitions: Int): RDD[(K, (Option[V], Option[W]))]
Perform a full outer join of
this
andother
.Perform a full outer join of
this
andother
. For each element (k, v) inthis
, the resulting RDD will either contain all pairs (k, (Some(v), Some(w))) for w inother
, or the pair (k, (Some(v), None)) if no elements inother
have key k. Similarly, for each element (k, w) inother
, the resulting RDD will either contain all pairs (k, (Some(v), Some(w))) for v inthis
, or the pair (k, (None, Some(w))) if no elements inthis
have key k. Hash-partitions the resulting RDD into the given number of partitions. -
def
fullOuterJoin[W](other: RDD[(K, W)]): RDD[(K, (Option[V], Option[W]))]
Perform a full outer join of
this
andother
.Perform a full outer join of
this
andother
. For each element (k, v) inthis
, the resulting RDD will either contain all pairs (k, (Some(v), Some(w))) for w inother
, or the pair (k, (Some(v), None)) if no elements inother
have key k. Similarly, for each element (k, w) inother
, the resulting RDD will either contain all pairs (k, (Some(v), Some(w))) for v inthis
, or the pair (k, (None, Some(w))) if no elements inthis
have key k. Hash-partitions the resulting RDD using the existing partitioner/ parallelism level. -
def
fullOuterJoin[W](other: RDD[(K, W)], partitioner: Partitioner): RDD[(K, (Option[V], Option[W]))]
Perform a full outer join of
this
andother
.Perform a full outer join of
this
andother
. For each element (k, v) inthis
, the resulting RDD will either contain all pairs (k, (Some(v), Some(w))) for w inother
, or the pair (k, (Some(v), None)) if no elements inother
have key k. Similarly, for each element (k, w) inother
, the resulting RDD will either contain all pairs (k, (Some(v), Some(w))) for v inthis
, or the pair (k, (None, Some(w))) if no elements inthis
have key k. Uses the given Partitioner to partition the output RDD. -
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
groupByKey(): RDD[(K, Iterable[V])]
Group the values for each key in the RDD into a single sequence.
Group the values for each key in the RDD into a single sequence. Hash-partitions the resulting RDD with the existing partitioner/parallelism level. The ordering of elements within each group is not guaranteed, and may even differ each time the resulting RDD is evaluated.
- Note
This operation may be very expensive. If you are grouping in order to perform an aggregation (such as a sum or average) over each key, using
PairRDDFunctions.aggregateByKey
orPairRDDFunctions.reduceByKey
will provide much better performance.
-
def
groupByKey(numPartitions: Int): RDD[(K, Iterable[V])]
Group the values for each key in the RDD into a single sequence.
Group the values for each key in the RDD into a single sequence. Hash-partitions the resulting RDD with into
numPartitions
partitions. The ordering of elements within each group is not guaranteed, and may even differ each time the resulting RDD is evaluated.- Note
This operation may be very expensive. If you are grouping in order to perform an aggregation (such as a sum or average) over each key, using
,PairRDDFunctions.aggregateByKey
orPairRDDFunctions.reduceByKey
will provide much better performance.As currently implemented, groupByKey must be able to hold all the key-value pairs for any key in memory. If a key has too many values, it can result in an
OutOfMemoryError
.
-
def
groupByKey(partitioner: Partitioner): RDD[(K, Iterable[V])]
Group the values for each key in the RDD into a single sequence.
Group the values for each key in the RDD into a single sequence. Allows controlling the partitioning of the resulting key-value pair RDD by passing a Partitioner. The ordering of elements within each group is not guaranteed, and may even differ each time the resulting RDD is evaluated.
- Note
This operation may be very expensive. If you are grouping in order to perform an aggregation (such as a sum or average) over each key, using
,PairRDDFunctions.aggregateByKey
orPairRDDFunctions.reduceByKey
will provide much better performance.As currently implemented, groupByKey must be able to hold all the key-value pairs for any key in memory. If a key has too many values, it can result in an
OutOfMemoryError
.
-
def
groupWith[W1, W2, W3](other1: RDD[(K, W1)], other2: RDD[(K, W2)], other3: RDD[(K, W3)]): RDD[(K, (Iterable[V], Iterable[W1], Iterable[W2], Iterable[W3]))]
Alias for cogroup.
-
def
groupWith[W1, W2](other1: RDD[(K, W1)], other2: RDD[(K, W2)]): RDD[(K, (Iterable[V], Iterable[W1], Iterable[W2]))]
Alias for cogroup.
-
def
groupWith[W](other: RDD[(K, W)]): RDD[(K, (Iterable[V], Iterable[W]))]
Alias for cogroup.
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
- Attributes
- protected
- Definition Classes
- Logging
-
def
initializeLogIfNecessary(isInterpreter: Boolean): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isTraceEnabled(): Boolean
- Attributes
- protected
- Definition Classes
- Logging
-
def
join[W](other: RDD[(K, W)], numPartitions: Int): RDD[(K, (V, W))]
Return an RDD containing all pairs of elements with matching keys in
this
andother
.Return an RDD containing all pairs of elements with matching keys in
this
andother
. Each pair of elements will be returned as a (k, (v1, v2)) tuple, where (k, v1) is inthis
and (k, v2) is inother
. Performs a hash join across the cluster. -
def
join[W](other: RDD[(K, W)]): RDD[(K, (V, W))]
Return an RDD containing all pairs of elements with matching keys in
this
andother
.Return an RDD containing all pairs of elements with matching keys in
this
andother
. Each pair of elements will be returned as a (k, (v1, v2)) tuple, where (k, v1) is inthis
and (k, v2) is inother
. Performs a hash join across the cluster. -
def
join[W](other: RDD[(K, W)], partitioner: Partitioner): RDD[(K, (V, W))]
Return an RDD containing all pairs of elements with matching keys in
this
andother
.Return an RDD containing all pairs of elements with matching keys in
this
andother
. Each pair of elements will be returned as a (k, (v1, v2)) tuple, where (k, v1) is inthis
and (k, v2) is inother
. Uses the given Partitioner to partition the output RDD. -
def
keys: RDD[K]
Return an RDD with the keys of each tuple.
-
def
leftOuterJoin[W](other: RDD[(K, W)], numPartitions: Int): RDD[(K, (V, Option[W]))]
Perform a left outer join of
this
andother
.Perform a left outer join of
this
andother
. For each element (k, v) inthis
, the resulting RDD will either contain all pairs (k, (v, Some(w))) for w inother
, or the pair (k, (v, None)) if no elements inother
have key k. Hash-partitions the output intonumPartitions
partitions. -
def
leftOuterJoin[W](other: RDD[(K, W)]): RDD[(K, (V, Option[W]))]
Perform a left outer join of
this
andother
.Perform a left outer join of
this
andother
. For each element (k, v) inthis
, the resulting RDD will either contain all pairs (k, (v, Some(w))) for w inother
, or the pair (k, (v, None)) if no elements inother
have key k. Hash-partitions the output using the existing partitioner/parallelism level. -
def
leftOuterJoin[W](other: RDD[(K, W)], partitioner: Partitioner): RDD[(K, (V, Option[W]))]
Perform a left outer join of
this
andother
.Perform a left outer join of
this
andother
. For each element (k, v) inthis
, the resulting RDD will either contain all pairs (k, (v, Some(w))) for w inother
, or the pair (k, (v, None)) if no elements inother
have key k. Uses the given Partitioner to partition the output RDD. -
def
log: Logger
- Attributes
- protected
- Definition Classes
- Logging
-
def
logDebug(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logDebug(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logError(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logError(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logInfo(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logInfo(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logName: String
- Attributes
- protected
- Definition Classes
- Logging
-
def
logTrace(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logTrace(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logWarning(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logWarning(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
lookup(key: K): Seq[V]
Return the list of values in the RDD for key
key
.Return the list of values in the RDD for key
key
. This operation is done efficiently if the RDD has a known partitioner by only searching the partition that the key maps to. -
def
mapValues[U](f: (V) ⇒ U): RDD[(K, U)]
Pass each value in the key-value pair RDD through a map function without changing the keys; this also retains the original RDD's partitioning.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
partitionBy(partitioner: Partitioner): RDD[(K, V)]
Return a copy of the RDD partitioned using the specified partitioner.
-
def
reduceByKey(func: (V, V) ⇒ V): RDD[(K, V)]
Merge the values for each key using an associative and commutative reduce function.
Merge the values for each key using an associative and commutative reduce function. This will also perform the merging locally on each mapper before sending results to a reducer, similarly to a "combiner" in MapReduce. Output will be hash-partitioned with the existing partitioner/ parallelism level.
-
def
reduceByKey(func: (V, V) ⇒ V, numPartitions: Int): RDD[(K, V)]
Merge the values for each key using an associative and commutative reduce function.
Merge the values for each key using an associative and commutative reduce function. This will also perform the merging locally on each mapper before sending results to a reducer, similarly to a "combiner" in MapReduce. Output will be hash-partitioned with numPartitions partitions.
-
def
reduceByKey(partitioner: Partitioner, func: (V, V) ⇒ V): RDD[(K, V)]
Merge the values for each key using an associative and commutative reduce function.
Merge the values for each key using an associative and commutative reduce function. This will also perform the merging locally on each mapper before sending results to a reducer, similarly to a "combiner" in MapReduce.
-
def
reduceByKeyLocally(func: (V, V) ⇒ V): Map[K, V]
Merge the values for each key using an associative and commutative reduce function, but return the results immediately to the master as a Map.
Merge the values for each key using an associative and commutative reduce function, but return the results immediately to the master as a Map. This will also perform the merging locally on each mapper before sending results to a reducer, similarly to a "combiner" in MapReduce.
-
def
rightOuterJoin[W](other: RDD[(K, W)], numPartitions: Int): RDD[(K, (Option[V], W))]
Perform a right outer join of
this
andother
.Perform a right outer join of
this
andother
. For each element (k, w) inother
, the resulting RDD will either contain all pairs (k, (Some(v), w)) for v inthis
, or the pair (k, (None, w)) if no elements inthis
have key k. Hash-partitions the resulting RDD into the given number of partitions. -
def
rightOuterJoin[W](other: RDD[(K, W)]): RDD[(K, (Option[V], W))]
Perform a right outer join of
this
andother
.Perform a right outer join of
this
andother
. For each element (k, w) inother
, the resulting RDD will either contain all pairs (k, (Some(v), w)) for v inthis
, or the pair (k, (None, w)) if no elements inthis
have key k. Hash-partitions the resulting RDD using the existing partitioner/parallelism level. -
def
rightOuterJoin[W](other: RDD[(K, W)], partitioner: Partitioner): RDD[(K, (Option[V], W))]
Perform a right outer join of
this
andother
.Perform a right outer join of
this
andother
. For each element (k, w) inother
, the resulting RDD will either contain all pairs (k, (Some(v), w)) for v inthis
, or the pair (k, (None, w)) if no elements inthis
have key k. Uses the given Partitioner to partition the output RDD. -
def
sampleByKey(withReplacement: Boolean, fractions: Map[K, Double], seed: Long = Utils.random.nextLong): RDD[(K, V)]
Return a subset of this RDD sampled by key (via stratified sampling).
Return a subset of this RDD sampled by key (via stratified sampling).
Create a sample of this RDD using variable sampling rates for different keys as specified by
fractions
, a key to sampling rate map, via simple random sampling with one pass over the RDD, to produce a sample of size that's approximately equal to the sum of math.ceil(numItems * samplingRate) over all key values.- withReplacement
whether to sample with or without replacement
- fractions
map of specific keys to sampling rates
- seed
seed for the random number generator
- returns
RDD containing the sampled subset
-
def
sampleByKeyExact(withReplacement: Boolean, fractions: Map[K, Double], seed: Long = Utils.random.nextLong): RDD[(K, V)]
Return a subset of this RDD sampled by key (via stratified sampling) containing exactly math.ceil(numItems * samplingRate) for each stratum (group of pairs with the same key).
Return a subset of this RDD sampled by key (via stratified sampling) containing exactly math.ceil(numItems * samplingRate) for each stratum (group of pairs with the same key).
This method differs from sampleByKey in that we make additional passes over the RDD to create a sample size that's exactly equal to the sum of math.ceil(numItems * samplingRate) over all key values with a 99.99% confidence. When sampling without replacement, we need one additional pass over the RDD to guarantee sample size; when sampling with replacement, we need two additional passes.
- withReplacement
whether to sample with or without replacement
- fractions
map of specific keys to sampling rates
- seed
seed for the random number generator
- returns
RDD containing the sampled subset
-
def
saveAsHadoopDataset(conf: JobConf): Unit
Output the RDD to any Hadoop-supported storage system, using a Hadoop JobConf object for that storage system.
Output the RDD to any Hadoop-supported storage system, using a Hadoop JobConf object for that storage system. The JobConf should set an OutputFormat and any output paths required (e.g. a table name to write to) in the same way as it would be configured for a Hadoop MapReduce job.
-
def
saveAsHadoopFile(path: String, keyClass: Class[_], valueClass: Class[_], outputFormatClass: Class[_ <: OutputFormat[_, _]], conf: JobConf = ..., codec: Option[Class[_ <: CompressionCodec]] = None): Unit
Output the RDD to any Hadoop-supported file system, using a Hadoop
OutputFormat
class supporting the key and value types K and V in this RDD.Output the RDD to any Hadoop-supported file system, using a Hadoop
OutputFormat
class supporting the key and value types K and V in this RDD.- Note
We should make sure our tasks are idempotent when speculation is enabled, i.e. do not use output committer that writes data directly. There is an example in https://issues.apache.org/jira/browse/SPARK-10063 to show the bad result of using direct output committer with speculation enabled.
-
def
saveAsHadoopFile(path: String, keyClass: Class[_], valueClass: Class[_], outputFormatClass: Class[_ <: OutputFormat[_, _]], codec: Class[_ <: CompressionCodec]): Unit
Output the RDD to any Hadoop-supported file system, using a Hadoop
OutputFormat
class supporting the key and value types K and V in this RDD.Output the RDD to any Hadoop-supported file system, using a Hadoop
OutputFormat
class supporting the key and value types K and V in this RDD. Compress with the supplied codec. -
def
saveAsHadoopFile[F <: OutputFormat[K, V]](path: String, codec: Class[_ <: CompressionCodec])(implicit fm: ClassTag[F]): Unit
Output the RDD to any Hadoop-supported file system, using a Hadoop
OutputFormat
class supporting the key and value types K and V in this RDD.Output the RDD to any Hadoop-supported file system, using a Hadoop
OutputFormat
class supporting the key and value types K and V in this RDD. Compress the result with the supplied codec. -
def
saveAsHadoopFile[F <: OutputFormat[K, V]](path: String)(implicit fm: ClassTag[F]): Unit
Output the RDD to any Hadoop-supported file system, using a Hadoop
OutputFormat
class supporting the key and value types K and V in this RDD. -
def
saveAsNewAPIHadoopDataset(conf: Configuration): Unit
Output the RDD to any Hadoop-supported storage system with new Hadoop API, using a Hadoop Configuration object for that storage system.
Output the RDD to any Hadoop-supported storage system with new Hadoop API, using a Hadoop Configuration object for that storage system. The Conf should set an OutputFormat and any output paths required (e.g. a table name to write to) in the same way as it would be configured for a Hadoop MapReduce job.
- Note
We should make sure our tasks are idempotent when speculation is enabled, i.e. do not use output committer that writes data directly. There is an example in https://issues.apache.org/jira/browse/SPARK-10063 to show the bad result of using direct output committer with speculation enabled.
-
def
saveAsNewAPIHadoopFile(path: String, keyClass: Class[_], valueClass: Class[_], outputFormatClass: Class[_ <: OutputFormat[_, _]], conf: Configuration = self.context.hadoopConfiguration): Unit
Output the RDD to any Hadoop-supported file system, using a new Hadoop API
OutputFormat
(mapreduce.OutputFormat) object supporting the key and value types K and V in this RDD. -
def
saveAsNewAPIHadoopFile[F <: OutputFormat[K, V]](path: String)(implicit fm: ClassTag[F]): Unit
Output the RDD to any Hadoop-supported file system, using a new Hadoop API
OutputFormat
(mapreduce.OutputFormat) object supporting the key and value types K and V in this RDD. -
def
subtractByKey[W](other: RDD[(K, W)], p: Partitioner)(implicit arg0: ClassTag[W]): RDD[(K, V)]
Return an RDD with the pairs from
this
whose keys are not inother
. -
def
subtractByKey[W](other: RDD[(K, W)], numPartitions: Int)(implicit arg0: ClassTag[W]): RDD[(K, V)]
Return an RDD with the pairs from
this
whose keys are not inother
. -
def
subtractByKey[W](other: RDD[(K, W)])(implicit arg0: ClassTag[W]): RDD[(K, V)]
Return an RDD with the pairs from
this
whose keys are not inother
.Return an RDD with the pairs from
this
whose keys are not inother
.Uses
this
partitioner/partition size, because even ifother
is huge, the resulting RDD will be less than or equal to us. -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
values: RDD[V]
Return an RDD with the values of each tuple.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()