public class HashTableUtils extends Object
Modifier and Type | Method and Description |
---|---|
static int |
hashMemory(org.apache.datasketches.memory.Memory memory,
long position,
int length)
Compute a simple, fast hash code of some memory range.
|
static boolean |
memoryEquals(org.apache.datasketches.memory.Memory memory1,
long offset1,
org.apache.datasketches.memory.Memory memory2,
long offset2,
int length)
Compare two memory ranges for equality.
|
static int |
previousPowerOfTwo(int n)
Computes the previous power of two less than or equal to a given "n".
|
public static int previousPowerOfTwo(int n)
Integer.MAX_VALUE
for best results. Other parameters will
return Integer.MIN_VALUE
.public static int hashMemory(org.apache.datasketches.memory.Memory memory, long position, int length)
memory
- a region of memoryposition
- position within the memory regionlength
- length of memory to hash, starting at the positionpublic static boolean memoryEquals(org.apache.datasketches.memory.Memory memory1, long offset1, org.apache.datasketches.memory.Memory memory2, long offset2, int length)
BaseState.equalTo(long, java.lang.Object, long, long)
for the small memory ranges that
typically comprise keys in hash tables. As of this writing, it is. See "MemoryBenchmark" in the druid-benchmarks
module for performance evaluation code.memory1
- a region of memoryoffset1
- position within the first memory regionmemory2
- another region of memoryoffset2
- position within the second memory regionlength
- length of memory to compare, starting at the positionsCopyright © 2011–2023 The Apache Software Foundation. All rights reserved.