2017-09-05 01:08:26 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-12-10 15:25:45 +00:00
|
|
|
#include <Common/SharedLibrary.h>
|
|
|
|
#include <common/LocalDateTime.h>
|
2018-11-28 11:37:12 +00:00
|
|
|
#include "DictionaryStructure.h"
|
|
|
|
#include "ExternalResultDescription.h"
|
|
|
|
#include "IDictionarySource.h"
|
2017-09-05 01:08:26 +00:00
|
|
|
|
2017-09-07 21:04:48 +00:00
|
|
|
|
2017-09-05 01:08:26 +00:00
|
|
|
namespace Poco
|
|
|
|
{
|
2018-03-13 23:13:39 +00:00
|
|
|
class Logger;
|
2017-12-09 06:32:22 +00:00
|
|
|
|
2018-03-13 23:13:39 +00:00
|
|
|
namespace Util
|
|
|
|
{
|
|
|
|
class AbstractConfiguration;
|
|
|
|
}
|
2017-09-05 01:08:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2017-09-05 17:13:00 +00:00
|
|
|
class CStringsHolder;
|
2017-09-05 01:08:26 +00:00
|
|
|
|
|
|
|
/// Allows loading dictionaries from dynamic libraries (.so)
|
|
|
|
/// Experimental version
|
2018-02-26 16:57:14 +00:00
|
|
|
/// Example: dbms/tests/external_dictionaries/dictionary_library/dictionary_library.cpp
|
2017-09-05 01:08:26 +00:00
|
|
|
class LibraryDictionarySource final : public IDictionarySource
|
|
|
|
{
|
|
|
|
public:
|
2018-12-10 15:25:45 +00:00
|
|
|
LibraryDictionarySource(
|
|
|
|
const DictionaryStructure & dict_struct_,
|
2017-09-05 01:08:26 +00:00
|
|
|
const Poco::Util::AbstractConfiguration & config,
|
|
|
|
const std::string & config_prefix,
|
2019-01-29 19:05:32 +00:00
|
|
|
Block & sample_block);
|
2017-09-05 01:08:26 +00:00
|
|
|
|
|
|
|
LibraryDictionarySource(const LibraryDictionarySource & other);
|
|
|
|
|
2018-06-03 20:39:06 +00:00
|
|
|
~LibraryDictionarySource() override;
|
2018-02-26 16:57:14 +00:00
|
|
|
|
2017-09-05 01:08:26 +00:00
|
|
|
BlockInputStreamPtr loadAll() override;
|
|
|
|
|
2018-02-15 13:08:23 +00:00
|
|
|
BlockInputStreamPtr loadUpdatedAll() override
|
|
|
|
{
|
|
|
|
throw Exception{"Method loadUpdatedAll is unsupported for LibraryDictionarySource", ErrorCodes::NOT_IMPLEMENTED};
|
|
|
|
}
|
|
|
|
|
2017-09-05 01:08:26 +00:00
|
|
|
BlockInputStreamPtr loadIds(const std::vector<UInt64> & ids) override;
|
|
|
|
|
|
|
|
BlockInputStreamPtr loadKeys(const Columns & key_columns, const std::vector<std::size_t> & requested_rows) override;
|
|
|
|
|
|
|
|
bool isModified() const override;
|
|
|
|
|
|
|
|
bool supportsSelectiveLoad() const override;
|
|
|
|
|
2018-01-15 12:44:39 +00:00
|
|
|
///Not yet supported
|
2018-12-10 15:25:45 +00:00
|
|
|
bool hasUpdateField() const override { return false; }
|
2018-01-15 12:44:39 +00:00
|
|
|
|
2017-09-05 01:08:26 +00:00
|
|
|
DictionarySourcePtr clone() const override;
|
|
|
|
|
|
|
|
std::string toString() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Poco::Logger * log;
|
|
|
|
|
|
|
|
LocalDateTime getLastModification() const;
|
|
|
|
|
|
|
|
const DictionaryStructure dict_struct;
|
|
|
|
const std::string config_prefix;
|
|
|
|
const std::string path;
|
|
|
|
Block sample_block;
|
|
|
|
SharedLibraryPtr library;
|
|
|
|
ExternalResultDescription description;
|
|
|
|
std::shared_ptr<CStringsHolder> settings;
|
2018-02-26 16:57:14 +00:00
|
|
|
void * lib_data = nullptr;
|
2017-09-05 01:08:26 +00:00
|
|
|
};
|
2018-11-28 11:37:12 +00:00
|
|
|
|
2017-09-05 01:08:26 +00:00
|
|
|
}
|