Skip to content

Commit

Permalink
[SPARK-18200][GRAPHX][FOLLOW-UP] Support zero as an initial capacity …
Browse files Browse the repository at this point in the history
…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 <[email protected]>

Closes #15754 from dongjoon-hyun/SPARK-18200-2.
  • Loading branch information
dongjoon-hyun authored and rxin committed Nov 4, 2016
1 parent a08463b commit 27602c3
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 27602c3

Please sign in to comment.