ClickHouse/src/Storages/StorageExecutable.h

59 lines
1.5 KiB
C++
Raw Normal View History

2021-04-14 17:51:55 +00:00
#pragma once
2022-04-27 15:05:45 +00:00
#include <Common/logger_useful.h>
2021-10-02 07:13:14 +00:00
#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
{
2021-12-28 09:43:30 +00:00
if (settings.is_executable_pool)
2021-09-02 11:53:20 +00:00
return "ExecutablePool";
else
return "Executable";
}
2021-04-14 17:51:55 +00:00
Pipe read(
const Names & column_names,
2021-09-09 11:27:10 +00:00
const StorageSnapshotPtr & /*storage_snapshot*/,
2021-04-14 17:51:55 +00:00
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-11-01 11:22:21 +00:00
const String & format,
const ExecutableSettings & settings,
const std::vector<ASTPtr> & input_queries,
2021-09-02 11:53:20 +00:00
const ColumnsDescription & columns,
const ConstraintsDescription & constraints);
2021-04-14 17:51:55 +00:00
private:
ExecutableSettings settings;
2021-11-01 11:22:21 +00:00
std::vector<ASTPtr> input_queries;
2021-08-24 19:38:42 +00:00
Poco::Logger * log;
2021-12-28 09:43:30 +00:00
std::unique_ptr<ShellCommandSourceCoordinator> coordinator;
2021-04-14 17:51:55 +00:00
};
2021-09-02 11:53:20 +00:00
}