Briefly, MLlib's Vector and the concrete subclasses DenseVector and SparkVector wrap Java arrays, which are mutable and maximize memory efficiency. To update one of these vectors, you mutate the elements of the underlying array. That's great for performance, but dangerous in multithreaded programs for all the usual reasons. Scala's Vector is a *persistent data structure* (best to google that term...), with O(1) operations, but a higher constant factor. Scala Vector instances are immutable, so mutating operations return a new Vector, but the "persistent" implementation uses structure sharing (the unchanged parts) to make efficient copies.
Also, Scala Vector isn't designed to represent sparse vectors. dean Dean Wampler, Ph.D. Author: Programming Scala, 2nd Edition <http://shop.oreilly.com/product/0636920033073.do> (O'Reilly) Typesafe <http://typesafe.com> @deanwampler <http://twitter.com/deanwampler> http://polyglotprogramming.com On Sat, Oct 4, 2014 at 1:44 AM, ll <[email protected]> wrote: > what are the pros/cons of each? when should we use mllib Vector, and when > to > use standard scala Vector? thanks. > > > > -- > View this message in context: > http://apache-spark-user-list.1001560.n3.nabble.com/scala-Vector-vs-mllib-Vector-tp15736.html > Sent from the Apache Spark User List mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
