[GitHub] spark pull request #18005: [SPARK-20773][SQL] ParquetWriteSupport.writeField...

2017-05-19 Thread asfgit
Github user asfgit closed the pull request at:

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


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

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



[GitHub] spark pull request #18005: [SPARK-20773][SQL] ParquetWriteSupport.writeField...

2017-05-17 Thread hvanhovell
Github user hvanhovell commented on a diff in the pull request:

https://github.com/apache/spark/pull/18005#discussion_r117029865
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetWriteSupport.scala
 ---
@@ -90,7 +90,7 @@ private[parquet] class ParquetWriteSupport extends 
WriteSupport[InternalRow] wit
 }
 
 
-this.rootFieldWriters = schema.map(_.dataType).map(makeWriter)
+this.rootFieldWriters = 
schema.map(_.dataType).map(makeWriter).toArray[ValueWriter]
--- End diff --

Either call toIndexedSeq or make the rootFieldWriters an Array. Both are 
fine.


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

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



[GitHub] spark pull request #18005: [SPARK-20773][SQL] ParquetWriteSupport.writeField...

2017-05-17 Thread hvanhovell
Github user hvanhovell commented on a diff in the pull request:

https://github.com/apache/spark/pull/18005#discussion_r117029723
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetWriteSupport.scala
 ---
@@ -90,7 +90,7 @@ private[parquet] class ParquetWriteSupport extends 
WriteSupport[InternalRow] wit
 }
 
 
-this.rootFieldWriters = schema.map(_.dataType).map(makeWriter).toArray
+this.rootFieldWriters = 
schema.map(_.dataType).map(makeWriter).toArray[ValueWriter]
--- End diff --

Either call `toIndexedSeq` or make the `rootFieldWriters` an Array. Both 
are fine.


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

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



[GitHub] spark pull request #18005: [SPARK-20773][SQL] ParquetWriteSupport.writeField...

2017-05-16 Thread tpoterba
GitHub user tpoterba opened a pull request:

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

[SPARK-20773][SQL] ParquetWriteSupport.writeFields is quadratic in number 
of fields 

Fix quadratic List indexing in ParquetWriteSupport.

I noticed this function while profiling some code with today. It showed up 
as a significant factor in a table with twenty columns; with hundreds of 
columns, it could dominate any other function call.

## What changes were proposed in this pull request?

The writeFields method iterates from 0 until number of fields, indexing 
into rootFieldWriters for each element. rootFieldWriters is a List, so indexing 
is a linear operation. The complexity of the writeFields method is thus 
quadratic in the number of fields.

Solution: explicitly convert rootFieldWriters to Array (implicitly 
converted to WrappedArray) for constant-time indexing. 

## How was this patch tested?

This is a one-line change for performance reasons.


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

$ git pull https://github.com/tpoterba/spark tpoterba-patch-1

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

https://github.com/apache/spark/pull/18005.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 #18005


commit e13ce9f85af8a0f87af09e49de04cfda30bf9180
Author: Tim Poterba 
Date:   2017-05-16T19:29:46Z

Fix quadratic List indexing in ParquetWriteSupport

Fix quadratic List indexing in ParquetWriteSupport.

Minimal solution is to convert rootFieldWriters to a WrappedArray, which 
has O(1) indexing, and restores complexity to linear.




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

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