`SELECT toDateTime(topKWeighted(-9223372036854775807, '-0.02')(NULL), '104857.5') FROM remote('127.0\00\0{2,3}127.0\00\0{2,3}127.0\00\0{2,3}127.0\00\0{2,3}127.0\00\0{2,3}127.0\00\0{2,3}127.0\00\0{2,3}127.0\00\0{2,3}', system.one) ORDER BY length(topK(1048577)(tuple(NULL))) ASC, '0' ASC NULLS LAST`
: public IAggregateFunctionDataHelper<AggregateFunctionTopKData<T>, AggregateFunctionTopK<T, is_weighted>>
{
protected:
    using State = AggregateFunctionTopKData<T>;
    UInt64 threshold;
    UInt64 reserved;
public:
    AggregateFunctionTopK(UInt64 threshold_, UInt64 load_factor, const DataTypes & argument_types_, const Array & params)
        : IAggregateFunctionDataHelper<AggregateFunctionTopKData<T>, AggregateFunctionTopK<T, is_weighted>>(argument_types_, params)
        , threshold(threshold_), reserved(load_factor * threshold) {}
    String getName() const override { return is_weighted ? "topKWeighted" : "topK"; }
    DataTypePtr getReturnType() const override
    {
        return std::make_shared<DataTypeArray>(this->argument_types[0]);
    }
    bool allocatesMemoryInArena() const override { return false; }