ClickHouse/dbms/src/Dictionaries/LibraryDictionarySource.h
proller dd2371e071 CLICKHOUSE-4137 DictionaryFactory, DictionarySourceFactory (#3653)
* Split ComplexKeyCacheDictionary to faster compile (part2)

* Dictionaries as lib WIP

* wip

* clean

* Fix build with old capnp

* fix

* wip

* fixes

* fix

* clean

* clean

* clean

* wip

* wip

* wip

* flat

* wip

* cache

* clean

* wip

* faster

* fix style

* fixes

* clean

* clean

* Split CacheDictionary.cpp for faster compile

* fix

* fix

* Less memory usage while compiling

* missing file

* format

* Update registerDictionaries.h

* clean
2018-11-28 14:37:12 +03:00

83 lines
2.0 KiB
C++

#pragma once
#include "DictionaryStructure.h"
#include "ExternalResultDescription.h"
#include "IDictionarySource.h"
#include <Common/SharedLibrary.h>
#include <common/LocalDateTime.h>
namespace Poco
{
class Logger;
namespace Util
{
class AbstractConfiguration;
}
}
namespace DB
{
class CStringsHolder;
/// Allows loading dictionaries from dynamic libraries (.so)
/// Experimental version
/// Example: dbms/tests/external_dictionaries/dictionary_library/dictionary_library.cpp
class LibraryDictionarySource final : public IDictionarySource
{
public:
LibraryDictionarySource(const DictionaryStructure & dict_struct_,
const Poco::Util::AbstractConfiguration & config,
const std::string & config_prefix,
Block & sample_block,
const Context & context);
LibraryDictionarySource(const LibraryDictionarySource & other);
~LibraryDictionarySource() override;
BlockInputStreamPtr loadAll() override;
BlockInputStreamPtr loadUpdatedAll() override
{
throw Exception{"Method loadUpdatedAll is unsupported for LibraryDictionarySource", ErrorCodes::NOT_IMPLEMENTED};
}
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;
///Not yet supported
bool hasUpdateField() const override
{
return false;
}
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;
const Context & context;
SharedLibraryPtr library;
ExternalResultDescription description;
std::shared_ptr<CStringsHolder> settings;
void * lib_data = nullptr;
};
}