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