Created
August 28, 2017 18:09
-
-
Save alexey-milovidov/c3ddfe91b17dcce28f935dc0a1322375 to your computer and use it in GitHub Desktop.
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
:) SELECT number % 3 AS key, number AS x FROM system.numbers LIMIT 10 | |
SELECT | |
number % 3 AS key, | |
number AS x | |
FROM system.numbers | |
LIMIT 10 | |
┌─key─┬─x─┐ | |
│ 0 │ 0 │ | |
│ 1 │ 1 │ | |
│ 2 │ 2 │ | |
│ 0 │ 3 │ | |
│ 1 │ 4 │ | |
│ 2 │ 5 │ | |
│ 0 │ 6 │ | |
│ 1 │ 7 │ | |
│ 2 │ 8 │ | |
│ 0 │ 9 │ | |
└─────┴───┘ | |
10 rows in set. Elapsed: 0.008 sec. | |
:) SELECT key, sum(x) FROM (SELECT number % 3 AS key, number AS x FROM system.numbers LIMIT 10) GROUP BY key | |
SELECT | |
key, | |
sum(x) | |
FROM | |
( | |
SELECT | |
number % 3 AS key, | |
number AS x | |
FROM system.numbers | |
LIMIT 10 | |
) | |
GROUP BY key | |
┌─key─┬─sum(x)─┐ | |
│ 0 │ 18 │ | |
│ 1 │ 12 │ | |
│ 2 │ 15 │ | |
└─────┴────────┘ | |
3 rows in set. Elapsed: 0.014 sec. | |
... | |
2017.08.28 21:05:03.886232 [ 19 ] <Trace> Aggregator: Aggregation method: key8 | |
... | |
Aggregator.h | |
struct AggregatedDataVariants | |
... | |
std::unique_ptr<AggregationMethodOneNumber<UInt8, AggregatedDataWithUInt8Key>> key8; | |
AggregationMethodOneNumber<UInt8, AggregatedDataWithUInt8Key> | |
using AggregatedDataWithUInt8Key = HashMap<UInt64, AggregateDataPtr, TrivialHash, HashTableFixedGrower<8>>; | |
В HashMap будет лежать три значения. | |
AggregateDataPtr будет указывать на AggregateFunctionSumData<UInt64> | |
(Которые будут расположены в Arena.) | |
А в них будут просуммированы числа: 18, 12, 15. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment