From 36be72b7a58bd2320dacc07e92be1ef80c40764a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E7=87=83?= Date: Tue, 13 Jun 2023 16:51:45 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=8E=BB=E6=8E=89=20DecodeUtil=20?= =?UTF-8?q?=E4=B8=AD=E5=BC=95=E5=85=A5=E7=9A=84=E4=B8=8D=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20degree=5Fstatic=20=E7=AE=97=E6=B3=95=20encodeId=20=E7=9A=84?= =?UTF-8?q?=E4=BC=A0=E5=8F=82=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/scala/com/vesoft/nebula/algorithm/Main.scala | 3 +-- .../nebula/algorithm/lib/DegreeStaticAlgo.scala | 3 +-- .../vesoft/nebula/algorithm/utils/DecodeUtil.scala | 11 ----------- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/Main.scala b/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/Main.scala index ca52319..3d7aaa4 100644 --- a/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/Main.scala +++ b/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/Main.scala @@ -172,8 +172,7 @@ object Main { ShortestPathAlgo(spark, dataSet, spConfig, hasWeight) } case "degreestatic" => { - val encodeId = configs.algorithmConfig.map.get("algorithm.degreestatic.encodeId") - val config = if (encodeId.getOrElse("").equals("true")) DegreeStaticConfig(true) else DegreeStaticConfig() + val config = DegreeStaticConfig.getDegreeStaticConfig(configs) DegreeStaticAlgo(spark, dataSet, config) } case "kcore" => { diff --git a/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/lib/DegreeStaticAlgo.scala b/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/lib/DegreeStaticAlgo.scala index 99c4667..7721ecc 100644 --- a/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/lib/DegreeStaticAlgo.scala +++ b/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/lib/DegreeStaticAlgo.scala @@ -48,8 +48,7 @@ object DegreeStaticAlgo { .createDataFrame(degreeResultRDD, schema) if (degreeConfig.encodeId) { - val resultDF = DecodeUtil.convertEncodeId2StringId(algoResult, encodeIdDf) - resultDF + DecodeUtil.convertAlgoId2StringId(algoResult, encodeIdDf) } else { algoResult } diff --git a/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/utils/DecodeUtil.scala b/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/utils/DecodeUtil.scala index 4f0f807..f540240 100644 --- a/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/utils/DecodeUtil.scala +++ b/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/utils/DecodeUtil.scala @@ -53,17 +53,6 @@ object DecodeUtil { (encodeDataframe, encodeId) } - def convertEncodeId2StringId(dataframe: DataFrame, encodeId: DataFrame): DataFrame = { - val resultDF = dataframe - .join(encodeId) - .where(col(ALGO_ID_COL) === col(ENCODE_ID_COL)) - .drop(ALGO_ID_COL) - .drop(ENCODE_ID_COL) - .withColumnRenamed(ORIGIN_ID_COL, ALGO_ID_COL) - resultDF.show() - resultDF - } - def convertAlgoId2StringId(dataframe: DataFrame, encodeId: DataFrame): DataFrame = { encodeId .join(dataframe)