Skip to content

Commit f8cfb54

Browse files
committed
address comments
1 parent 2235967 commit f8cfb54

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

core/src/main/scala/org/apache/spark/status/AppStatusStore.scala

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import org.apache.spark.{JobExecutionStatus, SparkConf}
2525
import org.apache.spark.status.api.v1
2626
import org.apache.spark.ui.scope._
2727
import org.apache.spark.util.{Distribution, Utils}
28-
import org.apache.spark.util.kvstore.{InMemoryStore, KVStore, LevelDB}
28+
import org.apache.spark.util.kvstore.{InMemoryStore, KVStore}
2929

3030
/**
3131
* A wrapper around a KVStore that provides methods for accessing the API data stored within.
@@ -148,18 +148,18 @@ private[spark] class AppStatusStore(
148148
// cheaper for disk stores (avoids deserialization).
149149
val count = {
150150
Utils.tryWithResource(
151-
if (store.isInstanceOf[LevelDB]) {
151+
if (store.isInstanceOf[InMemoryStore]) {
152152
store.view(classOf[TaskDataWrapper])
153153
.parent(stageKey)
154-
.index(TaskIndexNames.EXEC_RUN_TIME)
155-
.first(0L)
154+
.index(TaskIndexNames.STATUS)
155+
.first("SUCCESS")
156+
.last("SUCCESS")
156157
.closeableIterator()
157158
} else {
158159
store.view(classOf[TaskDataWrapper])
159160
.parent(stageKey)
160-
.index(TaskIndexNames.STATUS)
161-
.first("SUCCESS")
162-
.last("SUCCESS")
161+
.index(TaskIndexNames.EXEC_RUN_TIME)
162+
.first(0L)
163163
.closeableIterator()
164164
}
165165
) { it =>
@@ -230,14 +230,26 @@ private[spark] class AppStatusStore(
230230
// stabilize once the stage finishes. It's also slow, especially with disk stores.
231231
val indices = quantiles.map { q => math.min((q * count).toLong, count - 1) }
232232

233-
// TODO Summary metrics needs to display all the successful tasks' metrics (SPARK-26119).
233+
// TODO: Summary metrics needs to display all the successful tasks' metrics (SPARK-26119).
234234
// For InMemory case, it is efficient to find using the following code. But for diskStore case
235235
// we need an efficient solution to avoid deserialization time overhead. For that, we need to
236236
// rework on the way indexing works, so that we can index by specific metrics for successful
237237
// and failed tasks differently (would be tricky). Also would require changing the disk store
238238
// version (to invalidate old stores).
239239
def scanTasks(index: String)(fn: TaskDataWrapper => Long): IndexedSeq[Double] = {
240-
if (store.isInstanceOf[LevelDB]) {
240+
if (store.isInstanceOf[InMemoryStore]) {
241+
val quantileTasks = store.view(classOf[TaskDataWrapper])
242+
.parent(stageKey)
243+
.index(index)
244+
.first(0L)
245+
.asScala
246+
.filter { _.status == "SUCCESS"} // Filter "SUCCESS" tasks
247+
.toIndexedSeq
248+
249+
indices.map { index =>
250+
fn(quantileTasks(index.toInt)).toDouble
251+
}.toIndexedSeq
252+
} else {
241253
Utils.tryWithResource(
242254
store.view(classOf[TaskDataWrapper])
243255
.parent(stageKey)
@@ -262,18 +274,6 @@ private[spark] class AppStatusStore(
262274
}
263275
}.toIndexedSeq
264276
}
265-
} else {
266-
val quantileTasks = store.view(classOf[TaskDataWrapper])
267-
.parent(stageKey)
268-
.index(index)
269-
.first(0L)
270-
.asScala
271-
.filter { _.status == "SUCCESS"} // Filter "SUCCESS" tasks
272-
.toIndexedSeq
273-
274-
indices.map { index =>
275-
fn(quantileTasks(index.toInt)).toDouble
276-
}.toIndexedSeq
277277
}
278278
}
279279

core/src/test/scala/org/apache/spark/status/AppStatusStoreSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class AppStatusStoreSuite extends SparkFunSuite {
7979

8080
test("only successfull task have taskSummary") {
8181
val store = new InMemoryStore()
82-
(0 until 5).foreach { i => store.write(newTaskData(i, "FAILED")) }
82+
(0 until 5).foreach { i => store.write(newTaskData(i, status = "FAILED")) }
8383
val appStore = new AppStatusStore(store).taskSummary(stageId, attemptId, uiQuantiles)
8484
assert(appStore.size === 0)
8585
}

0 commit comments

Comments
 (0)