public final class HashOperations extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
STRIDE_MASK
The stride mask for the Open Address, Double Hashing (OADH) hash table algorithm.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
checkHashCorruption(long hash) |
static void |
checkThetaCorruption(long thetaLong) |
static boolean |
continueCondition(long thetaLong,
long hash)
Return true (continue) if hash is greater than or equal to thetaLong, or if hash == 0,
or if hash == Long.MAX_VALUE.
|
static int |
count(long[] srcArr,
long thetaLong)
Counts the cardinality of the given source array.
|
static int |
countPart(long[] srcArr,
int lgArrLongs,
long thetaLong)
Counts the cardinality of the first Log2 values of the given source array.
|
static int |
fastHashInsertOnly(org.apache.datasketches.memory.WritableMemory wmem,
int lgArrLongs,
long hash,
int memOffsetBytes)
This is a classical Knuth-style Open Addressing, Double Hash insert scheme, but inserts
values directly into a Memory.
|
static int |
fastHashSearchOrInsert(org.apache.datasketches.memory.WritableMemory wmem,
int lgArrLongs,
long hash,
int memOffsetBytes)
This is a classical Knuth-style Open Addressing, Double Hash insert scheme, but inserts
values directly into a Memory.
|
static int |
hashArrayInsert(long[] srcArr,
long[] hashTable,
int lgArrLongs,
long thetaLong)
Inserts the given long array into the given hash table array of the target size,
removes any negative input values, ignores duplicates and counts the values inserted.
|
static int |
hashInsertOnly(long[] hashTable,
int lgArrLongs,
long hash)
This is a classical Knuth-style Open Addressing, Double Hash insert scheme for on-heap.
|
static int |
hashSearch(long[] hashTable,
int lgArrLongs,
long hash)
This is a classical Knuth-style Open Addressing, Double Hash search scheme for on-heap.
|
static int |
hashSearch(org.apache.datasketches.memory.Memory mem,
int lgArrLongs,
long hash,
int memOffsetBytes)
This is a classical Knuth-style Open Addressing, Double Hash search scheme for off-heap.
|
static int |
hashSearchOrInsert(long[] hashTable,
int lgArrLongs,
long hash)
This is a classical Knuth-style Open Addressing, Double Hash insert scheme for on-heap.
|
public static final int STRIDE_MASK
public static int countPart(long[] srcArr,
int lgArrLongs,
long thetaLong)
srcArr - the given source arraylgArrLongs - See lgArrLongsthetaLong - See Theta Longpublic static int count(long[] srcArr,
long thetaLong)
srcArr - the given source arraythetaLong - See Theta Longpublic static int hashSearch(long[] hashTable,
int lgArrLongs,
long hash)
hashTable - The hash table to search. Must be a power of 2 in size.lgArrLongs - See lgArrLongs.
lgArrLongs ≤ log2(hashTable.length).hash - A hash value to search for. Must not be zero.public static int hashInsertOnly(long[] hashTable,
int lgArrLongs,
long hash)
hashTable - the hash table to insert into.lgArrLongs - See lgArrLongs.
lgArrLongs ≤ log2(hashTable.length).hash - value that must not be zero and will be inserted into the array into an empty slot.public static int hashSearchOrInsert(long[] hashTable,
int lgArrLongs,
long hash)
hashTable - the hash table to insert into.lgArrLongs - See lgArrLongs.
lgArrLongs ≤ log2(hashTable.length).hash - hash value that must not be zero and if not a duplicate will be inserted into the
array into an empty slotpublic static int hashArrayInsert(long[] srcArr,
long[] hashTable,
int lgArrLongs,
long thetaLong)
srcArr - the source hash array to be potentially insertedhashTable - The correctly sized target hash table that must be a power of two.lgArrLongs - See lgArrLongs.
lgArrLongs ≤ log2(hashTable.length).thetaLong - must greater than zero
See Theta Longpublic static int hashSearch(org.apache.datasketches.memory.Memory mem,
int lgArrLongs,
long hash,
int memOffsetBytes)
mem - The Memory hash table to search.lgArrLongs - See lgArrLongs.
lgArrLongs ≤ log2(hashTable.length).hash - A hash value to search for. Must not be zero.memOffsetBytes - offset in the memory where the hash array startspublic static int fastHashInsertOnly(org.apache.datasketches.memory.WritableMemory wmem,
int lgArrLongs,
long hash,
int memOffsetBytes)
wmem - The writable memorylgArrLongs - See lgArrLongs.
lgArrLongs ≤ log2(hashTable.length).hash - value that must not be zero and will be inserted into the array into an empty slot.memOffsetBytes - offset in the memory where the hash array startspublic static int fastHashSearchOrInsert(org.apache.datasketches.memory.WritableMemory wmem,
int lgArrLongs,
long hash,
int memOffsetBytes)
wmem - the WritableMemorylgArrLongs - See lgArrLongs.
lgArrLongs ≤ log2(hashTable.length).hash - A hash value that must not be zero and if not a duplicate will be inserted into the
array into an empty slot.memOffsetBytes - offset in the memory where the hash array startspublic static void checkThetaCorruption(long thetaLong)
thetaLong - must be greater than zero otherwise throws an exception.
See Theta Longpublic static void checkHashCorruption(long hash)
hash - must be greater than -1 otherwise throws an exception.
Note a hash of zero is normally ignored, but a negative hash is never allowed.public static boolean continueCondition(long thetaLong,
long hash)
thetaLong - must be greater than the hash value
See Theta Longhash - must be less than thetaLong and not less than or equal to zero.Copyright © 2015–2020 The Apache Software Foundation. All rights reserved.