ClickHouse/dbms/src/Interpreters/JoinSwitcher.h

76 lines
1.6 KiB
C++
Raw Normal View History

2020-02-11 18:27:52 +00:00
#pragma once
#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
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();
}
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;
SizeLimits limits;
2020-02-19 14:23:21 +00:00
mutable std::atomic<bool> switched;
mutable std::mutex switch_mutex;
std::shared_ptr<AnalyzedJoin> table_join;
2020-02-18 12:41:23 +00:00
const Block right_sample_block;
void switchJoin();
2020-02-11 18:27:52 +00:00
};
}