You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "thejdeep (via GitHub)" <gi...@apache.org> on 2023/05/23 17:12:04 UTC

[GitHub] [spark] thejdeep commented on a diff in pull request #41017: [SPARK-43334] [UI] Fix error while serializing ExecutorPeakMetricsDistributions into API response

thejdeep commented on code in PR #41017:
URL: https://github.com/apache/spark/pull/41017#discussion_r1202733724


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -232,6 +232,18 @@ private[spark] object Utils extends Logging {
     // scalastyle:on classforname
   }
 
+  def getQuantilesValue(
+    values: IndexedSeq[Double],
+    quantiles: Array[Double]): IndexedSeq[Double] = {
+    val count = values.size
+    val indices = quantiles.map { q => math.min((q * count).toLong, count - 1) }

Review Comment:
   Addressed it, thanks.



##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -232,6 +232,18 @@ private[spark] object Utils extends Logging {
     // scalastyle:on classforname
   }
 
+  def getQuantilesValue(
+    values: IndexedSeq[Double],
+    quantiles: Array[Double]): IndexedSeq[Double] = {
+    val count = values.size
+    val indices = quantiles.map { q => math.min((q * count).toLong, count - 1) }
+    if (count > 0) {
+      indices.map(i => values(i.toInt)).toIndexedSeq
+    } else {
+      quantiles.map(_ => 0.0)

Review Comment:
   Thanks for the suggestion, addressed it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org