2021-02-28 21:04:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-04-12 20:36:13 +00:00
|
|
|
|
2021-02-28 21:04:05 +00:00
|
|
|
#include <Core/Block.h>
|
|
|
|
#include <Interpreters/Context.h>
|
|
|
|
|
2021-09-02 11:53:20 +00:00
|
|
|
#include <Dictionaries/IDictionarySource.h>
|
|
|
|
#include <Dictionaries/DictionaryStructure.h>
|
2021-10-15 20:18:20 +00:00
|
|
|
#include <Processors/Sources/ShellCommandSource.h>
|
2021-02-28 21:04:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2021-03-01 09:32:13 +00:00
|
|
|
/** ExecutablePoolDictionarySource allows loading data from pool of processes.
|
|
|
|
* When client requests ids or keys source get process from ProcessPool
|
|
|
|
* and create stream based on source format from process stdout.
|
|
|
|
* It is important that stream format will expect only rows that were requested.
|
|
|
|
* When stream is finished process is returned back to the ProcessPool.
|
|
|
|
* If there are no processes in pool during request client will be blocked
|
2021-06-11 08:28:49 +00:00
|
|
|
* until some process will be returned to pool.
|
2021-03-01 09:32:13 +00:00
|
|
|
*/
|
2021-02-28 21:04:05 +00:00
|
|
|
class ExecutablePoolDictionarySource final : public IDictionarySource
|
|
|
|
{
|
|
|
|
public:
|
2021-03-06 18:45:51 +00:00
|
|
|
struct Configuration
|
|
|
|
{
|
2021-09-09 22:04:52 +00:00
|
|
|
String command;
|
2021-12-25 13:34:17 +00:00
|
|
|
std::vector<String> command_arguments;
|
2021-09-09 22:04:52 +00:00
|
|
|
bool implicit_key;
|
2021-03-06 18:45:51 +00:00
|
|
|
};
|
|
|
|
|
2021-02-28 21:04:05 +00:00
|
|
|
ExecutablePoolDictionarySource(
|
|
|
|
const DictionaryStructure & dict_struct_,
|
2021-03-06 18:45:51 +00:00
|
|
|
const Configuration & configuration_,
|
2021-02-28 21:04:05 +00:00
|
|
|
Block & sample_block_,
|
2021-12-28 09:43:30 +00:00
|
|
|
std::shared_ptr<ShellCommandSourceCoordinator> coordinator_,
|
2021-06-01 12:20:52 +00:00
|
|
|
ContextPtr context_);
|
2021-02-28 21:04:05 +00:00
|
|
|
|
|
|
|
ExecutablePoolDictionarySource(const ExecutablePoolDictionarySource & other);
|
|
|
|
ExecutablePoolDictionarySource & operator=(const ExecutablePoolDictionarySource &) = delete;
|
|
|
|
|
2022-05-20 19:49:31 +00:00
|
|
|
QueryPipeline loadAll() override;
|
2021-02-28 21:04:05 +00:00
|
|
|
|
|
|
|
/** The logic of this method is flawed, absolutely incorrect and ignorant.
|
|
|
|
* It may lead to skipping some values due to clock sync or timezone changes.
|
|
|
|
* The intended usage of "update_field" is totally different.
|
|
|
|
*/
|
2022-05-20 19:49:31 +00:00
|
|
|
QueryPipeline loadUpdatedAll() override;
|
2021-02-28 21:04:05 +00:00
|
|
|
|
2022-05-20 19:49:31 +00:00
|
|
|
QueryPipeline loadIds(const std::vector<UInt64> & ids) override;
|
2021-02-28 21:04:05 +00:00
|
|
|
|
2022-05-20 19:49:31 +00:00
|
|
|
QueryPipeline loadKeys(const Columns & key_columns, const std::vector<size_t> & requested_rows) override;
|
2021-02-28 21:04:05 +00:00
|
|
|
|
|
|
|
bool isModified() const override;
|
|
|
|
|
|
|
|
bool supportsSelectiveLoad() const override;
|
|
|
|
|
|
|
|
bool hasUpdateField() const override;
|
|
|
|
|
|
|
|
DictionarySourcePtr clone() const override;
|
|
|
|
|
|
|
|
std::string toString() const override;
|
|
|
|
|
2022-05-20 19:49:31 +00:00
|
|
|
QueryPipeline getStreamForBlock(const Block & block);
|
2021-02-28 21:04:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const DictionaryStructure dict_struct;
|
2021-03-06 18:45:51 +00:00
|
|
|
const Configuration configuration;
|
2021-02-28 21:04:05 +00:00
|
|
|
|
|
|
|
Block sample_block;
|
2021-12-28 09:43:30 +00:00
|
|
|
std::shared_ptr<ShellCommandSourceCoordinator> coordinator;
|
2021-06-01 12:20:52 +00:00
|
|
|
ContextPtr context;
|
2024-01-23 17:04:50 +00:00
|
|
|
LoggerPtr log;
|
2021-02-28 21:04:05 +00:00
|
|
|
};
|
|
|
|
|
2021-08-06 08:41:45 +00:00
|
|
|
}
|