hvanhovell commented on code in PR #47921:
URL: https://github.com/apache/spark/pull/47921#discussion_r1735391204


##########
sql/api/src/main/scala/org/apache/spark/sql/Observation.scala:
##########
@@ -75,39 +81,42 @@ abstract class ObservationBase(val name: String) {
    * @throws InterruptedException interrupted while waiting
    */
   @throws[InterruptedException]
-  def getAsJava: java.util.Map[String, AnyRef] = {
-    get.map { case (key, value) => (key, value.asInstanceOf[Object]) }.asJava
-  }
+  def getAsJava: java.util.Map[String, Any] = get.asJava
 
   /**
    * Get the observed metrics. This returns the metrics if they are available, 
otherwise an empty.
    *
    * @return the observed metrics as a `Map[String, Any]`
    */
   @throws[InterruptedException]
-  private[sql] def getOrEmpty: Map[String, _] = {
-    synchronized {
-      if (metrics.isEmpty) {
-        wait(100) // Wait for 100ms to see if metrics are available
-      }
-      metrics.getOrElse(Map.empty)
-    }
+  private[sql] def getOrEmpty: Map[String, Any] = {
+    Try(SparkThreadUtils.awaitResult(future, 100.millis)).getOrElse(Map.empty)
   }
 
   /**
    * Set the observed metrics and notify all waiting threads to resume.
    *
    * @return `true` if all waiting threads were notified, `false` if otherwise.
    */
-  private[spark] def setMetricsAndNotify(metrics: Option[Map[String, Any]]): 
Boolean = {
-    synchronized {
-      this.metrics = metrics
-      if(metrics.isDefined) {
-        notifyAll()
-        true
-      } else {
-        false
-      }
-    }
+  private[spark] def setMetricsAndNotify(metrics: Row): Boolean = {
+    val metricsMap = metrics.getValuesMap(metrics.schema.map(_.name))

Review Comment:
   I am still wondering why this needed to be a map...



-- 
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: [email protected]

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