2020-02-11 18:27:52 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-02-17 17:08:31 +00:00
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
#include <Core/Block.h>
|
2020-02-11 18:27:52 +00:00
|
|
|
#include <Interpreters/IJoin.h>
|
|
|
|
#include <Interpreters/AnalyzedJoin.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class JoinSwitcher : public IJoin
|
|
|
|
{
|
|
|
|
public:
|
2020-02-17 17:21:03 +00:00
|
|
|
JoinSwitcher(std::shared_ptr<AnalyzedJoin> table_join_, const Block & right_sample_block_);
|
2020-02-11 18:27:52 +00:00
|
|
|
|
2020-02-17 17:08:31 +00:00
|
|
|
bool addJoinedBlock(const Block & block, bool check_limits = true) override;
|
2020-02-11 18:27:52 +00:00
|
|
|
|
|
|
|
void joinBlock(Block & block, std::shared_ptr<ExtraBlock> & not_processed) override
|
|
|
|
{
|
|
|
|
join->joinBlock(block, not_processed);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasTotals() const override
|
|
|
|
{
|
|
|
|
return join->hasTotals();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setTotals(const Block & block) override
|
|
|
|
{
|
|
|
|
join->setTotals(block);
|
|
|
|
}
|
|
|
|
|
|
|
|
void joinTotals(Block & block) const override
|
|
|
|
{
|
|
|
|
join->joinTotals(block);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t getTotalRowCount() const override
|
|
|
|
{
|
|
|
|
return join->getTotalRowCount();
|
|
|
|
}
|
|
|
|
|
2020-02-17 17:08:31 +00:00
|
|
|
size_t getTotalByteCount() const override
|
|
|
|
{
|
|
|
|
return join->getTotalByteCount();
|
|
|
|
}
|
|
|
|
|
2020-02-11 18:27:52 +00:00
|
|
|
bool alwaysReturnsEmptySet() const override
|
|
|
|
{
|
|
|
|
return join->alwaysReturnsEmptySet();
|
|
|
|
}
|
|
|
|
|
|
|
|
BlockInputStreamPtr createStreamWithNonJoinedRows(const Block & block, UInt64 max_block_size) const override
|
|
|
|
{
|
|
|
|
return join->createStreamWithNonJoinedRows(block, max_block_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasStreamWithNonJoinedRows() const override
|
|
|
|
{
|
|
|
|
return join->hasStreamWithNonJoinedRows();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
JoinPtr join;
|
2020-02-17 17:08:31 +00:00
|
|
|
bool switched;
|
2020-02-18 14:19:13 +00:00
|
|
|
SizeLimits limits;
|
2020-02-17 17:08:31 +00:00
|
|
|
mutable std::mutex switch_mutex;
|
|
|
|
std::shared_ptr<AnalyzedJoin> table_join;
|
2020-02-18 12:41:23 +00:00
|
|
|
const Block right_sample_block;
|
2020-02-17 17:08:31 +00:00
|
|
|
|
|
|
|
void switchJoin();
|
2020-02-11 18:27:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|