All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.javanut.pronghorn.pipe.util.hash.PipeHashTable Maven / Gradle / Ivy

Go to download

Ring buffer based queuing utility for applications that require high performance and/or a small footprint. Well suited for embedded and stream based processing.

There is a newer version: 1.1.27
Show newest version
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