2011-09-04 00:22:19 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/SortDescription.h>
|
2011-09-04 00:22:19 +00:00
|
|
|
|
2019-01-23 14:48:50 +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
|
|
|
*/
|
2019-01-23 14:48:50 +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)
|
2017-04-01 07:20:54 +00:00
|
|
|
: description(description_), limit(limit_)
|
|
|
|
{
|
|
|
|
children.push_back(input_);
|
|
|
|
}
|
2011-09-04 00:22:19 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String getName() const override { return "PartialSorting"; }
|
2018-02-18 03:23:48 +00:00
|
|
|
Block getHeader() const override { return children.at(0)->getHeader(); }
|
2018-01-06 18:10:44 +00:00
|
|
|
|
2012-10-20 02:10:47 +00:00
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
Block readImpl() override;
|
2012-10-20 02:10:47 +00:00
|
|
|
|
2011-09-04 00:22:19 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
SortDescription description;
|
2019-02-10 15:17:45 +00:00
|
|
|
UInt64 limit;
|
2011-09-04 00:22:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|