Skip to content

Commit

Permalink
Merge pull request #2101 from square/py/hppc
Browse files Browse the repository at this point in the history
Fix typo in HPPC class name
  • Loading branch information
pyricau authored Mar 26, 2021
2 parents 6374c23 + fd9f1f2 commit 4a74e78
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.util.Locale
/**
* Code from https://github.com/carrotsearch/hppc copy pasted, inlined and converted to Kotlin.
*/
internal object HHPC {
internal object HPPC {

private const val PHI_C64 = -0x61c8864680b583ebL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ internal class LongLongScatterMap constructor(expectedElements: Int = 4) {
assigned = 0
hasEmptyKey = false

allocateBuffers(HHPC.minBufferSize(4, loadFactor))
allocateBuffers(HPPC.minBufferSize(4, loadFactor))
}

val size: Int
Expand All @@ -269,15 +269,15 @@ internal class LongLongScatterMap constructor(expectedElements: Int = 4) {
if (expectedElements > resizeAt) {
val prevKeys = this.keys
val prevValues = this.values
allocateBuffers(HHPC.minBufferSize(expectedElements, loadFactor))
allocateBuffers(HPPC.minBufferSize(expectedElements, loadFactor))
if (!isEmpty) {
rehash(prevKeys, prevValues)
}
}
}

private fun hashKey(key: Long): Int {
return HHPC.mixPhi(key)
return HPPC.mixPhi(key)
}

/**
Expand Down Expand Up @@ -336,7 +336,7 @@ internal class LongLongScatterMap constructor(expectedElements: Int = 4) {
)
}

this.resizeAt = HHPC.expandAtCount(arraySize, loadFactor)
this.resizeAt = HPPC.expandAtCount(arraySize, loadFactor)
this.mask = arraySize - 1
}

Expand All @@ -358,7 +358,7 @@ internal class LongLongScatterMap constructor(expectedElements: Int = 4) {
// Try to allocate new buffers first. If we OOM, we leave in a consistent state.
val prevKeys = this.keys
val prevValues = this.values
allocateBuffers(HHPC.nextBufferSize(mask + 1, size, loadFactor))
allocateBuffers(HPPC.nextBufferSize(mask + 1, size, loadFactor))

// We have succeeded at allocating new data so insert the pending key/value at
// the free slot in the old arrays before rehashing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ internal class LongObjectScatterMap<T> {
assigned = 0
hasEmptyKey = false

allocateBuffers(HHPC.minBufferSize(4, loadFactor))
allocateBuffers(HPPC.minBufferSize(4, loadFactor))
}

val size: Int
Expand All @@ -214,15 +214,15 @@ internal class LongObjectScatterMap<T> {
if (expectedElements > resizeAt) {
val prevKeys = this.keys
val prevValues = this.values
allocateBuffers(HHPC.minBufferSize(expectedElements, loadFactor))
allocateBuffers(HPPC.minBufferSize(expectedElements, loadFactor))
if (!isEmpty) {
rehash(prevKeys, prevValues)
}
}
}

private fun hashKey(key: Long): Int {
return HHPC.mixPhi(key)
return HPPC.mixPhi(key)
}

/**
Expand Down Expand Up @@ -282,7 +282,7 @@ internal class LongObjectScatterMap<T> {
)
}

this.resizeAt = HHPC.expandAtCount(arraySize, loadFactor)
this.resizeAt = HPPC.expandAtCount(arraySize, loadFactor)
this.mask = arraySize - 1
}

Expand All @@ -304,7 +304,7 @@ internal class LongObjectScatterMap<T> {
// Try to allocate new buffers first. If we OOM, we leave in a consistent state.
val prevKeys = this.keys
val prevValues = this.values
allocateBuffers(HHPC.nextBufferSize(mask + 1, size, loadFactor))
allocateBuffers(HPPC.nextBufferSize(mask + 1, size, loadFactor))

// We have succeeded at allocating new data so insert the pending key/value at
// the free slot in the old arrays before rehashing.
Expand Down
10 changes: 5 additions & 5 deletions shark-graph/src/main/java/shark/internal/hppc/LongScatterSet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal class LongScatterSet(expectedElements: Int = 4) {
}

private fun hashKey(key: Long): Int {
return HHPC.mixPhi(key)
return HPPC.mixPhi(key)
}

operator fun plusAssign(key: Long) {
Expand Down Expand Up @@ -174,13 +174,13 @@ internal class LongScatterSet(expectedElements: Int = 4) {
fun release() {
assigned = 0
hasEmptyKey = false
allocateBuffers(HHPC.minBufferSize(4, loadFactor))
allocateBuffers(HPPC.minBufferSize(4, loadFactor))
}

fun ensureCapacity(expectedElements: Int) {
if (expectedElements > resizeAt) {
val prevKeys = this.keys
allocateBuffers(HHPC.minBufferSize(expectedElements, loadFactor))
allocateBuffers(HPPC.minBufferSize(expectedElements, loadFactor))
if (size() != 0) {
rehash(prevKeys)
}
Expand Down Expand Up @@ -231,7 +231,7 @@ internal class LongScatterSet(expectedElements: Int = 4) {
)
}

this.resizeAt = HHPC.expandAtCount(arraySize, loadFactor)
this.resizeAt = HPPC.expandAtCount(arraySize, loadFactor)
this.mask = arraySize - 1
}

Expand All @@ -241,7 +241,7 @@ internal class LongScatterSet(expectedElements: Int = 4) {
) {
// Try to allocate new buffers first. If we OOM, we leave in a consistent state.
val prevKeys = this.keys
allocateBuffers(HHPC.nextBufferSize(mask + 1, size(), loadFactor))
allocateBuffers(HPPC.nextBufferSize(mask + 1, size(), loadFactor))

// We have succeeded at allocating new data so insert the pending key/value at
// the free slot in the old arrays before rehashing.
Expand Down
2 changes: 1 addition & 1 deletion shark-graph/src/test/java/shark/LongScatterSetTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package shark
import org.assertj.core.api.Assertions
import org.junit.Test
import shark.LongScatterSetAssertion.Companion.assertThat
import shark.internal.hppc.HHPC.mixPhi
import shark.internal.hppc.HPPC.mixPhi
import shark.internal.hppc.LongScatterSet

class LongScatterSetTest {
Expand Down

0 comments on commit 4a74e78

Please sign in to comment.