Spark programming,

Source: Internet
Author: User

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 ()

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.