be/src/exec/sink/writer/vhive_partition_writer.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <gen_cpp/DataSinks_types.h> |
21 | | |
22 | | #include "core/column/column.h" |
23 | | #include "exprs/vexpr_fwd.h" |
24 | | #include "format/transformer/vfile_format_transformer.h" |
25 | | #include "io/fs/file_writer.h" |
26 | | |
27 | | namespace doris { |
28 | | namespace io { |
29 | | class FileSystem; |
30 | | } |
31 | | |
32 | | class ObjectPool; |
33 | | class RuntimeState; |
34 | | class RuntimeProfile; |
35 | | class THiveColumn; |
36 | | |
37 | | class Block; |
38 | | class VFileFormatTransformer; |
39 | | |
40 | | class VHivePartitionWriter { |
41 | | public: |
42 | | struct WriteInfo { |
43 | | std::string write_path; |
44 | | std::string original_write_path; |
45 | | std::string target_path; |
46 | | TFileType::type file_type; |
47 | | std::vector<TNetworkAddress> broker_addresses; |
48 | | }; |
49 | | |
50 | | VHivePartitionWriter(const TDataSink& t_sink, std::string partition_name, |
51 | | TUpdateMode::type update_mode, |
52 | | const VExprContextSPtrs& write_output_expr_ctxs, |
53 | | std::vector<std::string> write_column_names, WriteInfo write_info, |
54 | | std::string file_name, int file_name_index, |
55 | | TFileFormatType::type file_format_type, |
56 | | TFileCompressType::type hive_compress_type, |
57 | | const THiveSerDeProperties* hive_serde_properties, |
58 | | const std::map<std::string, std::string>& hadoop_conf); |
59 | | |
60 | 0 | Status init_properties(ObjectPool* pool) { return Status::OK(); } |
61 | | |
62 | | Status open(RuntimeState* state, RuntimeProfile* profile); |
63 | | |
64 | | Status write(Block& block); |
65 | | |
66 | | Status close(const Status& status); |
67 | | |
68 | 0 | inline const std::string& file_name() const { return _file_name; } |
69 | | |
70 | 0 | inline int file_name_index() const { return _file_name_index; } |
71 | | |
72 | 0 | inline size_t written_len() { return _file_format_transformer->written_len(); } |
73 | | |
74 | | private: |
75 | | std::string _get_target_file_name(); |
76 | | |
77 | | private: |
78 | | THivePartitionUpdate _build_partition_update(); |
79 | | |
80 | | std::string _get_file_extension(TFileFormatType::type file_format_type, |
81 | | TFileCompressType::type write_compress_type); |
82 | | |
83 | | std::string _path; |
84 | | |
85 | | std::string _partition_name; |
86 | | |
87 | | TUpdateMode::type _update_mode; |
88 | | |
89 | | size_t _row_count = 0; |
90 | | |
91 | | const VExprContextSPtrs& _write_output_expr_ctxs; |
92 | | |
93 | | std::vector<std::string> _write_column_names; |
94 | | |
95 | | WriteInfo _write_info; |
96 | | std::string _file_name; |
97 | | int _file_name_index; |
98 | | TFileFormatType::type _file_format_type; |
99 | | TFileCompressType::type _hive_compress_type; |
100 | | const THiveSerDeProperties* _hive_serde_properties; |
101 | | const std::map<std::string, std::string>& _hadoop_conf; |
102 | | |
103 | | std::shared_ptr<io::FileSystem> _fs = nullptr; |
104 | | |
105 | | // If the result file format is plain text, like CSV, this _file_writer is owned by this FileResultWriter. |
106 | | // If the result file format is Parquet, this _file_writer is owned by _parquet_writer. |
107 | | std::unique_ptr<doris::io::FileWriter> _file_writer = nullptr; |
108 | | // convert block to parquet/orc/csv format |
109 | | std::unique_ptr<VFileFormatTransformer> _file_format_transformer = nullptr; |
110 | | |
111 | | RuntimeState* _state; |
112 | | }; |
113 | | } // namespace doris |