From 588fa0d1af343fe76f66e21a09d9dee2f9fde776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cv=5Fkkhuang=E2=80=9D?= <“420895376@qq.com”> Date: Mon, 16 Dec 2024 16:30:18 +0800 Subject: [PATCH 1/4] Code Optimization --- .../linkis/ujes/jdbc/UJESSQLResultSet.scala | 30 +++++++++++-------- .../io/executor/IoEngineConnExecutor.scala | 5 +++- .../engineplugin/io/utils/IOHelp.scala | 18 +++++------ 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/linkis-computation-governance/linkis-jdbc-driver/src/main/scala/org/apache/linkis/ujes/jdbc/UJESSQLResultSet.scala b/linkis-computation-governance/linkis-jdbc-driver/src/main/scala/org/apache/linkis/ujes/jdbc/UJESSQLResultSet.scala index 37c379a7ca..7a3fdf0f7e 100644 --- a/linkis-computation-governance/linkis-jdbc-driver/src/main/scala/org/apache/linkis/ujes/jdbc/UJESSQLResultSet.scala +++ b/linkis-computation-governance/linkis-jdbc-driver/src/main/scala/org/apache/linkis/ujes/jdbc/UJESSQLResultSet.scala @@ -175,13 +175,23 @@ class UJESSQLResultSet( if (null == resultSetResult) { return } - metaData = resultSetResult.getMetadata.asInstanceOf[util.List[util.Map[String, String]]] - if (null != metaData) { - for (cursor <- 1 to metaData.size()) { - val col = metaData.get(cursor - 1) - resultSetMetaData.setColumnNameProperties(cursor, col.get("columnName")) - resultSetMetaData.setDataTypeProperties(cursor, col.get("dataType")) - resultSetMetaData.setCommentPropreties(cursor, col.get("comment")) + val metaTmp = resultSetResult.getMetadata + if (NULL_VALUE.equals(String.valueOf(metaTmp))) { + val fileContentList = resultSetResult.getFileContent.asInstanceOf[util.List[util.List[String]]] + if (null != fileContentList) { + resultSetMetaData.setColumnNameProperties(1, "linkis_string") + resultSetMetaData.setDataTypeProperties(1, "String") + resultSetMetaData.setCommentPropreties(1, NULL_VALUE) + } + } else { + metaData = metaTmp.asInstanceOf[util.List[util.Map[String, String]]] + if (null != metaData) { + for (cursor <- 1 to metaData.size()) { + val col = metaData.get(cursor - 1) + resultSetMetaData.setColumnNameProperties(cursor, col.get("columnName")) + resultSetMetaData.setDataTypeProperties(cursor, col.get("dataType")) + resultSetMetaData.setCommentPropreties(cursor, col.get("comment")) + } } } } @@ -194,12 +204,6 @@ class UJESSQLResultSet( resultSetResult.getFileContent.asInstanceOf[util.ArrayList[util.ArrayList[String]]] } - def getResultSet(): util.ArrayList[util.ArrayList[String]] = { - resultSetResultInit() - resultSetInit() - resultSetRow - } - private def init(): Unit = { resultSetResultInit() metaDataInit() diff --git a/linkis-engineconn-plugins/io_file/src/main/scala/org/apache/linkis/manager/engineplugin/io/executor/IoEngineConnExecutor.scala b/linkis-engineconn-plugins/io_file/src/main/scala/org/apache/linkis/manager/engineplugin/io/executor/IoEngineConnExecutor.scala index e8feb0d354..a9ec71ba00 100644 --- a/linkis-engineconn-plugins/io_file/src/main/scala/org/apache/linkis/manager/engineplugin/io/executor/IoEngineConnExecutor.scala +++ b/linkis-engineconn-plugins/io_file/src/main/scala/org/apache/linkis/manager/engineplugin/io/executor/IoEngineConnExecutor.scala @@ -60,6 +60,8 @@ import java.util.concurrent.atomic.AtomicLong import scala.collection.JavaConverters._ import scala.collection.mutable.ArrayBuffer +import com.google.gson.internal.LinkedTreeMap + class IoEngineConnExecutor(val id: Int, val outputLimit: Int = 10) extends ConcurrentComputationExecutor(outputLimit) with Logging { @@ -322,7 +324,8 @@ class IoEngineConnExecutor(val id: Int, val outputLimit: Int = 10) s"Creator ${methodEntity.creatorUser} for user ${methodEntity.proxyUser} init fs $methodEntity" ) var fsId = methodEntity.id - val properties = methodEntity.params(0).asInstanceOf[Map[String, String]] + val properties = + methodEntity.params(0).asInstanceOf[LinkedTreeMap[String, String]].asScala.toMap val proxyUser = methodEntity.proxyUser if (!fsProxyService.canProxyUser(methodEntity.creatorUser, proxyUser, methodEntity.fsType)) { throw new StorageErrorException( diff --git a/linkis-engineconn-plugins/io_file/src/main/scala/org/apache/linkis/manager/engineplugin/io/utils/IOHelp.scala b/linkis-engineconn-plugins/io_file/src/main/scala/org/apache/linkis/manager/engineplugin/io/utils/IOHelp.scala index b6f35a2e8e..8d84a1b0b0 100644 --- a/linkis-engineconn-plugins/io_file/src/main/scala/org/apache/linkis/manager/engineplugin/io/utils/IOHelp.scala +++ b/linkis-engineconn-plugins/io_file/src/main/scala/org/apache/linkis/manager/engineplugin/io/utils/IOHelp.scala @@ -61,21 +61,17 @@ object IOHelp { writer.addRecord(ioRecord) writer.toString() } else if (method.params.length == 3) { - val position = - if (method.params(1).toString.toInt < 0) { - 0 - } else { - method.params(1).toString.toInt - } + val parm1 = BigDecimal(method.params(1).toString).intValue() + val parm2 = BigDecimal(method.params(2).toString).intValue() + if (parm1 > 0) { + inputStream.skip(parm1) + } val fetchSize = - if (method.params(2).toString.toInt > maxPageSize) { + if (parm2 > maxPageSize) { maxPageSize.toInt } else { - method.params(2).toString.toInt + parm2 } - if (position > 0) { - inputStream.skip(position) - } val bytes = new Array[Byte](fetchSize) val len = StorageUtils.readBytes(inputStream, bytes, fetchSize) val ioMetaData = new IOMetaData(0, len) From 804adfa7a18ec8aa3dbe2d90bf6d19d133cea16f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cv=5Fkkhuang=E2=80=9D?= <“420895376@qq.com”> Date: Mon, 16 Dec 2024 17:38:19 +0800 Subject: [PATCH 2/4] Code Optimization --- .../manager/engineplugin/io/utils/IOHelp.scala | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/linkis-engineconn-plugins/io_file/src/main/scala/org/apache/linkis/manager/engineplugin/io/utils/IOHelp.scala b/linkis-engineconn-plugins/io_file/src/main/scala/org/apache/linkis/manager/engineplugin/io/utils/IOHelp.scala index 8d84a1b0b0..8734dd7191 100644 --- a/linkis-engineconn-plugins/io_file/src/main/scala/org/apache/linkis/manager/engineplugin/io/utils/IOHelp.scala +++ b/linkis-engineconn-plugins/io_file/src/main/scala/org/apache/linkis/manager/engineplugin/io/utils/IOHelp.scala @@ -61,17 +61,21 @@ object IOHelp { writer.addRecord(ioRecord) writer.toString() } else if (method.params.length == 3) { - val parm1 = BigDecimal(method.params(1).toString).intValue() - val parm2 = BigDecimal(method.params(2).toString).intValue() - if (parm1 > 0) { - inputStream.skip(parm1) - } + val position = + if (method.params(1).toString.toDouble.toInt < 0) { + 0 + } else { + method.params(1).toString.toDouble.toInt + } val fetchSize = - if (parm2 > maxPageSize) { + if (method.params(2).toString.toDouble.toInt > maxPageSize) { maxPageSize.toInt } else { - parm2 + method.params(2).toString.toDouble.toInt } + if (position > 0) { + inputStream.skip(position) + } val bytes = new Array[Byte](fetchSize) val len = StorageUtils.readBytes(inputStream, bytes, fetchSize) val ioMetaData = new IOMetaData(0, len) From 39011c41205fb4c5aad0e5cd15afa6c6d6496334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cv=5Fkkhuang=E2=80=9D?= <“420895376@qq.com”> Date: Tue, 24 Dec 2024 11:27:27 +0800 Subject: [PATCH 3/4] Code Optimization --- .../org/apache/linkis/manager/am/restful/EngineRestfulApi.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/restful/EngineRestfulApi.java b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/restful/EngineRestfulApi.java index 9041d3f4e4..3feca8c643 100644 --- a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/restful/EngineRestfulApi.java +++ b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/restful/EngineRestfulApi.java @@ -770,7 +770,8 @@ public Message killEngineByUpdateConfig(HttpServletRequest req, @RequestBody Jso && AMConfiguration.isUnAllowKilledEngineType(engineType)) { return Message.error("multi user engine does not support this feature(多用户引擎不支持此功能)"); } - if (engineType.equals(Configuration.GLOBAL_CONF_SYMBOL())) { + if (StringUtils.isNotBlank(engineType) + && engineType.equals(Configuration.GLOBAL_CONF_SYMBOL())) { Arrays.stream(AMConfiguration.UDF_KILL_ENGINE_TYPE.split(",")) .forEach( engine -> From f550f4978bcd6f3ae96f7585872c0f8b5b35521a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cv=5Fkkhuang=E2=80=9D?= <“420895376@qq.com”> Date: Tue, 24 Dec 2024 11:40:56 +0800 Subject: [PATCH 4/4] Code Optimization --- .../org/apache/linkis/manager/am/restful/EngineRestfulApi.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/restful/EngineRestfulApi.java b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/restful/EngineRestfulApi.java index 3feca8c643..1e118e0ee7 100644 --- a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/restful/EngineRestfulApi.java +++ b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/restful/EngineRestfulApi.java @@ -770,8 +770,7 @@ public Message killEngineByUpdateConfig(HttpServletRequest req, @RequestBody Jso && AMConfiguration.isUnAllowKilledEngineType(engineType)) { return Message.error("multi user engine does not support this feature(多用户引擎不支持此功能)"); } - if (StringUtils.isNotBlank(engineType) - && engineType.equals(Configuration.GLOBAL_CONF_SYMBOL())) { + if (Configuration.GLOBAL_CONF_SYMBOL().equals(engineType)) { Arrays.stream(AMConfiguration.UDF_KILL_ENGINE_TYPE.split(",")) .forEach( engine ->