mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 04:12:19 +00:00
AggregateFunctionTopK: smaller initial table size
By default start with 2^4 elements
This commit is contained in:
parent
74cc0849dc
commit
95d926ec14
@ -21,8 +21,8 @@ namespace DB
|
|||||||
|
|
||||||
|
|
||||||
// Allow NxK more space before calculating top K to increase accuracy
|
// 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_LOAD_FACTOR 3
|
||||||
#define TOP_K_DEFAULT_DEGREE 10
|
|
||||||
#define TOP_K_MAX_SIZE 0xFFFFFF
|
#define TOP_K_MAX_SIZE 0xFFFFFF
|
||||||
|
|
||||||
|
|
||||||
@ -34,8 +34,8 @@ struct AggregateFunctionTopKData
|
|||||||
T,
|
T,
|
||||||
T,
|
T,
|
||||||
HashCRC32<T>,
|
HashCRC32<T>,
|
||||||
HashTableGrower<TOP_K_DEFAULT_DEGREE>,
|
HashTableGrower<4>,
|
||||||
HashTableAllocatorWithStackMemory<sizeof(T) * (1 << (TOP_K_DEFAULT_DEGREE/2))>
|
HashTableAllocatorWithStackMemory<sizeof(T) * (1 << 4)>
|
||||||
>;
|
>;
|
||||||
Set value;
|
Set value;
|
||||||
};
|
};
|
||||||
@ -47,7 +47,7 @@ class AggregateFunctionTopK
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
using State = AggregateFunctionTopKData<T>;
|
using State = AggregateFunctionTopKData<T>;
|
||||||
size_t threshold = TOP_K_DEFAULT_DEGREE;
|
size_t threshold = TOP_K_DEFAULT;
|
||||||
size_t reserved = TOP_K_LOAD_FACTOR * threshold;
|
size_t reserved = TOP_K_LOAD_FACTOR * threshold;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -132,8 +132,8 @@ struct AggregateFunctionTopKGenericData
|
|||||||
std::string,
|
std::string,
|
||||||
StringRef,
|
StringRef,
|
||||||
StringRefHash,
|
StringRefHash,
|
||||||
HashTableGrower<TOP_K_DEFAULT_DEGREE>,
|
HashTableGrower<4>,
|
||||||
HashTableAllocatorWithStackMemory<sizeof(StringRef) * (1 << (TOP_K_DEFAULT_DEGREE/2))>
|
HashTableAllocatorWithStackMemory<sizeof(StringRef) * (1 << 4)>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
Set value;
|
Set value;
|
||||||
@ -148,7 +148,7 @@ class AggregateFunctionTopKGeneric : public IUnaryAggregateFunction<AggregateFun
|
|||||||
private:
|
private:
|
||||||
using State = AggregateFunctionTopKGenericData;
|
using State = AggregateFunctionTopKGenericData;
|
||||||
DataTypePtr input_data_type;
|
DataTypePtr input_data_type;
|
||||||
size_t threshold = TOP_K_DEFAULT_DEGREE;
|
size_t threshold = TOP_K_DEFAULT;
|
||||||
size_t reserved = TOP_K_LOAD_FACTOR * threshold;
|
size_t reserved = TOP_K_LOAD_FACTOR * threshold;
|
||||||
|
|
||||||
static void deserializeAndInsert(StringRef str, IColumn & data_to);
|
static void deserializeAndInsert(StringRef str, IColumn & data_to);
|
||||||
@ -254,6 +254,7 @@ inline void AggregateFunctionTopKGeneric<true>::deserializeAndInsert(StringRef s
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#undef TOP_K_DEFAULT
|
||||||
#undef TOP_K_MAX_SIZE
|
#undef TOP_K_MAX_SIZE
|
||||||
#undef TOP_K_LOAD_FACTOR
|
#undef TOP_K_LOAD_FACTOR
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user