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/05 02:54:16 UTC

[02/12] git commit: Fix weird bug with specialized PrimitiveVector

Fix weird bug with specialized 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/7d44dec9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spark/tree/7d44dec9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spark/diff/7d44dec9

Branch: refs/heads/master
Commit: 7d44dec9bd7c4bbfb8daf4843a0968797e009bea
Parents: 7453f31
Author: Aaron Davidson <aa...@databricks.com>
Authored: Fri Nov 1 21:04:09 2013 -0700
Committer: Aaron Davidson <aa...@databricks.com>
Committed: Sun Nov 3 21:34:43 2013 -0800

----------------------------------------------------------------------
 .../org/apache/spark/util/collection/PrimitiveVector.scala     | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-spark/blob/7d44dec9/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 721f12b..369519c 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
@@ -21,7 +21,11 @@ package org.apache.spark.util.collection
 private[spark]
 class PrimitiveVector[@specialized(Long, Int, Double) V: ClassManifest](initialSize: Int = 64) {
   private var numElements = 0
-  private var array = new Array[V](initialSize)
+  private var array: Array[V] = _
+
+  // NB: This must be separate from the declaration, otherwise the specialized parent class
+  // will get its own array with the same initial size. TODO: Figure out why...
+  array = new Array[V](initialSize)
 
   def apply(index: Int): V = {
     require(index < numElements)