spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgaido91 <...@git.apache.org>
Subject [GitHub] spark pull request #19811: [SPARK-18016][SQL] Code Generation: Constant Pool...
Date Thu, 30 Nov 2017 08:47:56 GMT
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19811#discussion_r154013620
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
---
    @@ -177,11 +190,67 @@ class CodegenContext {
        *                 the list of default imports available.
        *                 Also, generic type arguments are accepted but ignored.
        * @param variableName Name of the field.
    -   * @param initCode The statement(s) to put into the init() method to initialize this
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 inline whether the declaration and initialization code may be inlined rather
than
    +   *               compacted. If true, the name is not changed
    +   * @return the name of the mutable state variable, which is either the original name
if the
    +   *         variable is inlined to the outer class, or an array access if the variable
is to be
    +   *         stored in an array of variables of the same type and initialization.
    +   *         primitive type variables will be inlined into outer class when the total
number of
    +   *         mutable variables is less than `CodeGenerator.OUTER_CLASS_VARIABLES_THRESHOLD`
    +   *         the max size of an array for compaction is given by
    +   *         `CodeGenerator.MUTABLESTATEARRAY_SIZE_LIMIT`.
        */
    -  def addMutableState(javaType: String, variableName: String, initCode: String = ""):
Unit = {
    -    mutableStates += ((javaType, variableName, initCode))
    +  def addMutableState(
    +      javaType: String,
    +      variableName: String,
    +      codeFunctions: String => String = _ => "",
    +      inline: Boolean = false): String = {
    --- End diff --
    
    if we go this way, what about creating a `MutableStateBuilder` then, with methods like
`withSimpleInitialValue` taking a string and `withComplexInit` taking a function or something
like that?


---

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


Mime
View raw message