2019-09-09 19:43:37 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
2019-09-10 14:51:28 +00:00
|
|
|
#include <shared_mutex>
|
2019-09-09 19:43:37 +00:00
|
|
|
|
|
|
|
#include <Core/Block.h>
|
|
|
|
#include <Interpreters/IJoin.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class AnalyzedJoin;
|
|
|
|
|
|
|
|
class MergeJoin : public IJoin
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MergeJoin(const AnalyzedJoin & table_join_, const Block & right_sample_block);
|
|
|
|
|
2019-09-10 14:51:28 +00:00
|
|
|
bool addJoinedBlock(const Block & block) override;
|
|
|
|
void joinBlock(Block &) override;
|
2019-09-09 19:43:37 +00:00
|
|
|
void joinTotals(Block &) const override {}
|
|
|
|
void setTotals(const Block &) override {}
|
2019-09-10 14:51:28 +00:00
|
|
|
size_t getTotalRowCount() const override { return right_blocks_row_count; }
|
2019-09-09 19:43:37 +00:00
|
|
|
|
|
|
|
private:
|
2019-09-10 14:51:28 +00:00
|
|
|
mutable std::shared_mutex rwlock;
|
2019-09-09 19:43:37 +00:00
|
|
|
const AnalyzedJoin & table_join;
|
|
|
|
Block sample_block_with_columns_to_add;
|
|
|
|
BlocksList right_blocks;
|
2019-09-10 14:51:28 +00:00
|
|
|
size_t right_blocks_row_count = 0;
|
|
|
|
size_t right_blocks_bytes = 0;
|
2019-09-09 19:43:37 +00:00
|
|
|
|
2019-09-10 14:51:28 +00:00
|
|
|
void addRightColumns(Block & block);
|
|
|
|
void mergeJoin(Block & block, const Block & right_block);
|
2019-09-09 19:43:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|