com.javanut.pronghorn.pipe.util.hash.PipeHashTable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pronghorn-pipes Show documentation
Show all versions of pronghorn-pipes Show documentation
Ring buffer based queuing utility for applications that require high performance and/or a small
footprint. Well suited for embedded and stream based processing.
package com.javanut.pronghorn.pipe.util.hash;
/**
* Lower bound range limited value hash table
*
* This hash table is used for direct index into values found in a pipe.
* When the lower bound is raised then values are no longer found in the pipe for use.
*
* @author Nathan Tippy
*
*/
public class PipeHashTable {
private final int mask;
private final long[] keys;
private final long[] values;
private int space;
private long lowerBounds;
public PipeHashTable(int bits) {
int size = 1<>63);
}
public static boolean hasItem(PipeHashTable ht, long key) {
int mask = ht.mask;
int hash = MurmurHash.hash64finalizer(key);
long keyAtIdx = ht.keys[hash&mask];
while (keyAtIdx != key && keyAtIdx != 0) {
keyAtIdx = ht.keys[++hash&mask];
}
long value = ht.values[hash&mask];
return 0 != (value&((ht.lowerBounds-(1+value))>>63));
}
public static void visit(PipeHashTable ht, PipeHashTableVisitor visitor) {
int j = ht.mask+1;
while (--j>=0) {
long key = ht.keys[j];
if (0!=key) {
long value = ht.values[j];
if (value >= ht.lowerBounds) {
visitor.visit(key, value);
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy