Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21078#discussion_r183514966
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/util/Instrumentation.scala ---
    @@ -157,34 +161,55 @@ private[spark] object Instrumentation {
     
     }
     
    -private[spark] class OptionalInstrument private (
    -    val instrument: Option[Instrumentation[_ <: Estimator[_]]],
    +/**
    + * A small wrapper that contains an optional `Instrumentation` object.
    + * Provide some log methods, if the containing `Instrumentation` object is 
defined,
    + * will log via it, otherwise will log via common logger.
    + */
    +private[spark] class OptionalInstrumentation private(
    +    val instrumentation: Option[Instrumentation[_ <: Estimator[_]]],
         val className: String) extends Logging {
     
    -  def this(instr: Instrumentation[_ <: Estimator[_]]) = this(Some(instr), 
"")
    -
    -  def this(clazz: Class[_]) = this(None, clazz.getName.stripSuffix("$"))
    -
    -  protected override def logName = className
    +  protected override def logName: String = className
     
       override def logInfo(msg: => String) {
    -    instrument match {
    +    instrumentation match {
           case Some(instr) => instr.logInfo(msg)
           case None => super.logInfo(msg)
         }
       }
     
       override def logWarning(msg: => String) {
    -    instrument match {
    +    instrumentation match {
           case Some(instr) => instr.logWarning(msg)
           case None => super.logWarning(msg)
         }
       }
     
       override def logError(msg: => String) {
    -    instrument match {
    +    instrumentation match {
           case Some(instr) => instr.logError(msg)
           case None => super.logError(msg)
         }
       }
     }
    +
    +private[spark] object OptionalInstrumentation {
    +
    +  /**
    +   * Creates an `OptionalInstrumentation` object from an existing 
`Instrumentation` object.
    +   */
    +  def create(instr: Instrumentation[_ <: Estimator[_]]): 
OptionalInstrumentation = {
    +    new OptionalInstrumentation(Some(instr),
    +      classOf[Instrumentation[_]].getName.stripSuffix("$"))
    --- End diff --
    
    This is going to log using className = Instrumentation, which is not very 
informative.  It should log using the Estimator class name.  It might be easier 
to separate logName from className.


---

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

Reply via email to