Coverage Report

Created: 2024-11-20 19:28

/root/doris/be/src/runtime/result_writer.h
Line
Count
Source (jump to first uncovered line)
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
namespace vectorized {
29
class Block;
30
}
31
class RuntimeState;
32
33
// abstract class of the result writer
34
class ResultWriter {
35
public:
36
6
    ResultWriter() = default;
37
6
    virtual ~ResultWriter() = default;
38
39
    virtual Status init(RuntimeState* state) = 0;
40
41
0
    virtual Status finish(RuntimeState* state) { return Status::OK(); }
42
43
    virtual Status close(Status s = Status::OK()) = 0;
44
45
0
    [[nodiscard]] virtual int64_t get_written_rows() const { return _written_rows; }
46
47
8
    [[nodiscard]] bool output_object_data() const { return _output_object_data; }
48
49
    // Write is sync, it will do real IO work.
50
    virtual Status write(vectorized::Block& block) = 0;
51
52
0
    virtual bool can_sink() { return true; }
53
54
0
    void set_output_object_data(bool output_object_data) {
55
0
        _output_object_data = output_object_data;
56
0
    }
57
58
protected:
59
    int64_t _written_rows = 0; // number of rows written
60
    bool _output_object_data = false;
61
};
62
63
} // namespace doris