| 1 | #pragma once |
| 2 | #include <Common/config.h> |
| 3 | #if USE_HDFS |
| 4 | |
| 5 | #include <Storages/IStorage.h> |
| 6 | #include <Poco/URI.h> |
| 7 | #include <common/logger_useful.h> |
| 8 | #include <ext/shared_ptr_helper.h> |
| 9 | |
| 10 | namespace DB |
| 11 | { |
| 12 | /** |
| 13 | * This class represents table engine for external hdfs files. |
| 14 | * Read method is supported for now. |
| 15 | */ |
| 16 | class StorageHDFS : public ext::shared_ptr_helper<StorageHDFS>, public IStorage |
| 17 | { |
| 18 | friend struct ext::shared_ptr_helper<StorageHDFS>; |
| 19 | public: |
| 20 | String getName() const override { return "HDFS" ; } |
| 21 | String getTableName() const override { return table_name; } |
| 22 | String getDatabaseName() const override { return database_name; } |
| 23 | |
| 24 | BlockInputStreams read(const Names & column_names, |
| 25 | const SelectQueryInfo & query_info, |
| 26 | const Context & context, |
| 27 | QueryProcessingStage::Enum processed_stage, |
| 28 | size_t max_block_size, |
| 29 | unsigned num_streams) override; |
| 30 | |
| 31 | BlockOutputStreamPtr write(const ASTPtr & query, const Context & context) override; |
| 32 | |
| 33 | void rename(const String & new_path_to_db, const String & new_database_name, const String & new_table_name, TableStructureWriteLockHolder &) override; |
| 34 | |
| 35 | protected: |
| 36 | StorageHDFS(const String & uri_, |
| 37 | const String & database_name_, |
| 38 | const String & table_name_, |
| 39 | const String & format_name_, |
| 40 | const ColumnsDescription & columns_, |
| 41 | const ConstraintsDescription & constraints_, |
| 42 | Context & context_, |
| 43 | const String & compression_method_); |
| 44 | |
| 45 | private: |
| 46 | String uri; |
| 47 | String format_name; |
| 48 | String table_name; |
| 49 | String database_name; |
| 50 | Context & context; |
| 51 | String compression_method; |
| 52 | |
| 53 | Logger * log = &Logger::get("StorageHDFS" ); |
| 54 | }; |
| 55 | } |
| 56 | |
| 57 | #endif |
| 58 | |