-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ORC: Grow list and map child vectors with a growth factor of 3 (#2218) (
#147)
- Loading branch information
Showing
6 changed files
with
274 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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 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 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
56 changes: 56 additions & 0 deletions
56
...k2/src/jmh/java/org/apache/iceberg/spark/source/IcebergSourceNestedListDataBenchmark.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.iceberg.spark.source; | ||
|
||
import java.util.Map; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.iceberg.PartitionSpec; | ||
import org.apache.iceberg.Schema; | ||
import org.apache.iceberg.Table; | ||
import org.apache.iceberg.TableProperties; | ||
import org.apache.iceberg.hadoop.HadoopTables; | ||
import org.apache.iceberg.relocated.com.google.common.collect.Maps; | ||
import org.apache.iceberg.types.Types; | ||
|
||
import static org.apache.iceberg.types.Types.NestedField.optional; | ||
import static org.apache.iceberg.types.Types.NestedField.required; | ||
|
||
public abstract class IcebergSourceNestedListDataBenchmark extends IcebergSourceBenchmark { | ||
|
||
@Override | ||
protected Configuration initHadoopConf() { | ||
return new Configuration(); | ||
} | ||
|
||
@Override | ||
protected final Table initTable() { | ||
Schema schema = new Schema( | ||
required(0, "id", Types.LongType.get()), | ||
optional(1, "outerlist", Types.ListType.ofOptional(2, | ||
Types.StructType.of(required(3, "innerlist", Types.ListType.ofRequired(4, Types.StringType.get()))) | ||
)) | ||
); | ||
PartitionSpec partitionSpec = PartitionSpec.unpartitioned(); | ||
HadoopTables tables = new HadoopTables(hadoopConf()); | ||
Map<String, String> properties = Maps.newHashMap(); | ||
properties.put(TableProperties.METADATA_COMPRESSION, "gzip"); | ||
return tables.create(schema, partitionSpec, properties, newTableLocation()); | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
...ava/org/apache/iceberg/spark/source/orc/IcebergSourceNestedListORCDataWriteBenchmark.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.iceberg.spark.source.orc; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
import org.apache.iceberg.relocated.com.google.common.collect.Maps; | ||
import org.apache.iceberg.spark.source.IcebergSourceNestedListDataBenchmark; | ||
import org.apache.spark.sql.Dataset; | ||
import org.apache.spark.sql.Row; | ||
import org.apache.spark.sql.SaveMode; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.Param; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.TearDown; | ||
import org.openjdk.jmh.annotations.Threads; | ||
|
||
import static org.apache.spark.sql.functions.array_repeat; | ||
import static org.apache.spark.sql.functions.expr; | ||
import static org.apache.spark.sql.functions.struct; | ||
|
||
/** | ||
* A benchmark that evaluates the performance of writing nested Parquet data using Iceberg | ||
* and the built-in file source in Spark. | ||
* | ||
* To run this benchmark: | ||
* <code> | ||
* ./gradlew :iceberg-spark2:jmh | ||
* -PjmhIncludeRegex=IcebergSourceNestedListORCDataWriteBenchmark | ||
* -PjmhOutputPath=benchmark/iceberg-source-nested-list-orc-data-write-benchmark-result.txt | ||
* </code> | ||
*/ | ||
public class IcebergSourceNestedListORCDataWriteBenchmark extends IcebergSourceNestedListDataBenchmark { | ||
|
||
@Setup | ||
public void setupBenchmark() { | ||
setupSpark(); | ||
} | ||
|
||
@TearDown | ||
public void tearDownBenchmark() throws IOException { | ||
tearDownSpark(); | ||
cleanupFiles(); | ||
} | ||
|
||
@Param({"2000", "20000"}) | ||
private int numRows; | ||
|
||
@Benchmark | ||
@Threads(1) | ||
public void writeIceberg() { | ||
String tableLocation = table().location(); | ||
benchmarkData().write().format("iceberg").option("write-format", "orc") | ||
.mode(SaveMode.Append).save(tableLocation); | ||
} | ||
|
||
@Benchmark | ||
@Threads(1) | ||
public void writeIcebergDictionaryOff() { | ||
Map<String, String> tableProperties = Maps.newHashMap(); | ||
tableProperties.put("orc.dictionary.key.threshold", "0"); | ||
withTableProperties(tableProperties, () -> { | ||
String tableLocation = table().location(); | ||
benchmarkData().write().format("iceberg").option("write-format", "orc") | ||
.mode(SaveMode.Append).save(tableLocation); | ||
}); | ||
} | ||
|
||
@Benchmark | ||
@Threads(1) | ||
public void writeFileSource() { | ||
benchmarkData().write().mode(SaveMode.Append).orc(dataLocation()); | ||
} | ||
|
||
private Dataset<Row> benchmarkData() { | ||
return spark().range(numRows) | ||
.withColumn("outerlist", array_repeat(struct( | ||
expr("array_repeat(CAST(id AS string), 1000) AS innerlist")), | ||
10)) | ||
.coalesce(1); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
...apache/iceberg/spark/source/parquet/IcebergSourceNestedListParquetDataWriteBenchmark.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.iceberg.spark.source.parquet; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
import org.apache.iceberg.relocated.com.google.common.collect.Maps; | ||
import org.apache.iceberg.spark.source.IcebergSourceNestedListDataBenchmark; | ||
import org.apache.spark.sql.Dataset; | ||
import org.apache.spark.sql.Row; | ||
import org.apache.spark.sql.SaveMode; | ||
import org.apache.spark.sql.internal.SQLConf; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.Param; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.TearDown; | ||
import org.openjdk.jmh.annotations.Threads; | ||
|
||
import static org.apache.spark.sql.functions.array_repeat; | ||
import static org.apache.spark.sql.functions.expr; | ||
import static org.apache.spark.sql.functions.struct; | ||
|
||
/** | ||
* A benchmark that evaluates the performance of writing nested Parquet data using Iceberg | ||
* and the built-in file source in Spark. | ||
* | ||
* To run this benchmark: | ||
* <code> | ||
* ./gradlew :iceberg-spark2:jmh | ||
* -PjmhIncludeRegex=IcebergSourceNestedListParquetDataWriteBenchmark | ||
* -PjmhOutputPath=benchmark/iceberg-source-nested-list-parquet-data-write-benchmark-result.txt | ||
* </code> | ||
*/ | ||
public class IcebergSourceNestedListParquetDataWriteBenchmark extends IcebergSourceNestedListDataBenchmark { | ||
|
||
@Setup | ||
public void setupBenchmark() { | ||
setupSpark(); | ||
} | ||
|
||
@TearDown | ||
public void tearDownBenchmark() throws IOException { | ||
tearDownSpark(); | ||
cleanupFiles(); | ||
} | ||
|
||
@Param({"2000", "20000"}) | ||
private int numRows; | ||
|
||
@Benchmark | ||
@Threads(1) | ||
public void writeIceberg() { | ||
String tableLocation = table().location(); | ||
benchmarkData().write().format("iceberg").mode(SaveMode.Append).save(tableLocation); | ||
} | ||
|
||
@Benchmark | ||
@Threads(1) | ||
public void writeFileSource() { | ||
Map<String, String> conf = Maps.newHashMap(); | ||
conf.put(SQLConf.PARQUET_COMPRESSION().key(), "gzip"); | ||
withSQLConf(conf, () -> benchmarkData().write().mode(SaveMode.Append).parquet(dataLocation())); | ||
} | ||
|
||
private Dataset<Row> benchmarkData() { | ||
return spark().range(numRows) | ||
.withColumn("outerlist", array_repeat(struct( | ||
expr("array_repeat(CAST(id AS string), 1000) AS innerlist")), | ||
10)) | ||
.coalesce(1); | ||
} | ||
} |