Spark programming,
Persist (): cache data in the heap space of JVM in serialized form;
Cache (): Same as calling persist () at the default storage level;
Collect (): You can use collect () only when your entire dataset can be stored in the memory of a single machine. Therefore, collect () cannot be used in large-scale datasets; filter RDD to a small scale and you want to process the data locally;
Conversion operation:
Map ()
Filter ()
FlatMap ()
Distinct ()
Union ()
Intersection () requires data Mixing
Subtract () requires data Mixing
Cartesian () cartesian Product
Action:
The reduce () and fold () Methods Operate on the RDD of data of the same element type, that is, they must be homogeneous. The Return Value Returns a new element of the same type;
Fold () is similar to reduce (). It receives the same function as the function signature received by reduce, and adds an initial value to the result of the first call;
Aggregate () can aggregate two different types of elements, that is, it supports heterogeneous;
Take () returns n elements in RDD and tries to access as few partitions as possible. Therefore, this operation will get an unbalanced set;
Top () uses the default sequence of data, but we can also provide our own comparison functions to extract the first few elements;
TakeSample (withReplacement, num, seed) allows us to get a sample from the data and specify whether to replace it.
Key-value pair operation:
Performancebykey (): merges the same key;
FoldByKey ():
CombineByKey (): Aggregation Based on keys;
MapValues (): Apply a function to each value;
FlatMapValues (): applies a function that returns the iterator to each value;
Keys () values ()
SubtractByKey (): Delete the elements with the same key as the other RDD key in the RDD;
SortByKey (): returns an rdd sorted by the key;
PartitionBy ():
Repartition (): Wash data through the network and create a new partition set;
Coalesce (): optimized version of repartiton ()
GroupByKey (): groups based on whether the keys are the same;
GroupBy (): it can be used for unpaired data or grouping based on conditions other than the same key;
Cogroup (): groups data with the same key in two RDDs. It can be applied to three or more RDDs. The value types do not have to be the same;
Join () rightOuterJoin () leftOuterJoin ()
CollectAsMap ()