You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by rx...@apache.org on 2013/11/18 03:42:28 UTC

[2/5] git commit: Return the vector itself for trim and resize method in PrimitiveVector.

Return the vector itself for trim and resize method in PrimitiveVector.


Project: http://git-wip-us.apache.org/repos/asf/incubator-spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spark/commit/16a2286d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spark/tree/16a2286d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spark/diff/16a2286d

Branch: refs/heads/master
Commit: 16a2286d6d0e692e0d2e2d568a3c72c053f5047a
Parents: c30979c
Author: Reynold Xin <rx...@apache.org>
Authored: Sun Nov 17 17:52:02 2013 -0800
Committer: Reynold Xin <rx...@apache.org>
Committed: Sun Nov 17 17:52:02 2013 -0800

----------------------------------------------------------------------
 .../org/apache/spark/util/collection/PrimitiveVector.scala    | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-spark/blob/16a2286d/core/src/main/scala/org/apache/spark/util/collection/PrimitiveVector.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/org/apache/spark/util/collection/PrimitiveVector.scala b/core/src/main/scala/org/apache/spark/util/collection/PrimitiveVector.scala
index 54a5569..b4fcc92 100644
--- a/core/src/main/scala/org/apache/spark/util/collection/PrimitiveVector.scala
+++ b/core/src/main/scala/org/apache/spark/util/collection/PrimitiveVector.scala
@@ -48,16 +48,17 @@ class PrimitiveVector[@specialized(Long, Int, Double) V: ClassManifest](initialS
 
   def size: Int = _numElements
 
-  /** Get the underlying array backing this vector. */
+  /** Gets the underlying array backing this vector. */
   def array: Array[V] = _array
 
   /** Trims this vector so that the capacity is equal to the size. */
-  def trim(): Unit = resize(size)
+  def trim(): PrimitiveVector[V] = resize(size)
 
   /** Resizes the array, dropping elements if the total length decreases. */
-  def resize(newLength: Int) {
+  def resize(newLength: Int): PrimitiveVector[V] = {
     val newArray = new Array[V](newLength)
     _array.copyToArray(newArray)
     _array = newArray
+    this
   }
 }