-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-16525][SQL] Enable Row Based HashMap in HashAggregateExec #14176
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 all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4a5b81f
Enable row-based fast hashmap and set it as default in auto mode.
ooq 7194394
Remove the configuration flag that sets maximum column width for vect…
ooq 122cf18
Fix klen and vlen in FixedLengthRowBasedKeyValueBatch (making multipl…
ooq def94cc
Fix writing DecimalType bug in RowBasedHashMapGenerator.
ooq 97bb7c1
Fix comments (unfinished)
ooq b9a4268
Fix comments (unfinished)
ooq e67ff5d
Add explicit tests for aggregate hash maps and other minor fixs.
ooq b32cb7b
Remove accidental/unnecessary import.
ooq a58314c
Update flag settings and tests.
ooq 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
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
290 changes: 198 additions & 92 deletions
290
sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/HashAggregateExec.scala
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
|---|---|---|
|
|
@@ -499,14 +499,15 @@ object SQLConf { | |
| .intConf | ||
| .createWithDefault(40) | ||
|
|
||
| val VECTORIZED_AGG_MAP_MAX_COLUMNS = | ||
| SQLConfigBuilder("spark.sql.codegen.aggregate.map.columns.max") | ||
| val ENABLE_TWOLEVEL_AGG_MAP = | ||
| SQLConfigBuilder("spark.sql.codegen.aggregate.map.twolevel.enable") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's also make sure that all references to the old config are also appropriately modified. |
||
| .internal() | ||
| .doc("Sets the maximum width of schema (aggregate keys + values) for which aggregate with" + | ||
| "keys uses an in-memory columnar map to speed up execution. Setting this to 0 effectively" + | ||
| "disables the columnar map") | ||
| .intConf | ||
| .createWithDefault(3) | ||
| .doc("Enable two-level aggregate hash map. When enabled, records will first be " + | ||
| "inserted/looked-up at a 1st-level, small, fast map, and then fallback to a " + | ||
| "2nd-level, larger, slower map when 1st level is full or keys cannot be found. " + | ||
| "When disabled, records go directly to the 2nd level. Defaults to true.") | ||
| .booleanConf | ||
| .createWithDefault(true) | ||
|
|
||
| val FILE_SINK_LOG_DELETION = SQLConfigBuilder("spark.sql.streaming.fileSink.log.deletion") | ||
| .internal() | ||
|
|
@@ -673,7 +674,7 @@ private[sql] class SQLConf extends Serializable with CatalystConf with Logging { | |
|
|
||
| override def runSQLonFile: Boolean = getConf(RUN_SQL_ON_FILES) | ||
|
|
||
| def vectorizedAggregateMapMaxColumns: Int = getConf(VECTORIZED_AGG_MAP_MAX_COLUMNS) | ||
| def enableTwoLevelAggMap: Boolean = getConf(ENABLE_TWOLEVEL_AGG_MAP) | ||
|
|
||
| def variableSubstituteEnabled: Boolean = getConf(VARIABLE_SUBSTITUTE_ENABLED) | ||
|
|
||
|
|
||
79 changes: 79 additions & 0 deletions
79
sql/core/src/test/scala/org/apache/spark/sql/AggregateHashMapSuite.scala
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 |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* | ||
| * 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.spark.sql | ||
|
|
||
| import org.scalatest.BeforeAndAfter | ||
|
|
||
| class SingleLevelAggregateHashMapSuite extends DataFrameAggregateSuite with BeforeAndAfter { | ||
|
|
||
| protected override def beforeAll(): Unit = { | ||
| sparkConf.set("spark.sql.codegen.fallback", "false") | ||
| sparkConf.set("spark.sql.codegen.aggregate.map.twolevel.enable", "false") | ||
| super.beforeAll() | ||
| } | ||
|
|
||
| // adding some checking after each test is run, assuring that the configs are not changed | ||
| // in test code | ||
| after { | ||
| assert(sparkConf.get("spark.sql.codegen.fallback") == "false", | ||
| "configuration parameter changed in test body") | ||
| assert(sparkConf.get("spark.sql.codegen.aggregate.map.twolevel.enable") == "false", | ||
| "configuration parameter changed in test body") | ||
| } | ||
| } | ||
|
|
||
| class TwoLevelAggregateHashMapSuite extends DataFrameAggregateSuite with BeforeAndAfter { | ||
|
|
||
| protected override def beforeAll(): Unit = { | ||
| sparkConf.set("spark.sql.codegen.fallback", "false") | ||
| sparkConf.set("spark.sql.codegen.aggregate.map.twolevel.enable", "true") | ||
| super.beforeAll() | ||
| } | ||
|
|
||
| // adding some checking after each test is run, assuring that the configs are not changed | ||
| // in test code | ||
| after { | ||
| assert(sparkConf.get("spark.sql.codegen.fallback") == "false", | ||
| "configuration parameter changed in test body") | ||
| assert(sparkConf.get("spark.sql.codegen.aggregate.map.twolevel.enable") == "true", | ||
| "configuration parameter changed in test body") | ||
| } | ||
| } | ||
|
|
||
| class TwoLevelAggregateHashMapWithVectorizedMapSuite extends DataFrameAggregateSuite with | ||
| BeforeAndAfter { | ||
|
|
||
| protected override def beforeAll(): Unit = { | ||
| sparkConf.set("spark.sql.codegen.fallback", "false") | ||
| sparkConf.set("spark.sql.codegen.aggregate.map.twolevel.enable", "true") | ||
| sparkConf.set("spark.sql.codegen.aggregate.map.vectorized.enable", "true") | ||
| super.beforeAll() | ||
| } | ||
|
|
||
| // adding some checking after each test is run, assuring that the configs are not changed | ||
| // in test code | ||
| after { | ||
| assert(sparkConf.get("spark.sql.codegen.fallback") == "false", | ||
| "configuration parameter changed in test body") | ||
| assert(sparkConf.get("spark.sql.codegen.aggregate.map.twolevel.enable") == "true", | ||
| "configuration parameter changed in test body") | ||
| assert(sparkConf.get("spark.sql.codegen.aggregate.map.vectorized.enable") == "true", | ||
| "configuration parameter changed in test body") | ||
| } | ||
| } | ||
|
|
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
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.
Can we add a regression test for this in [sql]?