long hash family

git-svn-id: https://hyracks.googlecode.com/svn/branches/fullstack_genomix@2720 123451ca-8445-de46-9d55-352943316053
diff --git a/genomix/src/main/java/edu/uci/ics/genomix/data/std/accessors/LongBinaryHashFunctionFamily.java b/genomix/src/main/java/edu/uci/ics/genomix/data/std/accessors/LongBinaryHashFunctionFamily.java
new file mode 100644
index 0000000..9685dd1
--- /dev/null
+++ b/genomix/src/main/java/edu/uci/ics/genomix/data/std/accessors/LongBinaryHashFunctionFamily.java
@@ -0,0 +1,31 @@
+package edu.uci.ics.genomix.data.std.accessors;

+

+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;

+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFamily;

+import edu.uci.ics.hyracks.data.std.api.IHashable;

+import edu.uci.ics.hyracks.data.std.primitive.LongPointable;

+

+public class LongBinaryHashFunctionFamily implements

+		IBinaryHashFunctionFamily {

+	private static final long serialVersionUID = 1L;

+

+	@Override

+	public IBinaryHashFunction createBinaryHashFunction(final int seed) {

+

+		return new IBinaryHashFunction() {

+			private LongPointable p = new LongPointable();

+

+			@Override

+			public int hash(byte[] bytes, int offset, int length) {

+				if (length + offset >= bytes.length)

+					throw new IllegalStateException("out of bound");

+				p.set(bytes, offset, length);

+				int hash = Math.abs(((IHashable) p).hash() * (seed + 1));

+				if (hash < 0) {

+					hash = Math.abs(hash + 1);

+				}

+				return hash;

+			}

+		};

+	}

+}