From 1a73a64b197035aea1b2ff9c4329a3f39886fb84 Mon Sep 17 00:00:00 2001 From: denon1 Date: Sat, 1 Apr 2023 11:52:15 +0200 Subject: [PATCH] change if to match --- .../scalding/ClusterEvaluation.scala | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/scala/com/twitter/simclusters_v2/scalding/ClusterEvaluation.scala b/src/scala/com/twitter/simclusters_v2/scalding/ClusterEvaluation.scala index 7133382eb..6fae82c62 100644 --- a/src/scala/com/twitter/simclusters_v2/scalding/ClusterEvaluation.scala +++ b/src/scala/com/twitter/simclusters_v2/scalding/ClusterEvaluation.scala @@ -90,21 +90,14 @@ object ClusterEvaluation { val resultsIter = membersAdjLists.flatMap { case (fromNodeId, adjList) => val fromNodeWt = memberScores.getOrElse(fromNodeId, 0.0) - adjList.map { - case (toNodeId, edgeWt) => - if (memberScores.contains(toNodeId)) { - val productOfMembershipScores = fromNodeWt * memberScores(toNodeId) - ClusterResults( - 1, - edgeWt, - 0, - 0, - samplerMonoid.build( - ((fromNodeId, toNodeId), (edgeWt.toDouble, productOfMembershipScores)))) - } else { - ClusterResults(0, 0, 1, edgeWt, samplerMonoid.zero) - } - } + adjList.map(ad => ad match { + case (toNodeId,edgeWt) if (!memberScores.contains(toNodeId)) => + ClusterResults(0, 0, 1, edgeWt, samplerMonoid.zero) + case (toNodeId,edgeWt) => + val productOfMembershipScores = fromNodeWt * memberScores(toNodeId) + val sampler = samplerMonoid.build((fromNodeId, toNodeId), (edgeWt.toDouble, productOfMembershipScores)) + ClusterResults(1, edgeWt, 0, 0, sampler) + }) } Monoid.sum(resultsIter)(ClusterResultsMonoid) }