janekdb commented on a change in pull request #29082:
URL: https://github.com/apache/spark/pull/29082#discussion_r525554422



##########
File path: core/src/main/scala/org/apache/spark/status/AppStatusStore.scala
##########
@@ -429,6 +429,37 @@ private[spark] class AppStatusStore(
     constructTaskDataList(taskDataWrapperIter)
   }
 
+  def failureSummary(stageId: Int, attemptId: Int): Seq[v1.FailureSummary] = {
+    val (stageData, _) = stageAttempt(stageId, attemptId)
+    val key = Array(stageId, attemptId)
+    asOption(store.read(classOf[CachedFailureSummary], key))
+      .find(p => p.failedTaskCount == stageData.numFailedTasks)
+      .map(_.failureSummary)
+      .getOrElse {
+        val failureSummary = computeFailureSummary(stageId, attemptId)
+        val cachedFailureSummary = new CachedFailureSummary(
+          stageId,
+          attemptId,
+          stageData.numFailedTasks,
+          failureSummary
+        )
+
+        store.write(cachedFailureSummary)
+        failureSummary
+      }
+  }
+
+  def computeFailureSummary(stageId: Int, attemptId: Int): 
Seq[v1.FailureSummary] = {
+    val tasks = taskList(stageId, attemptId, Int.MaxValue)
+    tasks.filter(t => t.status.equalsIgnoreCase("failed"))
+      .flatMap(t => t.failureReason)
+      .groupBy(e => (e.failureType, e.message))

Review comment:
       Drop use of tuple component accessors by using `values` on the grouped 
items?
   
   ```
   .groupBy(e => (e.failureType, e.message))
   .values
   .map(t => new v1.FailureSummary(t.head, t.length))
   ```




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to