be/src/exec/sink/writer/result_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 <stdint.h> |
21 | | |
22 | | #include <string> |
23 | | |
24 | | #include "common/status.h" |
25 | | |
26 | | namespace doris { |
27 | | |
28 | | class Block; |
29 | | class RuntimeState; |
30 | | |
31 | | // abstract class of the result writer |
32 | | class ResultWriter { |
33 | | public: |
34 | 14 | ResultWriter() = default; |
35 | 14 | virtual ~ResultWriter() = default; |
36 | | |
37 | | virtual Status init(RuntimeState* state) = 0; |
38 | | |
39 | 0 | virtual Status finish(RuntimeState* state) { return Status::OK(); } |
40 | | |
41 | | virtual Status close(Status s = Status::OK()) = 0; |
42 | | |
43 | 0 | [[nodiscard]] virtual int64_t get_written_rows() const { return _written_rows; } |
44 | | |
45 | 8 | [[nodiscard]] bool output_object_data() const { return _output_object_data; } |
46 | | |
47 | | // Write is sync, it will do real IO work. |
48 | | virtual Status write(RuntimeState* state, Block& block) = 0; |
49 | | |
50 | 0 | void set_output_object_data(bool output_object_data) { |
51 | 0 | _output_object_data = output_object_data; |
52 | 0 | } |
53 | | |
54 | | protected: |
55 | | int64_t _written_rows = 0; // number of rows written |
56 | | bool _output_object_data = false; |
57 | | }; |
58 | | |
59 | | } // namespace doris |