HappenLee commented on code in PR #22059: URL: https://github.com/apache/doris/pull/22059#discussion_r1271473105
########## fe/be-java-extensions/java-udf/src/main/java/org/apache/doris/udf/UdfExecutor.java: ########## @@ -503,4 +573,78 @@ protected void init(TJavaUdfExecutorCtorParams request, String jarPath, Type fun throw new UdfRuntimeException("Unable to call create UDF instance.", e); } } + + public static class HashMapBuilder<keyType> { + public Object[] get(Object[] keyCol, Object[] valueCol, PrimitiveType valueType) { + switch (valueType) { + case BOOLEAN: { + return new BuildMapFromType<keyType, Boolean>().get(keyCol, valueCol); + } + case TINYINT: { + return new BuildMapFromType<keyType, Byte>().get(keyCol, valueCol); + } + case SMALLINT: { + return new BuildMapFromType<keyType, Short>().get(keyCol, valueCol); + } + case INT: { + return new BuildMapFromType<keyType, Integer>().get(keyCol, valueCol); + } + case BIGINT: { + return new BuildMapFromType<keyType, Long>().get(keyCol, valueCol); + } + case LARGEINT: { + return new BuildMapFromType<keyType, BigInteger>().get(keyCol, valueCol); + } + case FLOAT: { + return new BuildMapFromType<keyType, Float>().get(keyCol, valueCol); + } + case DOUBLE: { + return new BuildMapFromType<keyType, Double>().get(keyCol, valueCol); + } + case CHAR: + case VARCHAR: + case STRING: { + return new BuildMapFromType<keyType, String>().get(keyCol, valueCol); + } + case DATEV2: + case DATE: { + return new BuildMapFromType<keyType, LocalDate>().get(keyCol, valueCol); + } + case DATETIMEV2: + case DATETIME: { + return new BuildMapFromType<keyType, LocalDateTime>().get(keyCol, valueCol); + } + case DECIMAL32: + case DECIMAL64: + case DECIMALV2: + case DECIMAL128: { + return new BuildMapFromType<keyType, BigDecimal>().get(keyCol, valueCol); + } + default: { + LOG.info("Not support: " + valueType); + Preconditions.checkState(false, "Not support type " + valueType.toString()); + break; + } + } + return null; + } + } + + public static class BuildMapFromType<T1, T2> { + public Object[] get(Object[] keyCol, Object[] valueCol) { + Object[] retHashMap = new HashMap[keyCol.length]; + for (int colIdx = 0; colIdx < keyCol.length; colIdx++) { + HashMap<T1, T2> hashMap = new HashMap<>(); + ArrayList<T1> keys = (ArrayList<T1>) (keyCol[colIdx]); + ArrayList<T2> values = (ArrayList<T2>) (valueCol[colIdx]); + for (int i = 0; i < keys.size(); i++) { + T1 key = keys.get(i); + T2 value = values.get(i); + hashMap.put(key, value); Review Comment: keep the same as doris map if contain the key, just skip the put call `putIfAbsent` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org