Repository: spark Updated Branches: refs/heads/branch-2.0 dae1581d9 -> c864e8a80
[SPARK-18200][GRAPHX][FOLLOW-UP] Support zero as an initial capacity in OpenHashSet ## What changes were proposed in this pull request? This is a follow-up PR of #15741 in order to keep `nextPowerOf2` consistent. **Before** ``` nextPowerOf2(0) => 2 nextPowerOf2(1) => 1 nextPowerOf2(2) => 2 nextPowerOf2(3) => 4 nextPowerOf2(4) => 4 nextPowerOf2(5) => 8 ``` **After** ``` nextPowerOf2(0) => 1 nextPowerOf2(1) => 1 nextPowerOf2(2) => 2 nextPowerOf2(3) => 4 nextPowerOf2(4) => 4 nextPowerOf2(5) => 8 ``` ## How was this patch tested? N/A Author: Dongjoon Hyun <dongj...@apache.org> Closes #15754 from dongjoon-hyun/SPARK-18200-2. (cherry picked from commit 27602c33751cebf6cd173c0de103454608cf6625) Signed-off-by: Reynold Xin <r...@databricks.com> Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/c864e8a8 Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/c864e8a8 Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/c864e8a8 Branch: refs/heads/branch-2.0 Commit: c864e8a8020f4890f1839766851e7f4917da5c70 Parents: dae1581 Author: Dongjoon Hyun <dongj...@apache.org> Authored: Thu Nov 3 23:15:33 2016 -0700 Committer: Reynold Xin <r...@databricks.com> Committed: Thu Nov 3 23:17:15 2016 -0700 ---------------------------------------------------------------------- .../main/scala/org/apache/spark/util/collection/OpenHashSet.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/c864e8a8/core/src/main/scala/org/apache/spark/util/collection/OpenHashSet.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/org/apache/spark/util/collection/OpenHashSet.scala b/core/src/main/scala/org/apache/spark/util/collection/OpenHashSet.scala index 7a1be85..60f6f53 100644 --- a/core/src/main/scala/org/apache/spark/util/collection/OpenHashSet.scala +++ b/core/src/main/scala/org/apache/spark/util/collection/OpenHashSet.scala @@ -272,7 +272,7 @@ class OpenHashSet[@specialized(Long, Int) T: ClassTag]( private def nextPowerOf2(n: Int): Int = { if (n == 0) { - 2 + 1 } else { val highBit = Integer.highestOneBit(n) if (highBit == n) n else highBit << 1 --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org