aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/DirectJoin.h
blob: 5f664314818156cbf50b40e26b664f960c223ce7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once


#include <Core/Block.h>

#include <Interpreters/IJoin.h>
#include <Interpreters/TableJoin.h>

#include <QueryPipeline/SizeLimits.h>

#include <Interpreters/IKeyValueEntity.h>
#include <Storages/IStorage_fwd.h>

namespace DB
{

class NotJoinedBlocks;

class DirectKeyValueJoin : public IJoin
{
public:
    DirectKeyValueJoin(
        std::shared_ptr<TableJoin> table_join_,
        const Block & right_sample_block_,
        std::shared_ptr<const IKeyValueEntity> storage_);

    DirectKeyValueJoin(
        std::shared_ptr<TableJoin> table_join_,
        const Block & right_sample_block_,
        std::shared_ptr<const IKeyValueEntity> storage_,
        const Block & right_sample_block_with_storage_column_names_);

    std::string getName() const override { return "DirectKeyValueJoin"; }
    virtual const TableJoin & getTableJoin() const override { return *table_join; }

    virtual bool addBlockToJoin(const Block &, bool) override;
    virtual void checkTypesOfKeys(const Block &) const override;

    /// Join the block with data from left hand of JOIN to the right hand data (that was previously built by calls to addBlockToJoin).
    /// Could be called from different threads in parallel.
    virtual void joinBlock(Block & block, std::shared_ptr<ExtraBlock> &) override;

    virtual size_t getTotalRowCount() const override { return 0; }

    virtual size_t getTotalByteCount() const override { return 0; }

    virtual bool alwaysReturnsEmptySet() const override { return false; }

    virtual bool isFilled() const override { return true; }

    virtual IBlocksStreamPtr
    getNonJoinedBlocks(const Block &, const Block &, UInt64) const override
    {
        return nullptr;
    }

private:
    std::shared_ptr<TableJoin> table_join;
    std::shared_ptr<const IKeyValueEntity> storage;
    Block right_sample_block;
    Block right_sample_block_with_storage_column_names;
    Block sample_block_with_columns_to_add;
    Poco::Logger * log;

};

}