ClickHouse/dbms/include/DB/DataStreams/MergeSortingBlockInputStream.h
2012-10-20 02:10:47 +00:00

46 lines
1.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <Yandex/logger_useful.h>
#include <DB/Core/SortDescription.h>
#include <DB/DataStreams/IProfilingBlockInputStream.h>
namespace DB
{
/** Соединяет поток сортированных по отдельности блоков в сортированный целиком поток.
*/
class MergeSortingBlockInputStream : public IProfilingBlockInputStream
{
public:
MergeSortingBlockInputStream(BlockInputStreamPtr input_, SortDescription & description_)
: input(input_), description(description_), has_been_read(false), log(&Logger::get("MergeSortingBlockInputStream"))
{
children.push_back(input);
}
String getName() const { return "MergeSortingBlockInputStream"; }
BlockInputStreamPtr clone() { return new MergeSortingBlockInputStream(input, description); }
protected:
Block readImpl();
private:
BlockInputStreamPtr input;
SortDescription description;
/// Всё было прочитано.
bool has_been_read;
Logger * log;
/** Слить сразу много блоков с помощью priority queue.
*/
Block merge(Blocks & blocks);
};
}