You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by chenghao-intel <gi...@git.apache.org> on 2015/02/09 09:26:07 UTC

[GitHub] spark pull request: [SPARK-5683] [SQL] Avoid multiple json generat...

GitHub user chenghao-intel opened a pull request:

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

    [SPARK-5683] [SQL] Avoid multiple json generator created

    

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

    $ git pull https://github.com/chenghao-intel/spark json

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

    https://github.com/apache/spark/pull/4468.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 #4468
    
----
commit 2a55d51872ecf4d9e6ef87dafa21a78f299ac8ed
Author: Cheng Hao <ha...@intel.com>
Date:   2015-02-08T13:37:47Z

    avoid multiple json generator created

----


---
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-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#issuecomment-73824443
  
    Thanks, merged to master and 1.3


---
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-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#issuecomment-73481187
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/27093/
    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: [SPARK-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#issuecomment-73472582
  
      [Test build #27092 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/27092/consoleFull) for   PR 4468 at commit [`e556aba`](https://github.com/apache/spark/commit/e556abaf078ec669e1e7e7f78523a3fcbcdd2149).
     * This patch merges cleanly.


---
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-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#issuecomment-73623501
  
    @chenghao-intel Thank you for the PR. It will be great if you can also attach some performance results.


---
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-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#issuecomment-73625785
  
    @yhuai, thanks for reviewing, in a local testing, it shows about 10-15% performance gain.


---
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-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#issuecomment-73480882
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/27092/
    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: [SPARK-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#discussion_r24381522
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameImpl.scala ---
    @@ -409,8 +411,26 @@ private[sql] class DataFrameImpl protected[sql](
       override def toJSON: RDD[String] = {
         val rowSchema = this.schema
         this.mapPartitions { iter =>
    -      val jsonFactory = new JsonFactory()
    -      iter.map(JsonRDD.rowToJSON(rowSchema, jsonFactory))
    +      val writer = new CharArrayWriter()
    +      // create the Generator without separator inserted between 2 records
    +      val gen = new JsonFactory().createGenerator(writer).setRootValueSeparator(null)
    --- End diff --
    
    A ` `(single space) will be inserted between 2 json records (in string) by default; 
    Previously, we create the `generator` object for each of record in serialization, hence it's OK with default object separator.
    However, in this PR, we are trying to using a single `generator` for all of the records, that's why we need to set it as null, which means nothing will be inserted between records.


---
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-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#discussion_r24381281
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameImpl.scala ---
    @@ -409,8 +411,26 @@ private[sql] class DataFrameImpl protected[sql](
       override def toJSON: RDD[String] = {
         val rowSchema = this.schema
         this.mapPartitions { iter =>
    -      val jsonFactory = new JsonFactory()
    -      iter.map(JsonRDD.rowToJSON(rowSchema, jsonFactory))
    +      val writer = new CharArrayWriter()
    --- End diff --
    
    I was trying to use the `StringWriter`, but it doesn't have the method like `reset`, hence we may not able to reuse the object for for each of the records. That's why I changed it as `CharArrayWriter`.


---
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-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#issuecomment-73480872
  
      [Test build #27092 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/27092/consoleFull) for   PR 4468 at commit [`e556aba`](https://github.com/apache/spark/commit/e556abaf078ec669e1e7e7f78523a3fcbcdd2149).
     * 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 pull request: [SPARK-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#issuecomment-73481177
  
      [Test build #27093 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/27093/consoleFull) for   PR 4468 at commit [`aeb7801`](https://github.com/apache/spark/commit/aeb7801231f62bc5776f96bd4a397e82b7418beb).
     * 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 pull request: [SPARK-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#discussion_r24380711
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameImpl.scala ---
    @@ -409,8 +411,26 @@ private[sql] class DataFrameImpl protected[sql](
       override def toJSON: RDD[String] = {
         val rowSchema = this.schema
         this.mapPartitions { iter =>
    -      val jsonFactory = new JsonFactory()
    -      iter.map(JsonRDD.rowToJSON(rowSchema, jsonFactory))
    +      val writer = new CharArrayWriter()
    --- End diff --
    
    Is it better than `StringWriter`?


---
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-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#issuecomment-73823993
  
    @marmbrus any more comment on this?


---
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-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#issuecomment-73631133
  
    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 pull request: [SPARK-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#discussion_r24380694
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameImpl.scala ---
    @@ -409,8 +411,26 @@ private[sql] class DataFrameImpl protected[sql](
       override def toJSON: RDD[String] = {
         val rowSchema = this.schema
         this.mapPartitions { iter =>
    -      val jsonFactory = new JsonFactory()
    -      iter.map(JsonRDD.rowToJSON(rowSchema, jsonFactory))
    +      val writer = new CharArrayWriter()
    +      // create the Generator without separator inserted between 2 records
    +      val gen = new JsonFactory().createGenerator(writer).setRootValueSeparator(null)
    --- End diff --
    
    Should we expect any test result change after using `setRootValueSeparator(null)`?


---
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-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#issuecomment-73621280
  
    cc @marmbrus @yhuai


---
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-5683] [SQL] Avoid multiple json generat...

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

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


---
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-5683] [SQL] Avoid multiple json generat...

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

    https://github.com/apache/spark/pull/4468#issuecomment-73473068
  
      [Test build #27093 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/27093/consoleFull) for   PR 4468 at commit [`aeb7801`](https://github.com/apache/spark/commit/aeb7801231f62bc5776f96bd4a397e82b7418beb).
     * This patch merges cleanly.


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