Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d441794
update API of addMutableState
kiszk Nov 24, 2017
870d106
eliminate initialization with default value
kiszk Nov 25, 2017
24d7087
allocate a global Java array to store a lot of mutable state in a class
kiszk Nov 26, 2017
3eb5842
fix scala style error
kiszk Nov 26, 2017
074d711
fix test failure of ExpressionEncoderSuite.NestedArray
kiszk Nov 27, 2017
eafa3f8
rebase with master
kiszk Nov 30, 2017
90d15f3
address review comments
kiszk Nov 30, 2017
c456c07
add useFreshname parameter to addMutableState
kiszk Nov 30, 2017
9ca5ab3
rebase with master
kiszk Nov 30, 2017
5b36c61
fix test failures
kiszk Dec 1, 2017
fd51d75
drop to creat a loop for initialization
kiszk Dec 7, 2017
effe918
fix test failure
kiszk Dec 8, 2017
9df109c
update comments
kiszk Dec 8, 2017
634d494
address review comment
kiszk Dec 10, 2017
d3438fd
address review comment
kiszk Dec 12, 2017
f4f3754
address review comment
kiszk Dec 12, 2017
f1e1fca
address review comments except test case
kiszk Dec 13, 2017
0937ef2
rebase with master
kiszk Dec 13, 2017
4bfcc1a
Do not use compaction as possible for frequently-accessed variable
kiszk Dec 13, 2017
49119a9
exclude mutable state from argument list for ExpressionCodegn
kiszk Dec 13, 2017
24f49c5
fix test failures
kiszk Dec 14, 2017
15e967e
address review comments
kiszk Dec 14, 2017
d6c1a97
address review comments
kiszk Dec 14, 2017
a9d40e9
address review comments
kiszk Dec 14, 2017
31914c0
address review comments
kiszk Dec 15, 2017
0e45c19
address review comments
kiszk Dec 19, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address review comments except test case
  • Loading branch information
kiszk committed Dec 14, 2017
commit f1e1fca57e232113a1f8f402bef0ee5cf99e798a
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ class CodegenContext {
* the list of default imports available.
* Also, generic type arguments are accepted but ignored.
* @param variableName Name of the field.
* @param codeFunctions Function includes statement(s) to put into the init() method to
* initialize this field. An argument is the name of the mutable state variable
* If left blank, the field will be default-initialized.
* @param initFunc Function includes statement(s) to put into the init() method to initialize
* this field. An argument is the name of the mutable state variable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indentation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The Argument...

* If left blank, the field will be default-initialized.
* @param inline whether the declaration and initialization code may be inlined rather than
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: forceInline?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have a clear rule when to force inline it?

* compacted.
* @param useFreshName If false and inline is true, the name is not changed
Expand All @@ -197,7 +197,7 @@ class CodegenContext {
def addMutableState(
javaType: String,
variableName: String,
codeFunctions: String => String = _ => "",
initFunc: String => String = _ => "",
inline: Boolean = false,
useFreshName: Boolean = true): String = {
val varName = if (useFreshName) freshName(variableName) else variableName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of calling freshName here and adding a useFreshName parameter, can we follow the previous style and ask the caller side to guarantee the given name is unique? i.e. call freshName at caller side

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I noticed that most of caller sides executes freshName, I decided to use the new style that can simply caller code. If a developer want to guarantee the given name is unique at caller site (currently, they are only several cases), it is OK by using useFreshName = true.

Do we need redundant code at caller side? WDYT? @cloud-fan

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it an existing problem? Let's fix it in another PR to make this PR more consistent with the previous code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let us discuss in another PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be moved in the if for clarity

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

Expand All @@ -208,7 +208,7 @@ class CodegenContext {
(mutableStates.length < CodeGenerator.OUTER_CLASS_VARIABLES_THRESHOLD) ||
// type is multi-dimensional array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can't support multi-dimensional array?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are changing a declared type for compaction (i.e. adding one dimension at the first dimension) at declareMutableStates. In the logic at declareMutableStates assumes that a given variable is scalar or one-dimensional array.
We could support multi-dimensional array. However, it requires slightly complicated string operations. Should we support multi-dimensional array or keep it simple?

@cloud-fan WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok let's leave it

javaType.contains("[][]")) {
val initCode = codeFunctions(varName)
val initCode = initFunc(varName)
mutableStates += ((javaType, varName, initCode))
varName
} else {
Expand All @@ -231,7 +231,7 @@ class CodegenContext {
mutableStateArrayCurrentNames(javaType) = arrayName
mutableStateArrayIdx((javaType, arrayName)) = newIdx

val initCode = codeFunctions(s"$arrayName[$newIdx]")
val initCode = initFunc(s"$arrayName[$newIdx]")
mutableStateArrayInitCodes += initCode
s"$arrayName[$newIdx]"
}
Expand Down Expand Up @@ -279,7 +279,7 @@ class CodegenContext {
// `TypedAggregateExpression`, we should call `distinct` here to remove the duplicated ones.
val initCodes = mutableStates.map(_._3).distinct.map(_ + "\n")
// statements for array element initialization
val arrayInitCodes = mutableStateArrayInitCodes.distinct.map(_ + "\n")
val arrayInitCodes = mutableStateArrayInitCodes.distinct

// The generated initialization code may exceed 64kb function size limit in JVM if there are too
// many mutable states, so split it into multiple functions.
Expand Down