Skip to content

Commit 67d9396

Browse files
authored
fix data structure for nebula datasource (#30)
1 parent 9c9c6d0 commit 67d9396

File tree

1 file changed

+10
-1
lines changed
  • nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/reader

1 file changed

+10
-1
lines changed

nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/reader/DataReader.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,17 @@ class NebulaReader(spark: SparkSession, configs: Configs, partitionNum: String)
5050
.build()
5151
if (dataset == null) {
5252
dataset = spark.read.nebula(config, nebulaReadEdgeConfig).loadEdgesToDF()
53+
if (weights.nonEmpty) {
54+
dataset = dataset.select("_srcId", "_dstId", weights(i))
55+
}
5356
} else {
54-
dataset = dataset.union(spark.read.nebula(config, nebulaReadEdgeConfig).loadEdgesToDF())
57+
var df = spark.read
58+
.nebula(config, nebulaReadEdgeConfig)
59+
.loadEdgesToDF()
60+
if (weights.nonEmpty) {
61+
df = df.select("_srcId", "_dstId", weights(i))
62+
}
63+
dataset = dataset.union(df)
5564
}
5665
}
5766
dataset

0 commit comments

Comments
 (0)