-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-24441][SS] Expose total estimated size of states in HDFSBackedStateStoreProvider #21469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
b620254
c9aada5
c4a6d11
a149ce5
36e5a12
5b203d4
32d0418
ed072fc
545081e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,8 @@ import org.apache.spark.annotation.InterfaceStability | |
| class StateOperatorProgress private[sql]( | ||
| val numRowsTotal: Long, | ||
| val numRowsUpdated: Long, | ||
| val memoryUsedBytes: Long | ||
| val memoryUsedBytes: Long, | ||
| val customMetrics: ju.Map[String, JLong] = new ju.HashMap() | ||
| ) extends Serializable { | ||
|
|
||
| /** The compact JSON representation of this progress. */ | ||
|
|
@@ -48,12 +49,24 @@ class StateOperatorProgress private[sql]( | |
| def prettyJson: String = pretty(render(jsonValue)) | ||
|
|
||
| private[sql] def copy(newNumRowsUpdated: Long): StateOperatorProgress = | ||
| new StateOperatorProgress(numRowsTotal, newNumRowsUpdated, memoryUsedBytes) | ||
| new StateOperatorProgress(numRowsTotal, newNumRowsUpdated, memoryUsedBytes, customMetrics) | ||
|
|
||
| private[sql] def jsonValue: JValue = { | ||
| ("numRowsTotal" -> JInt(numRowsTotal)) ~ | ||
| ("numRowsUpdated" -> JInt(numRowsUpdated)) ~ | ||
| ("memoryUsedBytes" -> JInt(memoryUsedBytes)) | ||
| def safeMapToJValue[T](map: ju.Map[String, T], valueToJValue: T => JValue): JValue = { | ||
|
||
| if (map.isEmpty) return JNothing | ||
| val keys = map.keySet.asScala.toSeq.sorted | ||
| keys.map { k => k -> valueToJValue(map.get(k)) : JObject }.reduce(_ ~ _) | ||
| } | ||
|
|
||
| val jsonVal = ("numRowsTotal" -> JInt(numRowsTotal)) ~ | ||
| ("numRowsUpdated" -> JInt(numRowsUpdated)) ~ | ||
| ("memoryUsedBytes" -> JInt(memoryUsedBytes)) | ||
|
|
||
| if (!customMetrics.isEmpty) { | ||
|
||
| jsonVal ~ ("customMetrics" -> safeMapToJValue[JLong](customMetrics, v => JInt(v.toLong))) | ||
| } else { | ||
| jsonVal | ||
| } | ||
| } | ||
|
|
||
| override def toString: String = prettyJson | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -231,7 +231,7 @@ class StreamingQueryListenerSuite extends StreamTest with BeforeAndAfter { | |
| test("event ordering") { | ||
| val listener = new EventCollector | ||
| withListenerAdded(listener) { | ||
| for (i <- 1 to 100) { | ||
| for (i <- 1 to 50) { | ||
|
||
| listener.reset() | ||
| require(listener.startEvent === null) | ||
| testStream(MemoryStream[Int].toDS)( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was to handle exception case while aggregating custom metrics, especially filtering out average since it is not aggregated correctly. Since we remove custom average metric, we no longer need to filter out them. Will revert the change as well as relevant logic.