-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-18016][SQL][followup] merge declareAddedFunctions, initNestedClasses and declareNestedClasses #18579
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
[SPARK-18016][SQL][followup] merge declareAddedFunctions, initNestedClasses and declareNestedClasses #18579
Changes from all commits
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 |
|---|---|---|
|
|
@@ -302,37 +302,30 @@ class CodegenContext { | |
| } | ||
|
|
||
| /** | ||
| * Instantiates all nested, private sub-classes as objects to the `OuterClass` | ||
| * Declares all function code. If the added functions are too many, split them into nested | ||
| * sub-classes to avoid hitting Java compiler constant pool limitation. | ||
| */ | ||
| private[sql] def initNestedClasses(): String = { | ||
| def declareAddedFunctions(): String = { | ||
| val inlinedFunctions = classFunctions(outerClassName).values | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Would it be better to move this line after the comment at line 311-312? This is because this output is declared in Line 312 (i.e. inlined fuction into OuterClass).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are different. This line inline pure functions which are not in the nested classes, and the next line inline these nested classes containing other functions.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right. Sorry, I made a mistake. |
||
|
|
||
| // Nested, private sub-classes have no mutable state (though they do reference the outer class' | ||
| // mutable state), so we declare and initialize them inline to the OuterClass. | ||
| classes.filter(_._1 != outerClassName).map { | ||
| val initNestedClasses = classes.filter(_._1 != outerClassName).map { | ||
| case (className, classInstance) => | ||
| s"private $className $classInstance = new $className();" | ||
| }.mkString("\n") | ||
| } | ||
|
|
||
| /** | ||
| * Declares all function code that should be inlined to the `OuterClass`. | ||
| */ | ||
| private[sql] def declareAddedFunctions(): String = { | ||
| classFunctions(outerClassName).values.mkString("\n") | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Declares all nested, private sub-classes and the function code that should be inlined to them. | ||
| */ | ||
| private[sql] def declareNestedClasses(): String = { | ||
| classFunctions.filterKeys(_ != outerClassName).map { | ||
| val declareNestedClasses = classFunctions.filterKeys(_ != outerClassName).map { | ||
| case (className, functions) => | ||
| s""" | ||
| |private class $className { | ||
| | ${functions.values.mkString("\n")} | ||
| |} | ||
| """.stripMargin | ||
| } | ||
| }.mkString("\n") | ||
|
|
||
| (inlinedFunctions ++ initNestedClasses ++ declareNestedClasses).mkString("\n") | ||
| } | ||
|
|
||
| final val JAVA_BOOLEAN = "boolean" | ||
| final val JAVA_BYTE = "byte" | ||
|
|
||
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 seems that we can keep this as
private[sql]because all previous three functions are.