-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-13922][SQL] Filter rows with null attributes in vectorized parquet reader #11749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Parquet Read Benchmark
- Loading branch information
commit 4fa94a221e0da8d27e1c1c35fbc06243711d34f3
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -299,10 +299,112 @@ object ParquetReadBenchmark { | |
| } | ||
| } | ||
|
|
||
| def stringWithNullsScanBenchmark(values: Int, fractionOfNulls: Double): Unit = { | ||
| withTempPath { dir => | ||
| withTempTable("t1", "tempTable") { | ||
| sqlContext.range(values).registerTempTable("t1") | ||
| sqlContext.sql(s"select IF(rand(1) < $fractionOfNulls, NULL, cast(id as STRING)) as c1, " + | ||
| s"IF(rand(2) < $fractionOfNulls, NULL, cast(id as STRING)) as c2 from t1") | ||
| .write.parquet(dir.getCanonicalPath) | ||
| sqlContext.read.parquet(dir.getCanonicalPath).registerTempTable("tempTable") | ||
|
|
||
| val benchmark = new Benchmark("String with Nulls Scan", values) | ||
|
|
||
| benchmark.addCase("SQL Parquet Vectorized") { iter => | ||
| sqlContext.sql("select sum(length(c2)) from tempTable where c1 is " + | ||
| "not NULL and c2 is not NULL").collect() | ||
| } | ||
|
|
||
| val files = SpecificParquetRecordReaderBase.listDirectory(dir).toArray | ||
| benchmark.addCase("PR Vectorized") { num => | ||
| var sum = 0 | ||
| files.map(_.asInstanceOf[String]).foreach { p => | ||
| val reader = new UnsafeRowParquetRecordReader | ||
| try { | ||
| reader.initialize(p, ("c1" :: "c2" :: Nil).asJava) | ||
| val batch = reader.resultBatch() | ||
| while (reader.nextBatch()) { | ||
| val rowIterator = batch.rowIterator() | ||
| while (rowIterator.hasNext) { | ||
| val row = rowIterator.next() | ||
| val value = row.getUTF8String(0) | ||
| if (!row.isNullAt(0) && !row.isNullAt(1)) sum += value.numBytes() | ||
| } | ||
| } | ||
| } finally { | ||
| reader.close() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| benchmark.addCase("PR Vectorized (Null Filtering)") { num => | ||
| var sum = 0L | ||
| files.map(_.asInstanceOf[String]).foreach { p => | ||
| val reader = new UnsafeRowParquetRecordReader | ||
| try { | ||
| reader.initialize(p, ("c1" :: "c2" :: Nil).asJava) | ||
| val batch = reader.resultBatch() | ||
| batch.filterNullsInColumn(0) | ||
| batch.filterNullsInColumn(1) | ||
| while (reader.nextBatch()) { | ||
| val rowIterator = batch.rowIterator() | ||
| while (rowIterator.hasNext) { | ||
| sum += rowIterator.next().getUTF8String(0).numBytes() | ||
| } | ||
| } | ||
| } finally { | ||
| reader.close() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| ======================= | ||
| Fraction of NULLs: 0 | ||
| ======================= | ||
|
|
||
| Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz | ||
| String with Nulls Scan: Best/Avg Time(ms) Rate(M/s) Per Row(ns) Relative | ||
| ------------------------------------------------------------------------------------------- | ||
| SQL Parquet Vectorized 1164 / 1333 9.0 111.0 1.0X | ||
| PR Vectorized 809 / 882 13.0 77.1 1.4X | ||
| PR Vectorized (Null Filtering) 723 / 800 14.5 69.0 1.6X | ||
|
|
||
| ======================= | ||
| Fraction of NULLs: 0.5 | ||
| ======================= | ||
|
|
||
| Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz | ||
| String with Nulls Scan: Best/Avg Time(ms) Rate(M/s) Per Row(ns) Relative | ||
| ------------------------------------------------------------------------------------------- | ||
| SQL Parquet Vectorized 983 / 1001 10.7 93.8 1.0X | ||
| PR Vectorized 699 / 728 15.0 66.7 1.4X | ||
| PR Vectorized (Null Filtering) 722 / 746 14.5 68.9 1.4X | ||
|
|
||
| ======================= | ||
|
||
| Fraction of NULLs: 0.95 | ||
| ======================= | ||
|
|
||
| Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz | ||
| String with Nulls Scan: Best/Avg Time(ms) Rate(M/s) Per Row(ns) Relative | ||
| ------------------------------------------------------------------------------------------- | ||
| SQL Parquet Vectorized 332 / 343 31.6 31.6 1.0X | ||
| PR Vectorized 177 / 180 59.1 16.9 1.9X | ||
| PR Vectorized (Null Filtering) 168 / 175 62.4 16.0 2.0X | ||
| */ | ||
|
|
||
| benchmark.run() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| def main(args: Array[String]): Unit = { | ||
| intScanBenchmark(1024 * 1024 * 15) | ||
| intStringScanBenchmark(1024 * 1024 * 10) | ||
| stringDictionaryScanBenchmark(1024 * 1024 * 10) | ||
| partitionTableScanBenchmark(1024 * 1024 * 15) | ||
| for (fractionOfNulls <- List(0.0, 0.50, 0.95)) { | ||
| stringWithNullsScanBenchmark(1024 * 1024 * 10, fractionOfNulls) | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you mean to add a space?