Repository: incubator-s2graph Updated Branches: refs/heads/master 444696634 -> b769d7ce9
[S2GRAPH-11] Performance tuning on sort by scoreSum on PostProcess remove JsNumber.as[Double] on sortBy in PostProcess. JIRA: [S2GRAPH-11] https://issues.apache.org/jira/browse/S2GRAPH-11 Pull Request: Closes #5 Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/b769d7ce Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/b769d7ce Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/b769d7ce Branch: refs/heads/master Commit: b769d7ce9a8193bd20a6827ba08e7b295fa064d9 Parents: 4446966 Author: DO YUNG YOON <[email protected]> Authored: Tue Feb 23 15:09:20 2016 +0900 Committer: DO YUNG YOON <[email protected]> Committed: Tue Feb 23 15:09:20 2016 +0900 ---------------------------------------------------------------------- CHANGES | 2 ++ .../src/main/scala/com/kakao/s2graph/core/PostProcess.scala | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/b769d7ce/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 2785fc0..f0d2f8d 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,8 @@ Release 0.12.1 - unreleased S2GRAPH-24: Add counter config for readonly graph (Committed by Jaesang Kim). + S2GRAPH-11: Performance tuning on sort by scoreSum on PostProcess (Committed by DOYUNG YOON). + BUG FIXES TASKS http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/b769d7ce/s2core/src/main/scala/com/kakao/s2graph/core/PostProcess.scala ---------------------------------------------------------------------- diff --git a/s2core/src/main/scala/com/kakao/s2graph/core/PostProcess.scala b/s2core/src/main/scala/com/kakao/s2graph/core/PostProcess.scala index 56d8591..b51397b 100644 --- a/s2core/src/main/scala/com/kakao/s2graph/core/PostProcess.scala +++ b/s2core/src/main/scala/com/kakao/s2graph/core/PostProcess.scala @@ -257,24 +257,25 @@ object PostProcess extends JSONParser { } yield column -> value } - val groupedEdges = { + val groupedEdgesWithScoreSum = { for { (groupByKeyVals, groupedRawEdges) <- grouped } yield { val scoreSum = groupedRawEdges.map(x => x._2).sum // ordering val edges = orderBy(query, orderByColumns, groupedRawEdges).map(_._1) - Json.obj( + val js = Json.obj( "groupBy" -> Json.toJson(groupByKeyVals.toMap), "scoreSum" -> scoreSum, "agg" -> edges ) + (js, scoreSum) } } - val groupedSortedJsons = groupedEdges.toList.sortBy { jsVal => -1 * (jsVal \ "scoreSum").as[Double] } + val groupedSortedJsons = groupedEdgesWithScoreSum.toList.sortBy { case (jsVal, scoreSum) => scoreSum * -1 }.map(_._1) Json.obj( - "size" -> groupedEdges.size, + "size" -> groupedSortedJsons.size, "degrees" -> degrees, "results" -> groupedSortedJsons, "impressionId" -> query.impressionId()
