Apache Spark چیست؟

چرا اسپارک؟
دلیل اول:

دلیل دوم:

اما:

تاریخچه اسپارک:

MapReduce چیست؟
MapReduce is a programming model and an associated implementation for processing and generating big data sets with a parallel, distributed algorithm on a cluster.
A MapReduce program is composed of a map procedure, which performs filtering and sorting, and a reduce method, which performs a summary operation.

زیرمجموعه های اسپارک:

زبانهای رایج در اسپارک:

SparkContext
اولین کار ایجاد یک شی sparkcontext است که به اسپارک میگوید چگونه به کلاستر دسترسی داشته باشد.

RDD
مجموعه داده های توزیع شده انعطاف پذیر

توضیحات بیشتر:

قابلیت های RDD:

دو عملیات در RDD:
- Transformations:
If an operation on an RDD gives you another RDD,
then it is a transformation.
- Actions
map
In a map transformation there is one-to-one mapping between
elements of the source RDD and the target RDD
برای مثال افزایش یک واحدی مقادیر در شکل زیر

filter
With a filter transformation, the function is executed on all the
elements of the source RDD and only those elements, for which the
function returns true, are selected to form the target RDD.
مثال مقادیری که باقیمانده آن بر 2 صفر شود.

flatMap
In flatMap() transformation, an element of source RDD can be
mapped to one or more elements of target RDD.
مپ شدن به یک یا بیش از یک المنت در RDD

MapToPair
It is similar to map transformation; however, this transformation
produces PairRDD, that is, an RDD consisting of key and value pairs.
مشابه با map است با این تفاوت که خروجی عملیات ما جفت (key- value ) است.

FlatMapToPair
• It is similar to flatMap(), however, the target RDD is a type of PairRDD,
that is, an RDD consisting of key and value Pairs. Like mapToPair(), this
operation is also specific to JavaRDDs.
مشابه flatmap است و همچنین key و value نیز داریم.!!!

union
As the name suggests, this transformation unites two RDDs into one.
The target consists of all the elements of source RDDs
تبدیل دوRDD به یک RDD

Intersection
• It produces an intersection of the elements of source RDDs, that is,
the target RDD consists of the elements that are identical in source
RDDs.
پیدا کردن مواردی که سورس RDD آنها همسان باشد.

distinct
the distinct operation will return an RDD by fetching all the distinct
elements of a source RDD
چیزی شبیه به مقادیر unique در پایتون

Cartesian
• Cartesian transformation generates a cartesian product of two RDDs
انجام ضرب کارتزین

GroupByKey


تا ص 24
ReduceByKey

SortByKey

join

- مشابه عملیات join در دیتابیس
Cogroup

تبدیل دو RDD به یک RDD
انواع transformation
- narrow
- Wide
نوعNarrow:

نوع Wide :
