ClickHouse/src/Storages/StorageExecutable.h

73 lines
2.0 KiB
C++
Raw Normal View History

2021-04-14 17:51:55 +00:00
#pragma once
2021-10-02 07:13:14 +00:00
#include <base/logger_useful.h>
#include <base/shared_ptr_helper.h>
2021-04-14 17:51:55 +00:00
#include <Storages/IStorage.h>
2021-10-15 20:18:20 +00:00
#include <Processors/Sources/ShellCommandSource.h>
#include <Storages/ExecutableSettings.h>
2021-08-24 19:38:42 +00:00
2021-04-14 17:51:55 +00:00
namespace DB
{
2021-09-02 11:53:20 +00:00
2021-04-14 17:51:55 +00:00
/**
* This class represents table engine for external executable files.
2021-09-02 11:53:20 +00:00
* Executable storage that will start process for read.
* ExecutablePool storage maintain pool of processes and take process from pool for read.
2021-04-14 17:51:55 +00:00
*/
2021-08-24 19:38:42 +00:00
class StorageExecutable final : public shared_ptr_helper<StorageExecutable>, public IStorage
2021-04-14 17:51:55 +00:00
{
2021-08-24 19:38:42 +00:00
friend struct shared_ptr_helper<StorageExecutable>;
2021-09-03 10:00:40 +00:00
2021-04-14 17:51:55 +00:00
public:
2021-09-02 11:53:20 +00:00
String getName() const override
{
if (process_pool)
return "ExecutablePool";
else
return "Executable";
}
2021-04-14 17:51:55 +00:00
Pipe read(
const Names & column_names,
const StorageMetadataPtr & /*metadata_snapshot*/,
SelectQueryInfo & query_info,
2021-08-24 19:38:42 +00:00
ContextPtr context,
2021-04-14 17:51:55 +00:00
QueryProcessingStage::Enum processed_stage,
size_t max_block_size,
2021-08-24 19:38:42 +00:00
unsigned threads) override;
2021-04-14 17:51:55 +00:00
protected:
2021-09-03 10:00:40 +00:00
2021-04-14 17:51:55 +00:00
StorageExecutable(
const StorageID & table_id,
2021-08-25 19:30:22 +00:00
const String & script_name_,
const std::vector<String> & arguments_,
2021-04-15 21:15:54 +00:00
const String & format_,
const std::vector<ASTPtr> & input_queries_,
2021-04-14 17:51:55 +00:00
const ColumnsDescription & columns,
2021-08-24 19:38:42 +00:00
const ConstraintsDescription & constraints);
2021-04-14 17:51:55 +00:00
2021-09-02 11:53:20 +00:00
StorageExecutable(
const StorageID & table_id,
const String & script_name_,
const std::vector<String> & arguments_,
const String & format_,
const std::vector<ASTPtr> & input_queries_,
const ExecutableSettings & settings_,
2021-09-02 11:53:20 +00:00
const ColumnsDescription & columns,
const ConstraintsDescription & constraints);
2021-04-14 17:51:55 +00:00
private:
2021-08-25 19:30:22 +00:00
String script_name;
std::vector<String> arguments;
2021-04-15 21:15:54 +00:00
String format;
std::vector<ASTPtr> input_queries;
ExecutableSettings settings;
2021-09-02 11:53:20 +00:00
std::shared_ptr<ProcessPool> process_pool;
2021-08-24 19:38:42 +00:00
Poco::Logger * log;
2021-04-14 17:51:55 +00:00
};
2021-09-02 11:53:20 +00:00
}