提问参考模版:
-
nebula 版本:2.0.1
-
部署方式(分布式 / 单机 / Docker / DBaaS):分布式
-
是否为线上版本:Y
-
问题的具体描述
因为find shortest path 没有点属性过滤,想尝试用GraphX 中的ShortestPath, 想咨询这个方法可以实现点过滤的需求吗?
我看这个源码并没有相关的参数
object ShortestPathAlgo {
private val LOGGER = Logger.getLogger(this.getClass)
val ALGORITHM: String = "ShortestPath"
/**
* run the ShortestPath algorithm for nebula graph
*/
def apply(spark: SparkSession,
dataset: Dataset[Row],
shortestPathConfig: ShortestPathConfig,
hasWeight: Boolean): DataFrame = {
val graph: Graph[None.type, Double] = NebulaUtil.loadInitGraph(dataset, hasWeight)
val prResultRDD = execute(graph, shortestPathConfig.landmarks)
val schema = StructType(
List(
StructField(AlgoConstants.ALGO_ID_COL, LongType, nullable = false),
StructField(AlgoConstants.SHORTPATH_RESULT_COL, StringType, nullable = true)
))
val algoResult = spark.sqlContext
.createDataFrame(prResultRDD, schema)
algoResult
}
def execute(graph: Graph[None.type, Double], landmarks: Seq[VertexId]): RDD[Row] = {
val spResultRDD: VertexRDD[SPMap] = ShortestPaths.run(graph, landmarks).vertices
spResultRDD.map(row => Row(row._1, row._2.toString()))
}
}