From 03d77af9ec4ce9a42affd6ab4381ae5bd3c79a5a Mon Sep 17 00:00:00 2001 From: Qifan Pu Date: Thu, 1 Sep 2016 16:56:35 -0700 Subject: [SPARK-16525] [SQL] Enable Row Based HashMap in HashAggregateExec ## What changes were proposed in this pull request? This PR is the second step for the following feature: For hash aggregation in Spark SQL, we use a fast aggregation hashmap to act as a "cache" in order to boost aggregation performance. Previously, the hashmap is backed by a `ColumnarBatch`. This has performance issues when we have wide schema for the aggregation table (large number of key fields or value fields). In this JIRA, we support another implementation of fast hashmap, which is backed by a `RowBatch`. We then automatically pick between the two implementations based on certain knobs. In this second-step PR, we enable `RowBasedHashMapGenerator` in `HashAggregateExec`. ## How was this patch tested? Added tests: `RowBasedAggregateHashMapSuite` and ` VectorizedAggregateHashMapSuite` Additional micro-benchmarks tests and TPCDS results will be added in a separate PR in the series. Author: Qifan Pu Author: ooq Closes #14176 from ooq/rowbasedfastaggmap-pr2. --- .../catalyst/expressions/FixedLengthRowBasedKeyValueBatch.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sql/catalyst/src') diff --git a/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/FixedLengthRowBasedKeyValueBatch.java b/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/FixedLengthRowBasedKeyValueBatch.java index 85529f6a0a..a88a315bf4 100644 --- a/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/FixedLengthRowBasedKeyValueBatch.java +++ b/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/FixedLengthRowBasedKeyValueBatch.java @@ -165,10 +165,10 @@ public final class FixedLengthRowBasedKeyValueBatch extends RowBasedKeyValueBatc protected FixedLengthRowBasedKeyValueBatch(StructType keySchema, StructType valueSchema, int maxRows, TaskMemoryManager manager) { super(keySchema, valueSchema, maxRows, manager); - klen = keySchema.defaultSize() - + UnsafeRow.calculateBitSetWidthInBytes(keySchema.length()); - vlen = valueSchema.defaultSize() - + UnsafeRow.calculateBitSetWidthInBytes(valueSchema.length()); + int keySize = keySchema.size() * 8; // each fixed-length field is stored in a 8-byte word + int valueSize = valueSchema.size() * 8; + klen = keySize + UnsafeRow.calculateBitSetWidthInBytes(keySchema.length()); + vlen = valueSize + UnsafeRow.calculateBitSetWidthInBytes(valueSchema.length()); recordLength = klen + vlen + 8; } } -- cgit v1.2.3