@@ -21,15 +21,10 @@ object NebulaUtil {
2121 */
2222 def loadInitGraph (dataSet : Dataset [Row ], hasWeight : Boolean ): Graph [None .type , Double ] = {
2323 implicit val encoder : Encoder [Edge [Double ]] = org.apache.spark.sql.Encoders .kryo[Edge [Double ]]
24- val edges : RDD [Edge [Double ]] = dataSet
25- .map(row => {
26- if (hasWeight) {
27- Edge (row.get(0 ).toString.toLong, row.get(1 ).toString.toLong, row.get(2 ).toString.toDouble)
28- } else {
29- Edge (row.get(0 ).toString.toLong, row.get(1 ).toString.toLong, 1.0 )
30- }
31- })(encoder)
32- .rdd
24+ val edges : RDD [Edge [Double ]] = dataSet.map { row =>
25+ val attr = if (hasWeight) row.get(2 ).toString.toDouble else 1.0
26+ Edge (row.get(0 ).toString.toLong, row.get(1 ).toString.toLong, attr)
27+ }(encoder).rdd
3328
3429 Graph .fromEdges(edges, None )
3530 }
@@ -42,11 +37,7 @@ object NebulaUtil {
4237 *
4338 * @return validate result path
4439 */
45- def getResultPath (path : String , algorithmName : String ): String = {
46- var resultFilePath = path
47- if (! resultFilePath.endsWith(" /" )) {
48- resultFilePath = resultFilePath + " /"
49- }
50- resultFilePath + algorithmName
51- }
40+ def getResultPath (path : String , algorithmName : String ): String =
41+ if (path.endsWith(" /" )) s " $path$algorithmName"
42+ else s " $path/ $algorithmName"
5243}
0 commit comments