Skip to content

Commit

Permalink
fix hashtype
Browse files Browse the repository at this point in the history
  • Loading branch information
Baunsgaard committed Oct 21, 2024
1 parent 0432dcc commit 88c6bea
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/org/apache/sysds/common/Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ private static ValueType getHighestCommonTypeSwitch(ValueType a, ValueType b){
}
case FP64:
switch(b) {
case HASH64:
case HASH32:
return b;
case UNKNOWN:
return a;
case CHARACTER:
Expand All @@ -333,6 +336,9 @@ private static ValueType getHighestCommonTypeSwitch(ValueType a, ValueType b){
}
case FP32:
switch(b) {
case HASH64:
case HASH32:
return b;
case CHARACTER:
return STRING;
case STRING:
Expand All @@ -344,6 +350,9 @@ private static ValueType getHighestCommonTypeSwitch(ValueType a, ValueType b){
}
case INT64:
switch(b) {
case HASH64:
case HASH32:
return b;
case CHARACTER:
return STRING;
case STRING:
Expand All @@ -356,6 +365,9 @@ private static ValueType getHighestCommonTypeSwitch(ValueType a, ValueType b){
}
case INT32:
switch(b) {
case HASH64:
case HASH32:
return b;
case CHARACTER:
return STRING;
case STRING:
Expand Down Expand Up @@ -384,6 +396,9 @@ private static ValueType getHighestCommonTypeSwitch(ValueType a, ValueType b){
}
case UINT8:
switch(b) {
case HASH64:
case HASH32:
return b;
case CHARACTER:
return STRING;
case STRING:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.sysds.test.component.frame;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
Expand All @@ -30,6 +31,8 @@
import org.apache.sysds.common.Types.ValueType;
import org.apache.sysds.runtime.DMLRuntimeException;
import org.apache.sysds.runtime.frame.data.FrameBlock;
import org.apache.sysds.runtime.frame.data.columns.Array;
import org.apache.sysds.runtime.frame.data.columns.StringArray;
import org.apache.sysds.runtime.frame.data.lib.FrameLibAppend;
import org.apache.sysds.runtime.frame.data.lib.FrameLibDetectSchema;
import org.apache.sysds.runtime.matrix.data.MatrixBlock;
Expand Down Expand Up @@ -97,4 +100,23 @@ public void appendUniqueColNames(){
assertTrue(c.getColumnName(0).equals("Hi"));
assertTrue(c.getColumnName(1).equals("There"));
}


@Test
public void detectSchema(){
FrameBlock f = new FrameBlock(new Array[]{new StringArray(new String[]{"00000001", "e013af63"})});
assertEquals("HASH32", FrameLibDetectSchema.detectSchema(f, 1).get(0,0));
}

@Test
public void detectSchema2(){
FrameBlock f = new FrameBlock(new Array[]{new StringArray(new String[]{"10000001", "e013af63"})});
assertEquals("HASH32", FrameLibDetectSchema.detectSchema(f, 1).get(0,0));
}

@Test
public void detectSchema3(){
FrameBlock f = new FrameBlock(new Array[]{new StringArray(new String[]{"e013af63","10000001"})});
assertEquals("HASH32", FrameLibDetectSchema.detectSchema(f, 1).get(0,0));
}
}

0 comments on commit 88c6bea

Please sign in to comment.