be/src/load/group_commit/wal/wal_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/internal_service.pb.h> |
21 | | |
22 | | #include "common/status.h" |
23 | | #include "io/fs/file_reader_writer_fwd.h" |
24 | | #include "io/fs/file_system.h" |
25 | | |
26 | | namespace doris { |
27 | | |
28 | | using PBlockArray = std::vector<PBlock*>; |
29 | | extern const char* k_wal_magic; |
30 | | extern const uint32_t k_wal_magic_length; |
31 | | |
32 | | class WalWriter { |
33 | | public: |
34 | | explicit WalWriter(const std::string& file_name); |
35 | | ~WalWriter(); |
36 | | |
37 | | Status init(const io::FileSystemSPtr& fs); |
38 | | Status finalize(); |
39 | | |
40 | | Status append_blocks(const PBlockArray& blocks); |
41 | | Status append_header(std::string col_ids); |
42 | | |
43 | 0 | std::string file_name() { return _file_name; }; |
44 | | |
45 | | public: |
46 | | static const int64_t LENGTH_SIZE = 8; |
47 | | static const int64_t CHECKSUM_SIZE = 4; |
48 | | static const int64_t VERSION_SIZE = 4; |
49 | | |
50 | | private: |
51 | | std::string _file_name; |
52 | | io::FileWriterPtr _file_writer; |
53 | | }; |
54 | | |
55 | | Status determine_wal_fs(int64_t db_id, int64_t tb_id, io::FileSystemSPtr& fs); |
56 | | |
57 | | } // namespace doris |