Skip to content

Commit

Permalink
Code Optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
“v_kkhuang” committed Dec 16, 2024
1 parent 398b171 commit 588fa0d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
}
}
}
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 588fa0d

Please sign in to comment.