add fromVertices on VertexQueryParam.
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/7d18c65e Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/7d18c65e Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/7d18c65e Branch: refs/heads/master Commit: 7d18c65e7595ab8b55b0fcaef738634d56075e9a Parents: e911008 Author: DO YUNG YOON <steams...@apache.org> Authored: Thu Jun 21 05:17:40 2018 +0900 Committer: DO YUNG YOON <steams...@apache.org> Committed: Thu Jun 21 08:46:34 2018 +0900 ---------------------------------------------------------------------- .../scala/org/apache/s2graph/core/QueryParam.scala | 6 +++++- .../main/scala/org/apache/s2graph/core/S2Graph.scala | 4 ++++ .../scala/org/apache/s2graph/core/S2GraphLike.scala | 2 ++ .../s2graph/core/Integrate/VertexTestHelper.scala | 14 ++++++-------- 4 files changed, 17 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/7d18c65e/s2core/src/main/scala/org/apache/s2graph/core/QueryParam.scala ---------------------------------------------------------------------- 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 QueryParam { 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) } } http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/7d18c65e/s2core/src/main/scala/org/apache/s2graph/core/S2Graph.scala ---------------------------------------------------------------------- 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 @@ class S2Graph(_config: Config)(implicit val ec: ExecutionContext) extends S2Grap 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) => http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/7d18c65e/s2core/src/main/scala/org/apache/s2graph/core/S2GraphLike.scala ---------------------------------------------------------------------- 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 @@ trait S2GraphLike extends Graph { 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] http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/7d18c65e/s2core/src/test/scala/org/apache/s2graph/core/Integrate/VertexTestHelper.scala ---------------------------------------------------------------------- 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 @@ class VertexTestHelper extends IntegrateCommon { 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 @@ class VertexTestHelper extends IntegrateCommon { 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) }