Class HashTableUtils
- java.lang.Object
-
- org.apache.druid.query.groupby.epinephelinae.collection.HashTableUtils
-
public class HashTableUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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".
-
-
-
Method Detail
-
previousPowerOfTwo
public static int previousPowerOfTwo(int n)
Computes the previous power of two less than or equal to a given "n". The integer should be between 1 (inclusive) andInteger.MAX_VALUE
for best results. Other parameters will returnInteger.MIN_VALUE
.
-
hashMemory
public static int hashMemory(org.apache.datasketches.memory.Memory memory, long position, int length)
Compute a simple, fast hash code of some memory range.- Parameters:
memory
- a region of memoryposition
- position within the memory regionlength
- length of memory to hash, starting at the position
-
memoryEquals
public 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. The purpose of this function is to be faster thanBaseState.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.- Parameters:
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 positions
-
-