Some Spark Shell Commands | Spark Commands
73K views
Oct 24, 2024
Some Spark Shell Commands
View Video Transcript
0:00
In this video we are discussing some spark shell commands
0:04
We know that spark is having one interactive shell with a Scala prompt where you can issue
0:10
our commands to process our data. So let us go for some further discussion on it
0:17
What is the Spark shell? So the Apache Spark is with an interactive shell and it has a Scala prompt and in the
0:25
prompt we can run different commands to process our data. spark shell commands will be something like this. So here you have shown some set of very
0:34
important spark shell commands. So create a new RDD from the file. So one file is there containing
0:42
some data set from there we are going to create one RDD. So well text is equal to SC
0:48
dot text file and within this first bracket within the double quotes will be giving the file
0:54
path. Here the file path can be the SDFS file path or the local system file path
0:59
and this SC actually stands for spark context. So look at the syntax, well text is equal to sc.tects file method, passing this file path within double course as the input parameter
1:13
So here the SC is the spark context and in the file path we can provide local or HDFS files
1:21
Next one is that create a new RDD from the Scala collection
1:26
So we are going to create one adddd from the Scala collection. So here we require to issue two commands The first one well list data is equal to list Here we are having this list of data separated by commas And then well list RDD is equal to SC that is a spark
1:43
context, SC.c. Parallelize list data. So this list data will be used here. So now here
1:51
we are going to create a new RDD from the Scala collections. Now, count number of items in
1:59
RDD. The command will be RDD name dot count method. Next one is that filter operation in
2:06
RDD. So, here it will be written as val text is equal to SC dot text file and this is a
2:13
text file is a method. So, within first brackets, within double quotes, we are mentioning the
2:17
file path and then well, fill data is equal to text.com filter. Text dot filter line implies
2:24
line dot contents, you are passing one string there. And depending on
2:29
the string depending upon the matching the respective filtering will take place so it will
2:34
select those lines which contains a bc string now here we are going for this first item in
2:42
rddd the respective command will be text dot first method so in case of select first in items
2:49
we are going for the method take so text dot take n so n will be denoting the number of
2:56
items we are selecting from the first so in this In this way, we have shown you that what are the different spark shell commands which are
3:03
available in our spark environment for the execution in the interactive shell at the
3:09
Scala prompt. Thanks for watching this video
#Computer Education
#Java (Programming Language)
#Programming