ClickHouse/dbms/DataStreams/PartialSortingBlockInputStream.h

36 lines
901 B
C++
Raw Normal View History

2011-09-04 00:22:19 +00:00
#pragma once
#include <Core/SortDescription.h>
2011-09-04 00:22:19 +00:00
#include <DataStreams/IBlockInputStream.h>
2011-09-04 00:22:19 +00:00
namespace DB
{
2017-05-13 22:19:04 +00:00
/** Sorts each block individually by the values of the specified columns.
* At the moment, not very optimal algorithm is used.
2011-09-04 00:22:19 +00:00
*/
class PartialSortingBlockInputStream : public IBlockInputStream
2011-09-04 00:22:19 +00:00
{
public:
2017-05-13 22:19:04 +00:00
/// limit - if not 0, then you can sort each block not completely, but only `limit` first rows by order.
2019-02-10 15:17:45 +00:00
PartialSortingBlockInputStream(const BlockInputStreamPtr & input_, SortDescription & description_, UInt64 limit_ = 0)
: description(description_), limit(limit_)
{
children.push_back(input_);
}
2011-09-04 00:22:19 +00:00
String getName() const override { return "PartialSorting"; }
Block getHeader() const override { return children.at(0)->getHeader(); }
2012-10-20 02:10:47 +00:00
protected:
Block readImpl() override;
2012-10-20 02:10:47 +00:00
2011-09-04 00:22:19 +00:00
private:
SortDescription description;
2019-02-10 15:17:45 +00:00
UInt64 limit;
2011-09-04 00:22:19 +00:00
};
}