simplify logic of normalization
git-svn-id: https://hyracks.googlecode.com/svn/branches/fullstack_genomix@3267 123451ca-8445-de46-9d55-352943316053
diff --git a/genomix/genomix-hyracks/src/main/java/edu/uci/ics/genomix/data/std/accessors/KmerHashPartitioncomputerFactory.java b/genomix/genomix-hyracks/src/main/java/edu/uci/ics/genomix/data/std/accessors/KmerHashPartitioncomputerFactory.java
index d136ef3..53eafaa 100644
--- a/genomix/genomix-hyracks/src/main/java/edu/uci/ics/genomix/data/std/accessors/KmerHashPartitioncomputerFactory.java
+++ b/genomix/genomix-hyracks/src/main/java/edu/uci/ics/genomix/data/std/accessors/KmerHashPartitioncomputerFactory.java
@@ -15,10 +15,9 @@
int hash = 1;
for (int i = offset; i < offset + length; i++)
hash = (31 * hash) + (int) bytes[i];
-
return hash;
}
-
+
@Override
public ITuplePartitionComputer createPartitioner() {
return new ITuplePartitionComputer() {
@@ -35,10 +34,12 @@
ByteBuffer buf = accessor.getBuffer();
- int hash = hashBytes(buf.array(), startOffset + fieldOffset + slotLength, fieldLength);
+ int hash = hashBytes(buf.array(), startOffset + fieldOffset
+ + slotLength, fieldLength);
if (hash < 0){
- hash = - (hash+1);
+ hash = (-hash+1);
}
+
return hash % nParts;
}
};
diff --git a/genomix/genomix-hyracks/src/main/java/edu/uci/ics/genomix/data/std/primitive/KmerPointable.java b/genomix/genomix-hyracks/src/main/java/edu/uci/ics/genomix/data/std/primitive/KmerPointable.java
index 675b589..ae07355 100644
--- a/genomix/genomix-hyracks/src/main/java/edu/uci/ics/genomix/data/std/primitive/KmerPointable.java
+++ b/genomix/genomix-hyracks/src/main/java/edu/uci/ics/genomix/data/std/primitive/KmerPointable.java
@@ -48,7 +48,7 @@
}
public static int getIntReverse(byte[] bytes, int offset, int length) {
- int shortValue = getShortReverse(bytes, offset, length);
+ int shortValue = getShortReverse(bytes, offset, length) & 0xffff;
if (length < 3) {
return shortValue;
@@ -65,7 +65,7 @@
public static long getLongReverse(byte[] bytes, int offset, int length) {
if (length < 8) {
- return getIntReverse(bytes, offset, length);
+ return ((long) getIntReverse(bytes, offset, length)) & 0x0ffffffffL;
}
return (((long) (bytes[offset + length - 1] & 0xff)) << 56)
+ (((long) (bytes[offset + length - 2] & 0xff)) << 48)
@@ -74,7 +74,7 @@
+ (((long) (bytes[offset + length - 5] & 0xff)) << 24)
+ (((long) (bytes[offset + length - 6] & 0xff)) << 16)
+ (((long) (bytes[offset + length - 7] & 0xff)) << 8)
- + (((long) (bytes[offset + length - 8] & 0xff)) << 0);
+ + (((long) (bytes[offset + length - 8] & 0xff)));
}
@Override
@@ -89,24 +89,13 @@
if (this.length != length) {
return this.length - length;
}
-
- // Why have we write so much ?
- // We need to follow the normalized key and it's usage
- int bNormKey = getIntReverse(this.bytes, this.start, this.length);
- int mNormKey = getIntReverse(bytes, offset, length);
- int cmp = bNormKey - mNormKey;
- if ( cmp != 0){
- return ((((long) bNormKey) & 0xffffffffL) < (((long) mNormKey) & 0xffffffffL)) ? -1
- : 1;
- }
-
- for (int i = length - 5; i >= 0; i--) {
- if (this.bytes[this.start + i] < bytes[offset + i]) {
- return -1;
- } else if (this.bytes[this.start + i] > bytes[offset + i]) {
- return 1;
+ for (int i = length - 1; i >= 0; i--) {
+ int cmp = (this.bytes[this.start + i] & 0xff) - (bytes[offset + i] & 0xff);
+ if (cmp !=0){
+ return cmp;
}
}
+
return 0;
}
diff --git a/genomix/genomix-hyracks/src/test/java/edu/uci/ics/genomix/example/jobrun/JobRunTest.java b/genomix/genomix-hyracks/src/test/java/edu/uci/ics/genomix/example/jobrun/JobRunTest.java
index 4eb7b9f..3e80ab7 100644
--- a/genomix/genomix-hyracks/src/test/java/edu/uci/ics/genomix/example/jobrun/JobRunTest.java
+++ b/genomix/genomix-hyracks/src/test/java/edu/uci/ics/genomix/example/jobrun/JobRunTest.java
@@ -145,7 +145,7 @@
public void TestHybridGroupby() throws Exception {
conf.set(GenomixJob.GROUPBY_TYPE, "hybrid");
- conf.set(GenomixJob.OUTPUT_FORMAT, "text");
+ conf.set(GenomixJob.OUTPUT_FORMAT, "binary");
System.err.println("Testing HybridGroupBy");
driver.runJob(new GenomixJob(conf), Plan.BUILD_DEBRUJIN_GRAPH, true);
Assert.assertEquals(true, checkResults());