2019-02-22 17:45:56 +00:00
|
|
|
#pragma once
|
|
|
|
#include <Processors/ISimpleTransform.h>
|
|
|
|
#include <Common/HashTable/HashMap.h>
|
2021-04-25 09:30:43 +00:00
|
|
|
|
2019-02-22 17:45:56 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-06-22 10:18:28 +00:00
|
|
|
/// Executes LIMIT BY for specified columns.
|
2019-02-22 17:45:56 +00:00
|
|
|
class LimitByTransform : public ISimpleTransform
|
|
|
|
{
|
|
|
|
public:
|
2020-07-12 05:18:01 +00:00
|
|
|
LimitByTransform(const Block & header, UInt64 group_length_, UInt64 group_offset_, const Names & columns);
|
2019-02-22 17:45:56 +00:00
|
|
|
|
|
|
|
String getName() const override { return "LimitByTransform"; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void transform(Chunk & chunk) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
using MapHashed = HashMap<UInt128, UInt64, UInt128TrivialHash>;
|
|
|
|
|
|
|
|
MapHashed keys_counts;
|
|
|
|
std::vector<size_t> key_positions;
|
2020-07-12 05:18:01 +00:00
|
|
|
const UInt64 group_length;
|
|
|
|
const UInt64 group_offset;
|
2019-02-22 17:45:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|