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