You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by techaddict <gi...@git.apache.org> on 2016/05/27 02:44:21 UTC

[GitHub] spark pull request: [SPARK-15598] Change Aggregator.zero to Aggreg...

GitHub user techaddict opened a pull request:

    https://github.com/apache/spark/pull/13347

    [SPARK-15598] Change Aggregator.zero to Aggregator.init

    ## What changes were proposed in this pull request?
    org.apache.spark.sql.expressions.Aggregator currently requires defining the zero value for an aggregator. This is actually a limitation making it difficult to implement APIs such as reduce. In reduce (or reduceByKey), a single associative and commutative reduce function is specified by the user, and there is no definition of zero value.
    A small tweak to the API is to change zero to init, taking an input, similar to the following:
    ```scala
    abstract class Aggregator[-IN, BUF, OUT] extends Serializable {
      def init(a: IN): BUF
      def reduce(b: BUF, a: IN): BUF
      def merge(b1: BUF, b2: BUF): BUF
      def finish(reduction: BUF): OUT
    }
    ```
    Then reduce can be implemented using:
    `f: (T, T) => T`
    ```scala
    new Aggregator[T, T, T] {
      override def init(a: T): T = identify
      override def reduce(b: T, a: T): T = f(b, a)
      override def merge(b1: T, b2: T): T = f(b1, b2)
      override def finish(reduction: T): T = identify
    }
    ```
    ## How was this patch tested?
    Existing tests

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/techaddict/spark SPARK-15598

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/13347.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #13347
    
----
commit c278f445b62b10f82d73739d883fa8a35dc81f7a
Author: Sandeep Singh <sa...@techaddict.me>
Date:   2016-05-27T02:42:15Z

    [SPARK-15598] Change Aggregator.zero to Aggregator.init

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-15598][SQL] Change Aggregator.zero to A...

Posted by techaddict <gi...@git.apache.org>.
Github user techaddict closed the pull request at:

    https://github.com/apache/spark/pull/13347


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-15598][SQL] Change Aggregator.zero to A...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/13347#issuecomment-222048813
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/59451/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-15598] Change Aggregator.zero to Aggreg...

Posted by techaddict <gi...@git.apache.org>.
Github user techaddict commented on the pull request:

    https://github.com/apache/spark/pull/13347#issuecomment-222048243
  
    @rxin Yupp thats what I was about to ask, for calls where we just need `.zero` what do we do ?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-15598][SQL] Change Aggregator.zero to A...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/13347#issuecomment-222066786
  
    Can you close this? The current one is too far away from working.



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-15598] Change Aggregator.zero to Aggreg...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/13347#issuecomment-222048050
  
    Thanks for the pull request. But is the implementation corrct? I don't think you can just pass literal 1 into the init function. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-15598][SQL] Change Aggregator.zero to A...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/13347#issuecomment-222063487
  
    This is a pretty major refactoring of the internals I think.



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-15598][SQL] Change Aggregator.zero to A...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/13347#issuecomment-222048810
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-15598] Change Aggregator.zero to Aggreg...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/13347#issuecomment-222047757
  
    **[Test build #59451 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/59451/consoleFull)** for PR 13347 at commit [`c278f44`](https://github.com/apache/spark/commit/c278f445b62b10f82d73739d883fa8a35dc81f7a).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [SPARK-15598][SQL] Change Aggregator.zero to A...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/13347#issuecomment-222048797
  
    **[Test build #59451 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/59451/consoleFull)** for PR 13347 at commit [`c278f44`](https://github.com/apache/spark/commit/c278f445b62b10f82d73739d883fa8a35dc81f7a).
     * This patch **fails MiMa tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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