From 0592081f2fe4b550c28d06dc8b017b34b64bdbbf Mon Sep 17 00:00:00 2001 From: Ivan Lezhankin Date: Thu, 25 Oct 2018 16:17:29 +0300 Subject: [PATCH] Reduce maximum allowable size of |HashSet|. --- .../AggregateFunctions/AggregateFunctionUniqCombined.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dbms/src/AggregateFunctions/AggregateFunctionUniqCombined.h b/dbms/src/AggregateFunctions/AggregateFunctionUniqCombined.h index f15c4e7e453..99cc3a93890 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionUniqCombined.h +++ b/dbms/src/AggregateFunctions/AggregateFunctionUniqCombined.h @@ -71,7 +71,11 @@ struct AggregateFunctionUniqCombinedDataWithKey { // TODO(ilezhankin): pre-generate values for |UniqCombinedBiasData|, // at the moment gen-bias-data.py script doesn't work. - using Set = CombinedCardinalityEstimator>, 16, K - 3, K, TrivialHash, Key>; + + // We want to migrate from |HashSet| to |HyperLogLogCounter| when the sizes in memory become almost equal. + // The size per element in |HashSet| is sizeof(Key)*2 bytes, and the overall size of |HyperLogLogCounter| is 2^K * 6 bits. + // For Key=UInt32 we can calculate: 2^X * 4 * 2 ≤ 2^(K-3) * 6 ⇒ X ≤ K-4. + using Set = CombinedCardinalityEstimator>, 16, K - 4, K, TrivialHash, Key>; Set set; }; @@ -82,7 +86,7 @@ struct AggregateFunctionUniqCombinedDataWithKey using Set = CombinedCardinalityEstimator>, 16, - 14, + 13, 17, TrivialHash, Key,