ClickHouse/dbms/include/DB/Dictionaries/FileDictionarySource.h

53 lines
1.4 KiB
C++
Raw Normal View History

#pragma once
#include <DB/Dictionaries/IDictionarySource.h>
#include <Poco/Timestamp.h>
2016-12-08 02:49:04 +00:00
namespace DB
{
2016-12-08 02:49:04 +00:00
class Context;
/// Allows loading dictionaries from a file with given format, does not support "random access"
class FileDictionarySource final : public IDictionarySource
{
public:
FileDictionarySource(const std::string & filename, const std::string & format, Block & sample_block,
2016-12-08 02:49:04 +00:00
const Context & context);
2016-12-08 02:49:04 +00:00
FileDictionarySource(const FileDictionarySource & other);
2016-12-08 02:49:04 +00:00
BlockInputStreamPtr loadAll() override;
BlockInputStreamPtr loadIds(const std::vector<UInt64> & ids) override
{
2016-12-08 02:49:04 +00:00
throw Exception{"Method loadIds is unsupported for FileDictionarySource", ErrorCodes::NOT_IMPLEMENTED};
}
BlockInputStreamPtr loadKeys(
const ConstColumnPlainPtrs & key_columns, const std::vector<std::size_t> & requested_rows) override
{
2016-12-08 02:49:04 +00:00
throw Exception{"Method loadKeys is unsupported for FileDictionarySource", ErrorCodes::NOT_IMPLEMENTED};
}
bool isModified() const override { return getLastModification() > last_modification; }
bool supportsSelectiveLoad() const override { return false; }
2015-02-10 21:10:58 +00:00
DictionarySourcePtr clone() const override { return std::make_unique<FileDictionarySource>(*this); }
2016-12-08 02:49:04 +00:00
std::string toString() const override;
private:
2016-12-08 02:49:04 +00:00
Poco::Timestamp getLastModification() const;
const std::string filename;
const std::string format;
Block sample_block;
const Context & context;
Poco::Timestamp last_modification;
};
}