aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Dictionaries/Embedded/GeodataProviders/NamesProvider.h
blob: 2d49cceab869d6d05e04621d78560f472800f752 (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
#pragma once

#include <Common/FileUpdatesTracker.h>
#include "INamesProvider.h"


// Represents local file with list of regions ids / names
class LanguageRegionsNamesDataSource : public ILanguageRegionsNamesDataSource
{
private:
    std::string path;
    FileUpdatesTracker updates_tracker;
    std::string language;

public:
    LanguageRegionsNamesDataSource(const std::string & path_, const std::string & language_)
        : path(path_), updates_tracker(path_), language(language_)
    {
    }

    bool isModified() const override;

    size_t estimateTotalSize() const override;

    ILanguageRegionsNamesReaderPtr createReader() override;

    std::string getLanguage() const override;

    std::string getSourceName() const override;
};

using ILanguageRegionsNamesDataSourcePtr = std::unique_ptr<ILanguageRegionsNamesDataSource>;


// Provides access to directory with multiple data source files: one file per language
class RegionsNamesDataProvider : public IRegionsNamesDataProvider
{
private:
    std::string directory;

public:
    explicit RegionsNamesDataProvider(const std::string & directory_);

    ILanguageRegionsNamesDataSourcePtr getLanguageRegionsNamesSource(const std::string & language) const override;

private:
    std::string getDataFilePath(const std::string & language) const;
};