From 95d926ec147d0ef323540e573f20122ff77829df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Vavru=C5=A1a?= Date: Fri, 12 May 2017 13:38:03 -0700 Subject: [PATCH] AggregateFunctionTopK: smaller initial table size By default start with 2^4 elements --- .../AggregateFunctions/AggregateFunctionTopK.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dbms/src/AggregateFunctions/AggregateFunctionTopK.h b/dbms/src/AggregateFunctions/AggregateFunctionTopK.h index e616f0436b9..f8143cbe7b4 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionTopK.h +++ b/dbms/src/AggregateFunctions/AggregateFunctionTopK.h @@ -21,8 +21,8 @@ namespace DB // Allow NxK more space before calculating top K to increase accuracy +#define TOP_K_DEFAULT 10 #define TOP_K_LOAD_FACTOR 3 -#define TOP_K_DEFAULT_DEGREE 10 #define TOP_K_MAX_SIZE 0xFFFFFF @@ -34,8 +34,8 @@ struct AggregateFunctionTopKData T, T, HashCRC32, - HashTableGrower, - HashTableAllocatorWithStackMemory + HashTableGrower<4>, + HashTableAllocatorWithStackMemory >; Set value; }; @@ -47,7 +47,7 @@ class AggregateFunctionTopK { private: using State = AggregateFunctionTopKData; - size_t threshold = TOP_K_DEFAULT_DEGREE; + size_t threshold = TOP_K_DEFAULT; size_t reserved = TOP_K_LOAD_FACTOR * threshold; public: @@ -132,8 +132,8 @@ struct AggregateFunctionTopKGenericData std::string, StringRef, StringRefHash, - HashTableGrower, - HashTableAllocatorWithStackMemory + HashTableGrower<4>, + HashTableAllocatorWithStackMemory >; Set value; @@ -148,7 +148,7 @@ class AggregateFunctionTopKGeneric : public IUnaryAggregateFunction::deserializeAndInsert(StringRef s } +#undef TOP_K_DEFAULT #undef TOP_K_MAX_SIZE #undef TOP_K_LOAD_FACTOR