@@ -21,15 +21,10 @@ object NebulaUtil {
21
21
*/
22
22
def loadInitGraph (dataSet : Dataset [Row ], hasWeight : Boolean ): Graph [None .type , Double ] = {
23
23
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
33
28
34
29
Graph .fromEdges(edges, None )
35
30
}
@@ -42,11 +37,7 @@ object NebulaUtil {
42
37
*
43
38
* @return validate result path
44
39
*/
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"
52
43
}
0 commit comments