ClickHouse/dbms/include/DB/DataStreams/MergeSortingBlockInputStream.h

39 lines
924 B
C
Raw Normal View History

2011-09-04 01:42:14 +00:00
#pragma once
#include <DB/Core/SortDescription.h>
2011-09-04 21:23:19 +00:00
#include <DB/DataStreams/IProfilingBlockInputStream.h>
2011-09-04 01:42:14 +00:00
namespace DB
{
/** Соединяет поток сортированных по отдельности блоков в сортированный целиком поток.
*/
2011-09-04 21:23:19 +00:00
class MergeSortingBlockInputStream : public IProfilingBlockInputStream
2011-09-04 01:42:14 +00:00
{
public:
MergeSortingBlockInputStream(BlockInputStreamPtr input_, SortDescription & description_)
2012-03-05 02:34:20 +00:00
: input(input_), description(description_), has_been_read(false)
2011-09-04 21:23:19 +00:00
{
children.push_back(input);
}
2011-09-04 01:42:14 +00:00
2011-09-04 21:23:19 +00:00
Block readImpl();
String getName() const { return "MergeSortingBlockInputStream"; }
2011-09-04 01:42:14 +00:00
2011-10-24 12:10:59 +00:00
BlockInputStreamPtr clone() { return new MergeSortingBlockInputStream(input, description); }
2011-09-04 01:42:14 +00:00
private:
BlockInputStreamPtr input;
SortDescription description;
2012-03-05 02:34:20 +00:00
/// Всё было прочитано
bool has_been_read;
2011-09-04 01:42:14 +00:00
void merge(Block & left, Block & right);
};
}