Coverage Report

Created: 2026-03-15 01:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/io/fs/stream_sink_file_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 <brpc/stream.h>
21
#include <gen_cpp/olap_common.pb.h>
22
23
#include <queue>
24
25
#include "io/fs/file_writer.h"
26
#include "util/uid_util.h"
27
28
namespace doris {
29
30
class LoadStreamStub;
31
32
struct RowsetId;
33
struct SegmentStatistics;
34
35
namespace io {
36
struct FileCacheAllocatorBuilder;
37
class StreamSinkFileWriter final : public FileWriter {
38
public:
39
    StreamSinkFileWriter(std::vector<std::shared_ptr<LoadStreamStub>> streams)
40
2
            : _streams(std::move(streams)) {}
41
42
    void init(PUniqueId load_id, int64_t partition_id, int64_t index_id, int64_t tablet_id,
43
              int32_t segment_id, FileType file_type = FileType::SEGMENT_FILE);
44
45
    Status appendv(const Slice* data, size_t data_cnt) override;
46
47
0
    size_t bytes_appended() const override { return _bytes_appended; }
48
49
0
    State state() const override { return _state; }
50
51
    // FIXME(plat1ko): Maybe it's an inappropriate abstraction?
52
0
    const Path& path() const override {
53
0
        static Path dummy;
54
0
        return dummy;
55
0
    }
56
    Status close(bool non_block = false) override;
57
58
private:
59
    Status _finalize();
60
    std::vector<std::shared_ptr<LoadStreamStub>> _streams;
61
62
    PUniqueId _load_id;
63
    int64_t _partition_id;
64
    int64_t _index_id;
65
    int64_t _tablet_id;
66
    int32_t _segment_id;
67
    size_t _bytes_appended = 0;
68
    State _state {State::OPENED};
69
    FileType _file_type {FileType::SEGMENT_FILE};
70
};
71
72
} // namespace io
73
} // namespace doris