aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Dictionaries/RedisDictionarySource.h
blob: a55f220321d4727a47c41f9a54037840cf6e36d7 (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
#pragma once

#include <Core/Block.h>
#include <base/BorrowedObjectPool.h>

#include "DictionaryStructure.h"
#include "IDictionarySource.h"
#include <Storages/RedisCommon.h>

namespace DB
{
    namespace ErrorCodes
    {
        extern const int NOT_IMPLEMENTED;
    }

    class RedisDictionarySource final : public IDictionarySource
    {
    public:
        RedisDictionarySource(
            const DictionaryStructure & dict_struct_,
            const RedisConfiguration & configuration_,
            const Block & sample_block_);

        RedisDictionarySource(const RedisDictionarySource & other);

        ~RedisDictionarySource() override;

        QueryPipeline loadAll() override;

        QueryPipeline loadUpdatedAll() override
        {
            throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Method loadUpdatedAll is unsupported for RedisDictionarySource");
        }

        bool supportsSelectiveLoad() const override { return true; }

        QueryPipeline loadIds(const std::vector<UInt64> & ids) override;

        QueryPipeline loadKeys(const Columns & key_columns, const std::vector<size_t> & requested_rows) override;

        bool isModified() const override { return true; }

        bool hasUpdateField() const override { return false; }

        DictionarySourcePtr clone() const override { return std::make_shared<RedisDictionarySource>(*this); }

        std::string toString() const override;

    private:
        const DictionaryStructure dict_struct;
        const RedisConfiguration configuration;

        RedisPoolPtr pool;
        Block sample_block;
    };
}