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

    https://github.com/apache/spark/pull/11410#discussion_r54555457
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/encoders/OuterScopes.scala
 ---
    @@ -39,4 +41,35 @@ object OuterScopes {
       def addOuterScope(outer: AnyRef): Unit = {
         outerScopes.putIfAbsent(outer.getClass.getName, outer)
       }
    +
    +  def getOuterScope(innerCls: Class[_]): AnyRef = {
    +    assert(innerCls.isMemberClass)
    +    val outerCls = innerCls.getDeclaringClass.getName
    +    val outer = outerScopes.get(outerCls)
    +    if (outer == null) {
    +      outerCls match {
    +        case REPLClass(line) =>
    +          val loader = Utils.getContextOrSparkClassLoader
    +          def loadCls(clsName: String): Class[_] = Class.forName(clsName, 
true, loader)
    +
    +          val cls1 = loadCls(line + "$read$")
    +          val obj1 = cls1.getField("MODULE$").get(null)
    +
    +          val obj2 = cls1.getMethod("INSTANCE").invoke(obj1)
    +          val cls2 = loadCls(line + "$read")
    +
    +          val obj3 = cls2.getMethod("$iw").invoke(obj2)
    +          val cls3 = loadCls(line + "$read$$iw")
    +
    +          cls3.getMethod("$iw").invoke(obj3)
    +
    +        case _ => null
    +      }
    +    } else {
    +      outer
    +    }
    +  }
    +
    +  // The format of REPL generated wrapper class's name, e.g. 
`$line12.$read$$iw$$iw`
    --- End diff --
    
    Ping @som-snytt and @retronym, Am I correct about the assumption that these 
wrappers are not likely to change very frequently ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to