Skip to content

Commit

Permalink
✨ 去掉 DecodeUtil 中引入的不必要转换逻辑,优化 degree_static 算法 encodeId 的传参逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
陈燃 committed Jun 13, 2023
1 parent dc1df9f commit 36be72b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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" => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 36be72b

Please sign in to comment.