Google News
logo
Spark - Interview Questions
Please explain the sparse vector in Spark.
A sparse vector is used for storing non-zero entries for saving space. It has two parallel arrays :
 
* One for indices
* The other for values

An example of a sparse vector is as follows :
Vectors.sparse(7,Array(0,1,2,3,4,5,6),Array(1650d,50000d,800d,3.0,3.0,2009,95054))
Advertisement