be/src/storage/rowset/group_rowset_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 "storage/rowset/rowset_writer.h" |
21 | | |
22 | | namespace doris { |
23 | | class Block; |
24 | | class GroupRowsetWriter : public RowsetWriter { |
25 | | public: |
26 | 12 | GroupRowsetWriter() = default; |
27 | | |
28 | | void set_data_writer(const RowsetWriterSharedPtr& txn_rowset_writer); |
29 | | |
30 | | void set_row_binlog_writer(const RowsetWriterSharedPtr& row_binlog_rowset_writer); |
31 | | |
32 | 12 | ~GroupRowsetWriter() = default; |
33 | | |
34 | | Status flush_rowsets(); |
35 | | |
36 | | Status build_rowsets(std::vector<RowsetSharedPtr>& rowsets); |
37 | | |
38 | 6 | RowsetWriterSharedPtr row_binlog_writer() { return _row_binlog_rowset_writer; } |
39 | | |
40 | 6 | RowsetWriterSharedPtr data_writer() { return _txn_rowset_writer; } |
41 | | |
42 | 3 | Status init(const RowsetWriterContext& rowset_writer_context) override { |
43 | 3 | _context = rowset_writer_context; |
44 | 3 | return Status::OK(); |
45 | 3 | } |
46 | | |
47 | 0 | Status add_block(const Block* block) override { |
48 | 0 | return Status::Error<ErrorCode::NOT_IMPLEMENTED_ERROR>( |
49 | 0 | "GroupRowsetWriter::add_block is not implemented"); |
50 | 0 | } |
51 | | |
52 | | // add rowset by create hard link |
53 | 0 | Status add_rowset(RowsetSharedPtr rowset) override { |
54 | 0 | return Status::Error<ErrorCode::NOT_IMPLEMENTED_ERROR>( |
55 | 0 | "GroupRowsetWriter::add_rowset is not implemented"); |
56 | 0 | } |
57 | | |
58 | | // Precondition: the input `rowset` should have the same type of the rowset we're building |
59 | 0 | Status add_rowset_for_linked_schema_change(RowsetSharedPtr rowset) override { |
60 | 0 | return Status::Error<ErrorCode::NOT_IMPLEMENTED_ERROR>( |
61 | 0 | "GroupRowsetWriter::add_rowset_for_linked_schema_change is not implemented"); |
62 | 0 | } |
63 | | |
64 | | // explicit flush all buffered rows into segment file. |
65 | | // note that `add_row` could also trigger flush when certain conditions are met |
66 | 1 | Status flush() override { return flush_rowsets(); } |
67 | | |
68 | | Status flush_memtable(Block* block, int32_t segment_id, int64_t* flush_size) override; |
69 | | |
70 | | Status flush_single_block(const Block* block) override; |
71 | | |
72 | | // GroupRowsetWriter does not support build a single rowset; its build is |
73 | | // delegated to underlying writers. |
74 | 0 | Status build(RowsetSharedPtr& rowset) override { |
75 | 0 | return Status::NotSupported("GroupRowsetWriter::build is not supported"); |
76 | 0 | } |
77 | | |
78 | 0 | RowsetSharedPtr manual_build(const RowsetMetaSharedPtr& rowset_meta) override { |
79 | 0 | LOG(FATAL) << "GroupRowsetWriter::manual_build not implemented"; |
80 | 0 | return nullptr; |
81 | 0 | } |
82 | | |
83 | 0 | PUniqueId load_id() override { return _context.load_id; } |
84 | | |
85 | 0 | Version version() override { return _context.version; } |
86 | | |
87 | 0 | int64_t num_rows() const override { return _txn_rowset_writer->num_rows(); } |
88 | | |
89 | 0 | int64_t num_rows_updated() const override { return _txn_rowset_writer->num_rows_updated(); } |
90 | | |
91 | 0 | int64_t num_rows_deleted() const override { return _txn_rowset_writer->num_rows_deleted(); } |
92 | | |
93 | 0 | int64_t num_rows_new_added() const override { return _txn_rowset_writer->num_rows_new_added(); } |
94 | | |
95 | 0 | int64_t num_rows_filtered() const override { return _txn_rowset_writer->num_rows_filtered(); } |
96 | | |
97 | 0 | RowsetId rowset_id() override { |
98 | 0 | LOG(FATAL) << "GroupRowsetWriter::rowset_id not implemented"; |
99 | 0 | RowsetId res; |
100 | 0 | return res; |
101 | 0 | } |
102 | | |
103 | 2 | RowsetTypePB type() const override { return BETA_ROWSET; } |
104 | | |
105 | 0 | Status get_segment_num_rows(std::vector<uint32_t>* segment_num_rows) const override { |
106 | 0 | return Status::NotSupported("GroupRowsetWriter::get_segment_num_rows to be implemented"); |
107 | 0 | } |
108 | | |
109 | 0 | int32_t allocate_segment_id() override { |
110 | 0 | LOG(FATAL) << "GroupRowsetWriter::allocate_segment_id is not supported"; |
111 | 0 | return -1; |
112 | 0 | } |
113 | | |
114 | 0 | int32_t get_allocated_segment_id() override { |
115 | 0 | DCHECK(_txn_rowset_writer != nullptr); |
116 | 0 | DCHECK(_row_binlog_rowset_writer != nullptr); |
117 | 0 | auto seg_id = _txn_rowset_writer->get_allocated_segment_id(); |
118 | 0 | DCHECK_EQ(seg_id, _row_binlog_rowset_writer->get_allocated_segment_id()); |
119 | 0 | return seg_id; |
120 | 0 | } |
121 | | |
122 | 0 | void set_segment_start_id(int num_segment) override { |
123 | 0 | LOG(FATAL) << "GroupRowsetWriter::set_segment_start_id not supported"; |
124 | 0 | } |
125 | | |
126 | 0 | int64_t delete_bitmap_ns() override { return 0; } |
127 | | |
128 | 0 | int64_t segment_writer_ns() override { return 0; } |
129 | | |
130 | 0 | bool is_partial_update() override { return _txn_rowset_writer->is_partial_update(); } |
131 | | |
132 | 0 | std::shared_ptr<PartialUpdateInfo> get_partial_update_info() override { |
133 | 0 | return _txn_rowset_writer->get_partial_update_info(); |
134 | 0 | } |
135 | | |
136 | | private: |
137 | | RowsetWriterSharedPtr _txn_rowset_writer; |
138 | | RowsetWriterSharedPtr _row_binlog_rowset_writer; |
139 | | }; |
140 | | |
141 | | } // namespace doris |