Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
csun5285 merged PR #67468: URL: https://github.com/apache/doris/pull/67468 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
hello-stephen commented on PR #67468: URL: https://github.com/apache/doris/pull/67468#issuecomment-5539580106 # BE Regression && UT Coverage Report Increment line coverage `0.00% (0/1)` :tada: [Increment coverage report](http://coverage.selectdb-in.cc/coverage/67468_a2b8009eeb65a3ad90eb349d5b9dcf1f7f453962_merge/increment_report/index.html) [Complete coverage report](http://coverage.selectdb-in.cc/coverage/67468_a2b8009eeb65a3ad90eb349d5b9dcf1f7f453962_merge/report/index.html) | Category | Coverage | |---|| | Function Coverage | 76.34% (34647/45387) | | Line Coverage | 61.37% (390814/636846) | | Region Coverage | 57.55% (328300/570421) | | Branch Coverage | 58.41% (149802/256470) | -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
hello-stephen commented on PR #67468: URL: https://github.com/apache/doris/pull/67468#issuecomment-5537955018 ClickBench: Total hot run time: 14.62 s ``` machine: 'aliyun_ecs.c7a.8xlarge_32C64G' scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools ClickBench test result on commit a2b8009eeb65a3ad90eb349d5b9dcf1f7f453962, data reload: false query1 0.010.010.00 query2 0.080.040.03 query3 0.240.100.10 query4 1.600.100.09 query5 0.170.150.16 query6 1.270.690.70 query7 0.040.010.01 query8 0.040.020.03 query9 0.280.220.21 query10 0.330.330.36 query11 0.160.120.12 query12 0.150.130.12 query13 0.290.300.30 query14 0.460.460.44 query15 0.370.350.36 query16 0.220.230.22 query17 0.720.740.66 query18 0.160.150.17 query19 1.161.191.18 query20 0.020.010.01 query21 15.43 0.160.11 query22 5.050.050.04 query23 16.17 0.250.10 query24 2.990.310.26 query25 0.100.050.04 query26 0.820.160.11 query27 0.030.040.04 query28 3.680.560.28 query29 12.44 3.182.54 query30 0.250.110.12 query31 2.760.370.17 query32 3.530.310.23 query33 1.361.421.60 query34 15.39 2.191.77 query35 1.741.791.72 query36 0.450.280.28 query37 0.060.040.04 query38 0.050.030.03 query39 0.030.020.02 query40 0.120.070.07 query41 0.080.020.02 query42 0.040.020.02 query43 0.040.030.02 Total cold run time: 90.38 s Total hot run time: 14.62 s ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
hello-stephen commented on PR #67468: URL: https://github.com/apache/doris/pull/67468#issuecomment-5537911267 TPC-DS: Total hot run time: 82258 ms ``` machine: 'aliyun_ecs.c7a.8xlarge_32C64G' scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools TPC-DS sf100 test result on commit a2b8009eeb65a3ad90eb349d5b9dcf1f7f453962, data reload: false query5 4254409 332 332 query6 384 139 130 130 query7 4959426 221 221 query8 289 122 122 122 query9 8679286828822868 query10 390 221 191 191 query11 53911035921 921 query12 116 72 70 70 query13 1205443 346 346 query14 6190222521332133 query14_12015198419941984 query15 173 120 118 118 query16 919 366 352 352 query17 809 458 362 362 query18 2337328 241 241 query19 161 156 127 127 query20 74 68 70 68 query21 201 101 88 88 query22 5441556553165316 query23 6799641758975897 query23_16230601460596014 query24 7300791 791 query24_1768 784 801 784 query25 445 305 282 282 query26 1230225 135 135 query27 2798431 265 265 query28 4634149215151492 query29 952 440 364 364 query30 250 148 136 136 query31 830 400 334 334 query32 133 85 76 76 query33 458 225 187 187 query34 993 823 482 482 query35 410 408 366 366 query36 590 557 548 548 query37 119 80 75 75 query38 1017848 823 823 query39 521 489 473 473 query39_1452 459 453 453 query40 201 92 81 81 query41 59 57 59 57 query42 77 72 76 72 query43 243 241 212 212 query44 1019554 567 554 query45 113 109 101 101 query46 807 844 570 570 query47 749 780 707 707 query48 312 321 235 235 query49 536 252 191 191 query50 725 258 197 197 query51 8056794578217821 query52 67 69 64 64 query53 192 206 153 153 query54 219 166 172 166 query55 69 62 57 57 query56 187 179 241 179 query57 699 637 654 637 query58 192 161 166 161 query59 1192122510791079 query60 228 194 195 194 query61 126 124 151 124 query62 363 216 176 176 query63 172 138 138 138 query64 2881719 586 586 query65 1602160116071601 query66 1906270 220 220 query67 10004 971296589658 query68 30051149716 716 query69 329 216 189 189 query70 684 617 629 617 query71 249 174 155 155 query72 2320174515681568 query73 649 605 359 359 query74 1997123711661166 query75 11901104970 970 query76 2357752 544 544 query77 260 265 219 219 query78 4040360433533353 query79 2798839 600 600 query80 1598332 270 270 query81 514 157 134 134 query82 623 132 94 94 query83 287 214 193 193 query84 291 109 92 92 query85 848 361 294 294 query86 481 173 174 173 query87 1025966 892 892 query88 3019211821272118 query89 291 202 178 178 query90 2097128 136 128 query91 135 122 100 100 query92 96 66 70 66 query93 21181075711 711 query94 652 256 230 230 query95 532 338 234 234 query96 807 603 280 280 query97 1042102510421025 query98 174 132 143 132 query99 420 356 309 309 Total cold run time: 180226 ms Total hot run time: 82258 ms ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
hello-stephen commented on PR #67468: URL: https://github.com/apache/doris/pull/67468#issuecomment-5537844407 TPC-H: Total hot run time: 16862 ms ``` machine: 'aliyun_ecs.c7a.8xlarge_32C64G' scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools Tpch sf100 test result on commit a2b8009eeb65a3ad90eb349d5b9dcf1f7f453962, data reload: false -- Round 1 -- q1 17570 303130073007 q2 2094256 230 230 q3 10234 880 517 517 q4 4667246 205 205 q5 7683556 380 380 q6 139 113 95 95 q7 547 494 386 386 q8 9229940 1011940 q9 3498244123832383 q10 6513823 704 704 q11 386 203 184 184 q12 611 259 210 210 q13 18128 153611751175 q14 163 152 141 141 q15 q16 434 396 367 367 q17 1375958 776 776 q18 3088225422442244 q19 1258911 777 777 q20 388 282 202 202 q21 5592171318761713 q22 337 264 226 226 Total cold run time: 93934 ms Total hot run time: 16862 ms - Round 2, with runtime_filter_mode=off - q1 3397329832963296 q2 499 398 371 371 q3 2195243021802180 q4 11921171893 893 q5 2230212521112111 q6 160 116 85 85 q7 1029934 853 853 q8 1592138614071386 q9 3104308230803080 q10 1830182216411641 q11 346 268 244 244 q12 454 431 345 345 q13 1507154511561156 q14 173 177 170 170 q15 q16 395 397 357 357 q17 3644324032183218 q18 4785438347294383 q19 851 905 886 886 q20 1020930 856 856 q21 3813314532733145 q22 389 338 317 317 Total cold run time: 34605 ms Total hot run time: 30973 ms ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
csun5285 commented on PR #67468: URL: https://github.com/apache/doris/pull/67468#issuecomment-5536587597 run buildall -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
csun5285 commented on code in PR #67468:
URL: https://github.com/apache/doris/pull/67468#discussion_r3923842253
##
be/src/storage/segment/vertical_segment_writer.cpp:
##
@@ -272,43 +272,82 @@ Status
VerticalSegmentWriter::_create_column_writer(uint32_t cid, const TabletCo
opts.file_writer = _file_writer;
opts.compression_type = _opts.compression_type;
opts.footer = &_footer;
-opts.input_rs_readers = _opts.rowset_ctx->input_rs_readers;
+if (_opts.rowset_ctx != nullptr) {
+opts.input_rs_readers = _opts.rowset_ctx->input_rs_readers;
+}
std::unique_ptr writer;
RETURN_IF_ERROR(ColumnWriter::create(opts, &column, _file_writer,
&writer));
RETURN_IF_ERROR(writer->init());
-_column_writers[cid] = std::move(writer);
-_olap_data_convertor->add_column_data_convertor_at(column, cid);
+_column_writers[pos] = std::move(writer);
+_olap_data_convertor->add_column_data_convertor_at(column, pos);
return Status::OK();
-};
+}
+
+std::vector VerticalSegmentWriter::_all_column_ids() const {
+std::vector column_ids(_tablet_schema->num_columns());
+std::iota(column_ids.begin(), column_ids.end(), 0);
+return column_ids;
+}
Status VerticalSegmentWriter::init() {
+return init(_all_column_ids(), true);
+}
+
+Status VerticalSegmentWriter::init(const std::vector& col_ids, bool
has_key) {
+// Vertical compaction and segcompaction init() once per group; the footer
keeps
+// every group's entries, so this group's slice starts at the current size.
+const int variant_stats_footer_offset = _footer.columns_size();
+RETURN_IF_ERROR(_open_group(col_ids, has_key));
+RETURN_IF_ERROR(_create_writers(_tablet_schema, col_ids));
+
+// Initialize variant statistics calculator
+_variant_stats_calculator = std::make_unique(
+&_footer, _tablet_schema, col_ids, variant_stats_footer_offset);
+return Status::OK();
+}
+
+Status VerticalSegmentWriter::_open_group(const std::vector&
col_ids, bool has_key) {
DCHECK(_column_writers.empty());
+DCHECK(_column_ids.empty());
+_has_key = has_key;
+_column_ids.insert(_column_ids.end(), col_ids.begin(), col_ids.end());
Review Comment:
不检查累计量,这是master 的行为
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
csun5285 commented on code in PR #67468:
URL: https://github.com/apache/doris/pull/67468#discussion_r3923844888
##
be/test/storage/segment/segment_writer_write_paths_test.cpp:
##
@@ -0,0 +1,448 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// A segment can be handed to VerticalSegmentWriter one column group at a time
--
+// what compaction does -- or as one whole-schema block through write_block(),
+// which is what a load flush does. The two produce the same rows and the same
+// key bounds; they do not produce the same bytes, because a group writes its
own
+// index sections right after its data, so the column group segment interleaves
+// the two.
+//
+// These tests drive both shapes over identical rows, read both segments back
and
+// check the rows and the primary key index match. They also cover the row
store
+// column, whose values are generated from whole rows rather than read out of
the
+// block: write_block() pumps it from its generator in bounded batches.
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include "common/config.h"
+#include "core/block/block.h"
+#include "core/data_type/data_type_factory.hpp"
+#include "io/fs/local_file_system.h"
+#include "storage/index/indexed_column_reader.h"
+#include "storage/index/primary_key_index.h"
+#include "storage/iterators.h"
+#include "storage/merger.h"
+#include "storage/rowset/rowset_writer_context.h"
+#include "storage/schema.h"
+#include "storage/segment/segment.h"
+#include "storage/segment/vertical_segment_writer.h"
+#include "storage/tablet/tablet_schema.h"
+#include "storage/transform/block_transform.h"
+
+namespace doris::segment_v2 {
+
+static const std::string kSegmentDir =
"./ut_dir/segment_writer_write_paths_test";
+// Small enough that kNumRows fills several primary key index data pages.
+static constexpr int32_t kPrimaryKeyDataPageSize = 1024;
+static constexpr size_t kNumRows = 512;
+static constexpr int64_t kTabletId = 1;
+
+namespace {
+
+TabletColumnPtr create_int_key(int32_t id) {
+auto column = std::make_shared();
+column->_unique_id = id;
+column->_col_name = std::to_string(id);
+column->_type = FieldType::OLAP_FIELD_TYPE_INT;
+column->_is_key = true;
+column->_is_nullable = false;
+column->_length = 4;
+column->_index_length = 4;
+return column;
+}
+
+TabletColumnPtr create_int_value(int32_t id) {
+auto column = std::make_shared();
+column->_unique_id = id;
+column->_col_name = std::to_string(id);
+column->_type = FieldType::OLAP_FIELD_TYPE_INT;
+column->_is_key = false;
+column->_is_nullable = true;
+column->_length = 4;
+column->_index_length = 4;
+return column;
+}
+
+// One key column and two value columns, so a column group split has something
+// to split.
+TabletSchemaSPtr create_schema(KeysType keys_type, bool with_cluster_key,
+ bool with_key_column = true) {
+TabletSchemaSPtr schema = std::make_shared();
+if (with_key_column) {
+schema->append_column(*create_int_key(0));
+} else {
+schema->append_column(*create_int_value(0));
+}
+schema->append_column(*create_int_value(1));
+schema->append_column(*create_int_value(2));
+schema->_keys_type = keys_type;
+schema->_num_short_key_columns = with_key_column ? 1 : 0;
+if (with_cluster_key) {
+// sort the segment by the first value column instead of the key column
+schema->_cluster_key_uids = {1};
+}
+return schema;
+}
+
+// Rows in the order the segment stores them: the key column descends and the
+// first value column ascends, so both are unique and the block is already
sorted
+// by whichever of them the table sorts by.
+Block create_block(const TabletSchemaSPtr& schema, bool sorted_by_value) {
+Block block = schema->create_storage_block();
+auto key_column = block.get_by_position(0).column->assert_mutable();
+auto sort_column = block.get_by_position(1).column->assert_mutable();
+auto plain_column = block.get_by_position(2).column->assert_mutable();
+for (size_t row = 0; row < kNumRows; ++row) {
+auto ascending = static_cast(row);
+auto descending =
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
github-actions[bot] commented on code in PR #67468:
URL: https://github.com/apache/doris/pull/67468#discussion_r3923761201
##
be/src/storage/segment/vertical_segment_writer.cpp:
##
@@ -272,43 +272,82 @@ Status
VerticalSegmentWriter::_create_column_writer(uint32_t cid, const TabletCo
opts.file_writer = _file_writer;
opts.compression_type = _opts.compression_type;
opts.footer = &_footer;
-opts.input_rs_readers = _opts.rowset_ctx->input_rs_readers;
+if (_opts.rowset_ctx != nullptr) {
+opts.input_rs_readers = _opts.rowset_ctx->input_rs_readers;
+}
std::unique_ptr writer;
RETURN_IF_ERROR(ColumnWriter::create(opts, &column, _file_writer,
&writer));
RETURN_IF_ERROR(writer->init());
-_column_writers[cid] = std::move(writer);
-_olap_data_convertor->add_column_data_convertor_at(column, cid);
+_column_writers[pos] = std::move(writer);
+_olap_data_convertor->add_column_data_convertor_at(column, pos);
return Status::OK();
-};
+}
+
+std::vector VerticalSegmentWriter::_all_column_ids() const {
+std::vector column_ids(_tablet_schema->num_columns());
+std::iota(column_ids.begin(), column_ids.end(), 0);
+return column_ids;
+}
Status VerticalSegmentWriter::init() {
+return init(_all_column_ids(), true);
+}
+
+Status VerticalSegmentWriter::init(const std::vector& col_ids, bool
has_key) {
+// Vertical compaction and segcompaction init() once per group; the footer
keeps
+// every group's entries, so this group's slice starts at the current size.
+const int variant_stats_footer_offset = _footer.columns_size();
+RETURN_IF_ERROR(_open_group(col_ids, has_key));
+RETURN_IF_ERROR(_create_writers(_tablet_schema, col_ids));
+
+// Initialize variant statistics calculator
+_variant_stats_calculator = std::make_unique(
+&_footer, _tablet_schema, col_ids, variant_stats_footer_offset);
+return Status::OK();
+}
+
+Status VerticalSegmentWriter::_open_group(const std::vector&
col_ids, bool has_key) {
DCHECK(_column_writers.empty());
+DCHECK(_column_ids.empty());
+_has_key = has_key;
+_column_ids.insert(_column_ids.end(), col_ids.begin(), col_ids.end());
Review Comment:
[P1] write_block() finalizes each column before the final capacity check and
sets _columns_data_flushed=true, so estimate_segment_size() at this point omits
every column already appended to the segment. The earlier checks only pass one
column's buffer at a time against DataDir's cached available bytes; they do not
account for bytes written by prior columns. With a wide row or low free space,
individually passing columns can cumulatively cross the flood-stage limit.
Please include the segment's already-appended bytes (or preserve an aggregate
pre-write estimate) in the capacity check before/through each column write.
##
be/test/storage/segment/segment_writer_write_paths_test.cpp:
##
@@ -0,0 +1,448 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// A segment can be handed to VerticalSegmentWriter one column group at a time
--
+// what compaction does -- or as one whole-schema block through write_block(),
+// which is what a load flush does. The two produce the same rows and the same
+// key bounds; they do not produce the same bytes, because a group writes its
own
+// index sections right after its data, so the column group segment interleaves
+// the two.
+//
+// These tests drive both shapes over identical rows, read both segments back
and
+// check the rows and the primary key index match. They also cover the row
store
+// column, whose values are generated from whole rows rather than read out of
the
+// block: write_block() pumps it from its generator in bounded batches.
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include "common/config.h"
+#include "core/block/block.h"
+#include "core/data_type/data_type_factory.hpp"
+#include "io/fs/local_file_system.h"
+#include "storage/index/indexed_column_reader.h"
+#include "storage/index/primary_key_index.h"
+#include "storage/iterators.h"
+#include "storage/merger.h"
+#include "storage/rowset/rowset_writer_context.h"
+#include "storage/schema.h"
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
csun5285 commented on code in PR #67468:
URL: https://github.com/apache/doris/pull/67468#discussion_r3923354232
##
be/src/storage/segment/vertical_segment_writer.cpp:
##
@@ -368,113 +407,175 @@ Status
VerticalSegmentWriter::_finalize_column_writer_and_update_meta(size_t cid
return Status::OK();
}
-Status VerticalSegmentWriter::batch_block(const Block* block, size_t row_pos,
size_t num_rows) {
-// input width is checked by the transform chain's ValidateStage
-DCHECK(block->columns() == _tablet_schema->num_columns())
-<< "block columns = " << block->dump_structure()
-<< ", tablet_schema columns = " <<
_tablet_schema->dump_structure();
-_batched_blocks.emplace_back(block, row_pos, num_rows);
+Status VerticalSegmentWriter::append_block(const Block* block, size_t row_pos,
size_t num_rows) {
+if (block->columns() < _column_writers.size()) {
+return Status::InternalError(
+"block->columns() < _column_writers.size(), block->columns()="
+
+std::to_string(block->columns()) +
+", _column_writers.size()=" +
std::to_string(_column_writers.size()) +
+", _tablet_schema->dump_structure()=" +
_tablet_schema->dump_structure());
+}
+CHECK(block->columns() >= _column_writers.size())
+<< ", block->columns()=" << block->columns()
+<< ", _column_writers.size()=" << _column_writers.size()
+<< ", _tablet_schema->dump_structure()=" <<
_tablet_schema->dump_structure();
+_olap_data_convertor->set_source_content(block, row_pos, num_rows);
+
+// convert column data from engine format to storage layer format
+std::vector key_columns;
+IOlapColumnDataAccessor* seq_column = nullptr;
+// keyed by cluster key unique id
+std::map cluster_key_columns;
+for (size_t id = 0; id < _column_writers.size(); ++id) {
+// olap data convertor alway start from id = 0
+auto converted_result = _olap_data_convertor->convert_column_data(id);
+if (!converted_result.first.ok()) {
+return converted_result.first;
+}
+auto cid = _column_ids[id];
+if (_has_key && cid < _tablet_schema->num_key_columns()) {
+key_columns.push_back(converted_result.second);
+} else if (_has_key && _tablet_schema->has_sequence_col() &&
+ cid == _tablet_schema->sequence_col_idx()) {
+seq_column = converted_result.second;
+}
+if (_has_key) {
+_collect_cluster_key_column(cid, converted_result.second,
&cluster_key_columns);
+}
+
RETURN_IF_ERROR(_column_writers[id]->append(converted_result.second->get_nullmap(),
+
converted_result.second->get_data(), num_rows));
+}
+if (_opts.write_type == DataWriteType::TYPE_COMPACTION) {
+RETURN_IF_ERROR(
+_variant_stats_calculator->calculate_variant_stats(block,
row_pos, num_rows));
+}
+
+// value groups carry no key columns
+if (_has_key) {
+RETURN_IF_ERROR(
+_generate_key_index(key_columns, seq_column, num_rows,
cluster_key_columns));
+}
+
+_num_rows_written += num_rows;
+_olap_data_convertor->clear_source_content();
return Status::OK();
}
-Status VerticalSegmentWriter::write_batch() {
-// Blocks arrive fully transformed: validated, partial-update rows filled,
-// variants parsed, and the derived (row-store) column decided by the
chain.
-// Its generator is pumped here in bounded batches.
+Status VerticalSegmentWriter::write_block(const Block* block, size_t row_pos,
size_t num_rows) {
+RETURN_IF_ERROR(_open_group(_all_column_ids(), true));
+// Each column writer is created right before its column is written, so
+// only one column's page buffers are alive at a time. The derived
+// (row-store) column goes first, pumped from its generator in batches.
if (_derived_column.second) {
const auto& [cid, generator] = _derived_column;
-RETURN_IF_ERROR(_create_column_writer(cid,
_tablet_schema->column(cid), _tablet_schema));
-for (auto& data : _batched_blocks) {
-RETURN_IF_ERROR(_append_generated_column(*generator, *data.block,
data.row_pos,
- data.num_rows, cid));
-}
+RETURN_IF_ERROR(_create_column_writer(cid, cid, _tablet_schema));
+RETURN_IF_ERROR(_append_generated_column(*generator, *block, row_pos,
num_rows, cid));
RETURN_IF_ERROR(_check_column_writer_disk_capacity(cid));
RETURN_IF_ERROR(_finalize_column_writer_and_update_meta(cid));
}
std::vector key_columns;
IOlapColumnDataAccessor* seq_column = nullptr;
-// the key is cluster key column unique id
-std::map cid_to_column;
+// keyed by cluster key unique id
+std::map cluster_key_columns;
for
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
csun5285 commented on PR #67468: URL: https://github.com/apache/doris/pull/67468#issuecomment-5524034991 /review -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
csun5285 commented on PR #67468: URL: https://github.com/apache/doris/pull/67468#issuecomment-5524036370 run buildall -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
github-actions[bot] commented on code in PR #67468:
URL: https://github.com/apache/doris/pull/67468#discussion_r3922176579
##
be/src/storage/segment/vertical_segment_writer.cpp:
##
@@ -368,113 +407,175 @@ Status
VerticalSegmentWriter::_finalize_column_writer_and_update_meta(size_t cid
return Status::OK();
}
-Status VerticalSegmentWriter::batch_block(const Block* block, size_t row_pos,
size_t num_rows) {
-// input width is checked by the transform chain's ValidateStage
-DCHECK(block->columns() == _tablet_schema->num_columns())
-<< "block columns = " << block->dump_structure()
-<< ", tablet_schema columns = " <<
_tablet_schema->dump_structure();
-_batched_blocks.emplace_back(block, row_pos, num_rows);
+Status VerticalSegmentWriter::append_block(const Block* block, size_t row_pos,
size_t num_rows) {
+if (block->columns() < _column_writers.size()) {
+return Status::InternalError(
+"block->columns() < _column_writers.size(), block->columns()="
+
+std::to_string(block->columns()) +
+", _column_writers.size()=" +
std::to_string(_column_writers.size()) +
+", _tablet_schema->dump_structure()=" +
_tablet_schema->dump_structure());
+}
+CHECK(block->columns() >= _column_writers.size())
+<< ", block->columns()=" << block->columns()
+<< ", _column_writers.size()=" << _column_writers.size()
+<< ", _tablet_schema->dump_structure()=" <<
_tablet_schema->dump_structure();
+_olap_data_convertor->set_source_content(block, row_pos, num_rows);
+
+// convert column data from engine format to storage layer format
+std::vector key_columns;
+IOlapColumnDataAccessor* seq_column = nullptr;
+// keyed by cluster key unique id
+std::map cluster_key_columns;
+for (size_t id = 0; id < _column_writers.size(); ++id) {
+// olap data convertor alway start from id = 0
+auto converted_result = _olap_data_convertor->convert_column_data(id);
+if (!converted_result.first.ok()) {
+return converted_result.first;
+}
+auto cid = _column_ids[id];
+if (_has_key && cid < _tablet_schema->num_key_columns()) {
+key_columns.push_back(converted_result.second);
+} else if (_has_key && _tablet_schema->has_sequence_col() &&
+ cid == _tablet_schema->sequence_col_idx()) {
+seq_column = converted_result.second;
+}
+if (_has_key) {
+_collect_cluster_key_column(cid, converted_result.second,
&cluster_key_columns);
+}
+
RETURN_IF_ERROR(_column_writers[id]->append(converted_result.second->get_nullmap(),
+
converted_result.second->get_data(), num_rows));
+}
+if (_opts.write_type == DataWriteType::TYPE_COMPACTION) {
+RETURN_IF_ERROR(
+_variant_stats_calculator->calculate_variant_stats(block,
row_pos, num_rows));
+}
+
+// value groups carry no key columns
+if (_has_key) {
+RETURN_IF_ERROR(
+_generate_key_index(key_columns, seq_column, num_rows,
cluster_key_columns));
+}
+
+_num_rows_written += num_rows;
+_olap_data_convertor->clear_source_content();
return Status::OK();
}
-Status VerticalSegmentWriter::write_batch() {
-// Blocks arrive fully transformed: validated, partial-update rows filled,
-// variants parsed, and the derived (row-store) column decided by the
chain.
-// Its generator is pumped here in bounded batches.
+Status VerticalSegmentWriter::write_block(const Block* block, size_t row_pos,
size_t num_rows) {
+RETURN_IF_ERROR(_open_group(_all_column_ids(), true));
+// Each column writer is created right before its column is written, so
+// only one column's page buffers are alive at a time. The derived
+// (row-store) column goes first, pumped from its generator in batches.
if (_derived_column.second) {
const auto& [cid, generator] = _derived_column;
-RETURN_IF_ERROR(_create_column_writer(cid,
_tablet_schema->column(cid), _tablet_schema));
-for (auto& data : _batched_blocks) {
-RETURN_IF_ERROR(_append_generated_column(*generator, *data.block,
data.row_pos,
- data.num_rows, cid));
-}
+RETURN_IF_ERROR(_create_column_writer(cid, cid, _tablet_schema));
+RETURN_IF_ERROR(_append_generated_column(*generator, *block, row_pos,
num_rows, cid));
RETURN_IF_ERROR(_check_column_writer_disk_capacity(cid));
RETURN_IF_ERROR(_finalize_column_writer_and_update_meta(cid));
}
std::vector key_columns;
IOlapColumnDataAccessor* seq_column = nullptr;
-// the key is cluster key column unique id
-std::map cid_to_column;
+// keyed by cluster key unique id
+std::map cluster_key_columns;
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
csun5285 commented on PR #67468: URL: https://github.com/apache/doris/pull/67468#issuecomment-5521950243 /review -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
github-actions[bot] commented on PR #67468: URL: https://github.com/apache/doris/pull/67468#issuecomment-5521776215 Codex automated review failed and did not complete. Error: Review context preparation failed before Codex ran; inspect the 'Prepare authoritative PR context and required AGENTS guides' step. Workflow run: https://github.com/apache/doris/actions/runs/33724878932 Please inspect the workflow logs and rerun the review after the underlying issue is resolved. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
csun5285 commented on code in PR #67468:
URL: https://github.com/apache/doris/pull/67468#discussion_r3921824069
##
be/src/storage/segment/vertical_segment_writer.cpp:
##
@@ -569,67 +686,120 @@ void VerticalSegmentWriter::_abandon_index_staging() {
}
}
-// A failure below can land AFTER the ANN and BKD indexes have already been
built
-// into their staging files. The caller then returns before
close_inverted_index(),
-// so the seal that would have consumed them never runs, and the rowset writer
-// keeps this segment's IndexFileWriter -- with its staging files and their
open
-// descriptors -- until the whole load or compaction unwinds. Drop them here.
-//
-// ONLY on failure. On the success path close_inverted_index() is what consumes
-// the staging, so dropping it here would silently seal a container with no ANN
-// or BKD index in it.
-Status VerticalSegmentWriter::finalize_columns_index(uint64_t* index_size) {
-Status status = _finalize_columns_index_impl(index_size);
-if (!status.ok()) {
-_abandon_index_staging();
+Status VerticalSegmentWriter::_finalize_columns_data() {
+// check disk capacity before writing the buffered pages out
+if (_data_dir != nullptr &&
_data_dir->reach_capacity_limit((int64_t)estimate_segment_size())) {
Review Comment:
已修改
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
csun5285 commented on PR #67468: URL: https://github.com/apache/doris/pull/67468#issuecomment-5521720249 /review -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
github-actions[bot] commented on code in PR #67468:
URL: https://github.com/apache/doris/pull/67468#discussion_r3921182215
##
be/src/storage/segment/vertical_segment_writer.cpp:
##
@@ -569,67 +686,120 @@ void VerticalSegmentWriter::_abandon_index_staging() {
}
}
-// A failure below can land AFTER the ANN and BKD indexes have already been
built
-// into their staging files. The caller then returns before
close_inverted_index(),
-// so the seal that would have consumed them never runs, and the rowset writer
-// keeps this segment's IndexFileWriter -- with its staging files and their
open
-// descriptors -- until the whole load or compaction unwinds. Drop them here.
-//
-// ONLY on failure. On the success path close_inverted_index() is what consumes
-// the staging, so dropping it here would silently seal a container with no ANN
-// or BKD index in it.
-Status VerticalSegmentWriter::finalize_columns_index(uint64_t* index_size) {
-Status status = _finalize_columns_index_impl(index_size);
-if (!status.ok()) {
-_abandon_index_staging();
+Status VerticalSegmentWriter::_finalize_columns_data() {
+// check disk capacity before writing the buffered pages out
+if (_data_dir != nullptr &&
_data_dir->reach_capacity_limit((int64_t)estimate_segment_size())) {
Review Comment:
[P1] Exclude finalized key-index bytes from value-group capacity checks
In a multi-group vertical compaction, the key group is finalized before each
value group, but clear() leaves
_primary_key_index_builder/_short_key_index_builder populated. The new
_finalize_columns_data() calls estimate_segment_size() for the value group, and
_key_index_size() adds those already-written key-index bytes to the incoming
size. Near the flood threshold this can return DISK_REACH_CAPACITY_LIMIT even
when the value-group buffers fit. Please exclude finalized key-index state for
has_key == false (or reset/snapshot it) before this capacity check.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
github-actions[bot] commented on code in PR #67468: URL: https://github.com/apache/doris/pull/67468#discussion_r3921177641 ## be/src/storage/segment/vertical_segment_writer.cpp: ## @@ -17,50 +17,49 @@ #include "storage/segment/vertical_segment_writer.h" -#include -#include +#include #include #include #include -#include -#include -#include -#include -#include -#include +#include + +// IWYU pragma: no_include Review Comment: [P1] Exclude finalized key-index bytes from value-group capacity checks In a multi-group vertical compaction, the key group is finalized before each value group, but clear() leaves _primary_key_index_builder/_short_key_index_builder populated. The new _finalize_columns_data() calls estimate_segment_size() for the value group, and _key_index_size() adds those already-written key-index bytes to the incoming size. Near the flood threshold this can return DISK_REACH_CAPACITY_LIMIT even when the value-group buffers fit. Please exclude finalized key-index state for has_key == false (or reset/snapshot it) before this capacity check. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
github-actions[bot] commented on code in PR #67468: URL: https://github.com/apache/doris/pull/67468#discussion_r3921177641 ## be/src/storage/segment/vertical_segment_writer.cpp: ## @@ -17,50 +17,49 @@ #include "storage/segment/vertical_segment_writer.h" -#include -#include +#include #include #include #include -#include -#include -#include -#include -#include -#include +#include + +// IWYU pragma: no_include Review Comment: [P1] Exclude finalized key-index bytes from value-group capacity checks In a multi-group vertical compaction, the key group is finalized before each value group, but clear() leaves _primary_key_index_builder/_short_key_index_builder populated. The new _finalize_columns_data() calls estimate_segment_size() for the value group, and _key_index_size() adds those already-written key-index bytes to the incoming size. Near the flood threshold this can return DISK_REACH_CAPACITY_LIMIT even when the value-group buffers fit. Please exclude finalized key-index state for has_key == false (or reset/snapshot it) before this capacity check. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
csun5285 commented on PR #67468: URL: https://github.com/apache/doris/pull/67468#issuecomment-5520350531 /review -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] [refactor](storage) Merge SegmentWriter into VerticalSegmentWriter [doris]
hello-stephen commented on PR #67468: URL: https://github.com/apache/doris/pull/67468#issuecomment-5520349810 Thank you for your contribution to Apache Doris. Don't know what should be done next? See [How to process your PR](https://cwiki.apache.org/confluence/display/DORIS/How+to+process+your+PR). Please clearly describe your PR: 1. What problem was fixed (it's best to include specific error reporting information). How it was fixed. 2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be. 3. What features were added. Why was this function added? 4. Which code was refactored and why was this part of the code refactored? 5. Which functions were optimized and what is the difference before and after the optimization? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
