Big Data Technologies (Spark & Scala) (CO4) : Apex Institute of Technology. Ait-Ibm Cse
Big Data Technologies (Spark & Scala) (CO4) : Apex Institute of Technology. Ait-Ibm Cse
AIT-IBM CSE
CHANDIGARH UNIVERSITY, MOHALI
The students shall be able to familiarize with various data clustering and
dimension reduction techniques
Books
• Sr No Title of the Book Author Name Volume/Edition Publish
Hours Years
• 1 The Art of Data Science Roger Peng 3rd lulu.com 2016
• 2 Scala CookBook Alvin Alexander 2 nd Edition O'reilly 2008
• Reference Books
• P. Simon, ," Too Big to Ignore: The Business Case for Big Data”, Wiley
India, 2013
OTHER LINKS
• https://developer.ibm.com/predictiveanalytics/videos/category/tutori
als/
• https://www.ibm.com/developerworks/library/ba-predictive-analytics
1/index.html
Array In Scala
Declaring Array Variables
Declaring Array Variables-
To use an array in a program, you must declare a variable
to reference the array and you must specify the type of
array the variable can reference.
The following is the syntax for declaring an array
variable.
Syntax-
var z:Array[String] = new Array[String](3)
or
var z = new Array[String](3)
• Here, z is declared as an array of Strings that
may hold up to three elements.
Values can be assigned to individual elements
or get access to individual elements.
It can be done by using commands like the
following −
z(0) = "Zara"; z(1) = "Neha"; z(2) = "Aryan“
Here, the last example shows that in general
the index can be any expression that yields a
whole number. There is one more way of
defining an array −
var z = Array("Zara", "Neha", "Aryan")
Another way to print Array
If you are not going to give value to array then
it will take it’s data type’s default value.
Another example by taking string data type
In simple way concatenation
Another Example of Concatinate method
Processing Arrays
When processing array elements, we often use loop control
structures because all of the elements in an array are of the same
type and the size of the array is known.
OUTPUT:
Create Array with Range:
• Use of range() method to generate an array containing a
sequence of increasing integers in a given range. You can use
final argument as step to create the sequence; if you do not
use final argument, then step would be assumed as 1.
• Let us take an example of creating an array of range (10, 20,
2): It means creating an array with elements between 10 and
20 and range difference 2. Elements in the array are 10, 12,
14, 16, and 18.
• Another example: range (10, 20). Here range difference is not
given so by default it assumes 1 element. It create an array
with the elements in between 10 and 20 with range difference
1. Elements in the array are 10, 11, 12, 13, …, and 19.
Multi-Dimensional
Arrays
• There are many situations where you would need to define
and use multi-dimensional arrays (i.e., arrays whose
elements are arrays).
• For example, matrices and tables are examples of
structures that can be realized as two-dimensional arrays.
• The following is the example of defining a two-dimensional
array −
• var myMatrix = ofDim[Int](3,3)
• This is an array that has three elements each being an
array of integers that has three elements.
Example