2019-07-18 14:41:11 +00:00
|
|
|
#pragma once
|
2021-06-25 16:22:39 +00:00
|
|
|
#include <Storages/MergeTree/MergeTreeSelectProcessor.h>
|
2019-07-18 14:41:11 +00:00
|
|
|
|
2021-07-17 18:06:46 +00:00
|
|
|
|
2019-07-18 14:41:11 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/// Used to read data from single part with select query
|
2021-06-25 16:22:39 +00:00
|
|
|
/// in reverse order of primary key.
|
2019-07-18 14:41:11 +00:00
|
|
|
/// Cares about PREWHERE, virtual columns, indexes etc.
|
|
|
|
/// To read data from multiple parts, Storage (MergeTree) creates multiple such objects.
|
2021-07-16 14:11:34 +00:00
|
|
|
class MergeTreeReverseSelectProcessor final : public MergeTreeSelectProcessor
|
2019-07-18 14:41:11 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-07-16 14:11:34 +00:00
|
|
|
template <typename... Args>
|
2021-12-09 10:39:28 +00:00
|
|
|
explicit MergeTreeReverseSelectProcessor(Args &&... args)
|
2021-07-16 14:11:34 +00:00
|
|
|
: MergeTreeSelectProcessor{std::forward<Args>(args)...}
|
|
|
|
{
|
2022-02-04 14:53:20 +00:00
|
|
|
LOG_TRACE(log, "Reading {} ranges in reverse order from part {}, approx. {} rows starting from {}",
|
2021-07-16 14:11:34 +00:00
|
|
|
all_mark_ranges.size(), data_part->name, total_rows,
|
|
|
|
data_part->index_granularity.getMarkStartingRow(all_mark_ranges.front().begin));
|
|
|
|
}
|
2019-07-18 14:41:11 +00:00
|
|
|
|
|
|
|
String getName() const override { return "MergeTreeReverse"; }
|
|
|
|
|
2021-06-25 16:22:39 +00:00
|
|
|
private:
|
2021-12-09 10:39:28 +00:00
|
|
|
bool getNewTaskImpl() override;
|
|
|
|
void finalizeNewTask() override {}
|
|
|
|
|
2019-10-01 16:50:08 +00:00
|
|
|
Chunk readFromPart() override;
|
2019-07-18 14:41:11 +00:00
|
|
|
|
2019-10-01 16:50:08 +00:00
|
|
|
Chunks chunks;
|
2020-05-30 21:57:37 +00:00
|
|
|
Poco::Logger * log = &Poco::Logger::get("MergeTreeReverseSelectProcessor");
|
2019-07-18 14:41:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|