From 88c6beac44b44e6cec48596bae799f9718c4ad3c Mon Sep 17 00:00:00 2001 From: Sebastian Baunsgaard Date: Mon, 21 Oct 2024 13:28:32 +0200 Subject: [PATCH] fix hashtype --- .../java/org/apache/sysds/common/Types.java | 15 +++++++++++++ .../test/component/frame/FrameCustomTest.java | 22 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/main/java/org/apache/sysds/common/Types.java b/src/main/java/org/apache/sysds/common/Types.java index e7274b25c4c..a6f7719733d 100644 --- a/src/main/java/org/apache/sysds/common/Types.java +++ b/src/main/java/org/apache/sysds/common/Types.java @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: diff --git a/src/test/java/org/apache/sysds/test/component/frame/FrameCustomTest.java b/src/test/java/org/apache/sysds/test/component/frame/FrameCustomTest.java index 047b2da3b25..3af635a3189 100644 --- a/src/test/java/org/apache/sysds/test/component/frame/FrameCustomTest.java +++ b/src/test/java/org/apache/sysds/test/component/frame/FrameCustomTest.java @@ -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; @@ -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; @@ -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)); + } }