add fromVertices on VertexQueryParam.
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala b/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
index 5fdd3ee..9b0100e 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala
@@ -296,8 +296,12 @@
object VertexQueryParam {
def Empty: VertexQueryParam = VertexQueryParam(Nil)
+ def fromVertices(vertices: Seq[S2VertexLike]): VertexQueryParam = {
+ apply(vertices.map(_.id))
+ }
+
def apply(vertexIds: Seq[VertexId]): VertexQueryParam = {
- VertexQueryParam(vertexIds)
+ new VertexQueryParam(vertexIds)
}
}
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
index f3010f7..95793c8 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala
@@ -343,6 +343,10 @@
else matchedVerticesFuture
}
+ override def getVertices(vertices: Seq[S2VertexLike]): Future[Seq[S2VertexLike]] =
+ getVertices(VertexQueryParam.fromVertices(vertices))
+
+
override def getVertices(queryParam: VertexQueryParam): Future[Seq[S2VertexLike]] = {
val vertexIdsWithIdx = queryParam.vertexIds.zipWithIndex
val futures = vertexIdsWithIdx.groupBy { case (vId, idx) => vId.column }.map { case (serviceColumn, vertexGroup) =>
diff --git a/s2core/src/main/scala/org/apache/s2graph/core/S2GraphLike.scala b/s2core/src/main/scala/org/apache/s2graph/core/S2GraphLike.scala
index cab866d..629d429 100644
--- a/s2core/src/main/scala/org/apache/s2graph/core/S2GraphLike.scala
+++ b/s2core/src/main/scala/org/apache/s2graph/core/S2GraphLike.scala
@@ -110,6 +110,8 @@
def shutdown(modelDataDelete: Boolean = false): Unit
+ def getVertices(vertices: Seq[S2VertexLike]): Future[Seq[S2VertexLike]]
+
def getVertices(queryParam: VertexQueryParam): Future[Seq[S2VertexLike]]
def checkEdges(edges: Seq[S2EdgeLike]): Future[StepResult]
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/Integrate/VertexTestHelper.scala b/s2core/src/test/scala/org/apache/s2graph/core/Integrate/VertexTestHelper.scala
index c4136ab..6bb6b2e 100644
--- a/s2core/src/test/scala/org/apache/s2graph/core/Integrate/VertexTestHelper.scala
+++ b/s2core/src/test/scala/org/apache/s2graph/core/Integrate/VertexTestHelper.scala
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -43,11 +43,10 @@
val vertices = parser.toVertices(payload, "insert", Option(serviceName), Option(columnName))
val srcVertices = vertices
- val srcVertexIds = srcVertices.map(_.id)
- val queryParam = VertexQueryParam(vertexIds = srcVertexIds)
+
Await.result(graph.mutateVertices(srcVertices, withWait = true), HttpRequestWaitingTime)
- val res = graph.getVertices(queryParam).map { vertices =>
+ val res = graph.getVertices(srcVertices).map { vertices =>
PostProcess.verticesToJson(vertices)
}
@@ -72,11 +71,10 @@
val vertices = parser.toVertices(payload, "insert", Option(serviceName),
Option(stringColumnName))
val srcVertices = vertices
- val srcVertexIds = srcVertices.map(_.id)
- val queryParam = VertexQueryParam(vertexIds = srcVertexIds)
+
Await.result(graph.mutateVertices(srcVertices, withWait = true), HttpRequestWaitingTime)
- val res = graph.getVertices(queryParam).map { vertices =>
+ val res = graph.getVertices(srcVertices).map { vertices =>
PostProcess.verticesToJson(vertices)
}