aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/TableFunctions/TableFunctionHDFSCluster.h
blob: 0bd2d05f0f80a444401b6011a3873309318c592b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once

#include "clickhouse_config.h"

#if USE_HDFS

#include <TableFunctions/ITableFunctionFileLike.h>
#error #include <TableFunctions/TableFunctionHDFS.h>
#include <TableFunctions/ITableFunctionCluster.h>


namespace DB
{

class Context;

/**
 * hdfsCluster(cluster, URI, format, structure, compression_method)
 * A table function, which allows to process many files from HDFS on a specific cluster
 * On initiator it creates a connection to _all_ nodes in cluster, discloses asterisks
 * in HDFS file path and dispatch each file dynamically.
 * On worker node it asks initiator about next task to process, processes it.
 * This is repeated until the tasks are finished.
 */
class TableFunctionHDFSCluster : public ITableFunctionCluster<TableFunctionHDFS>
{
public:
    static constexpr auto name = "hdfsCluster";
    static constexpr auto signature = " - cluster_name, uri\n"
                                      " - cluster_name, uri, format\n"
                                      " - cluster_name, uri, format, structure\n"
                                      " - cluster_name, uri, format, structure, compression_method\n";

    String getName() const override
    {
        return name;
    }

    String getSignature() const override
    {
        return signature;
    }

protected:
    StoragePtr getStorage(
        const String & source, const String & format_, const ColumnsDescription & columns, ContextPtr global_context,
        const std::string & table_name, const String & compression_method_) const override;

    const char * getStorageTypeName() const override { return "HDFSCluster"; }
};

}

#endif