You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by rxin <gi...@git.apache.org> on 2017/04/11 08:23:01 UTC

[GitHub] spark pull request #17604: [SPARK-20289][SQL] Use StaticInvoke to box primit...

GitHub user rxin opened a pull request:

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

    [SPARK-20289][SQL] Use StaticInvoke to box primitive types

    ## What changes were proposed in this pull request?
    Dataset typed API currently uses NewInstance to box primitive types (i.e. calling the constructor). Instead, it'd be slightly more idiomatic in Java to use PrimitiveType.valueOf, which can be invoked using StaticInvoke expression.
    
    ## How was this patch tested?
    The change should be covered by existing tests for Dataset encoders.


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

    $ git pull https://github.com/rxin/spark SPARK-20289

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

    https://github.com/apache/spark/pull/17604.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 #17604
    
----
commit 8cbc617ee528ab92a755995a03b9ebefc2eb03a4
Author: Reynold Xin <rx...@databricks.com>
Date:   2017-04-11T08:21:38Z

    [SPARK-20289][SQL] Use StaticInvoke to box primitive types

----


---
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 #17604: [SPARK-20289][SQL] Use StaticInvoke to box primit...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17604#discussion_r110855845
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/JavaTypeInference.scala ---
    @@ -204,20 +204,19 @@ object JavaTypeInference {
         typeToken.getRawType match {
           case c if !inferExternalType(c).isInstanceOf[ObjectType] => getPath
     
    -      case c if c == classOf[java.lang.Short] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Integer] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Long] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Double] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Byte] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Float] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Boolean] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    +      case c if c == classOf[java.lang.Short] ||
    --- End diff --
    
    Ugh right ignore that. Not thinking straight.


---
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 #17604: [SPARK-20289][SQL] Use StaticInvoke to box primit...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17604#discussion_r110853394
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/JavaTypeInference.scala ---
    @@ -204,20 +204,19 @@ object JavaTypeInference {
         typeToken.getRawType match {
           case c if !inferExternalType(c).isInstanceOf[ObjectType] => getPath
     
    -      case c if c == classOf[java.lang.Short] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Integer] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Long] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Double] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Byte] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Float] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Boolean] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    +      case c if c == classOf[java.lang.Short] ||
    --- End diff --
    
    Is this simpler as
    
    ```
    case c: java.lang.Short | java.lang.Integer | java.lang.Long | ... =>
    ```
    
    I believe it's the same thing but don't know if it is implemented in a meaningfully different way. Seems like it ought to be no worse at runtime but I don't know.


---
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 #17604: [SPARK-20289][SQL] Use StaticInvoke to box primit...

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

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


---
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 issue #17604: [SPARK-20289][SQL] Use StaticInvoke to box primitive typ...

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

    https://github.com/apache/spark/pull/17604
  
    Merging in master.


---
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 #17604: [SPARK-20289][SQL] Use StaticInvoke to box primit...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17604#discussion_r110840736
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala ---
    @@ -204,37 +204,37 @@ object ScalaReflection extends ScalaReflection {
           case t if t <:< localTypeOf[java.lang.Integer] =>
             val boxedType = classOf[java.lang.Integer]
             val objectType = ObjectType(boxedType)
    -        NewInstance(boxedType, getPath :: Nil, objectType)
    +        StaticInvoke(boxedType, objectType, "valueOf", getPath :: Nil, propagateNull = true)
    --- End diff --
    
    `propagateNull` is true by default, maybe omit it?


---
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 issue #17604: [SPARK-20289][SQL] Use StaticInvoke to box primitive typ...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/17604
  
    LGTM


---
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 issue #17604: [SPARK-20289][SQL] Use StaticInvoke to box primitive typ...

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

    https://github.com/apache/spark/pull/17604
  
    Merged build finished. Test PASSed.


---
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 issue #17604: [SPARK-20289][SQL] Use StaticInvoke to box primitive typ...

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

    https://github.com/apache/spark/pull/17604
  
    **[Test build #75698 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75698/testReport)** for PR 17604 at commit [`8cbc617`](https://github.com/apache/spark/commit/8cbc617ee528ab92a755995a03b9ebefc2eb03a4).
     * This patch passes all 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


[GitHub] spark issue #17604: [SPARK-20289][SQL] Use StaticInvoke to box primitive typ...

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

    https://github.com/apache/spark/pull/17604
  
    **[Test build #75698 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75698/testReport)** for PR 17604 at commit [`8cbc617`](https://github.com/apache/spark/commit/8cbc617ee528ab92a755995a03b9ebefc2eb03a4).


---
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 issue #17604: [SPARK-20289][SQL] Use StaticInvoke to box primitive typ...

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

    https://github.com/apache/spark/pull/17604
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/75698/
    Test PASSed.


---
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 #17604: [SPARK-20289][SQL] Use StaticInvoke to box primit...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17604#discussion_r110855725
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/JavaTypeInference.scala ---
    @@ -204,20 +204,19 @@ object JavaTypeInference {
         typeToken.getRawType match {
           case c if !inferExternalType(c).isInstanceOf[ObjectType] => getPath
     
    -      case c if c == classOf[java.lang.Short] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Integer] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Long] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Double] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Byte] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Float] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    -      case c if c == classOf[java.lang.Boolean] =>
    -        NewInstance(c, getPath :: Nil, ObjectType(c))
    +      case c if c == classOf[java.lang.Short] ||
    --- End diff --
    
    `c` is a `Class[_]`...


---
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