dataroaring commented on code in PR #38538:
URL: https://github.com/apache/doris/pull/38538#discussion_r1699776027
##########
be/src/olap/rowset/segment_v2/vertical_segment_writer.cpp:
##########
@@ -98,17 +98,40 @@
VerticalSegmentWriter::VerticalSegmentWriter(io::FileWriter* file_writer, uint32
CHECK_NOTNULL(file_writer);
_num_key_columns = _tablet_schema->num_key_columns();
_num_short_key_columns = _tablet_schema->num_short_key_columns();
- DCHECK(_num_key_columns >= _num_short_key_columns);
+ if (_tablet_schema->cluster_key_idxes().empty()) {
+ DCHECK(_num_key_columns >= _num_short_key_columns)
+ << ", table_id=" << _tablet_schema->table_id()
+ << ", num_key_columns=" << _num_key_columns
+ << ", num_short_key_columns=" << _num_short_key_columns
+ << ", cluster_key_columns=" <<
_tablet_schema->cluster_key_idxes().size();
+ }
for (size_t cid = 0; cid < _num_key_columns; ++cid) {
const auto& column = _tablet_schema->column(cid);
_key_coders.push_back(get_key_coder(column.type()));
_key_index_size.push_back(column.index_length());
}
// encode the sequence id into the primary key index
- if (_tablet_schema->has_sequence_col() && _tablet_schema->keys_type() ==
UNIQUE_KEYS &&
- _opts.enable_unique_key_merge_on_write) {
- const auto& column =
_tablet_schema->column(_tablet_schema->sequence_col_idx());
- _seq_coder = get_key_coder(column.type());
+ if (_tablet_schema->keys_type() == UNIQUE_KEYS &&
_opts.enable_unique_key_merge_on_write) {
+ if (_tablet_schema->has_sequence_col()) {
+ const auto& column =
_tablet_schema->column(_tablet_schema->sequence_col_idx());
+ _seq_coder = get_key_coder(column.type());
+ }
+ // encode the rowid into the primary key index
+ if (!_tablet_schema->cluster_key_idxes().empty()) {
+ const auto* type_info =
get_scalar_type_info<FieldType::OLAP_FIELD_TYPE_UNSIGNED_INT>();
+ _rowid_coder = get_key_coder(type_info->type());
+ // primary keys
+ _primary_key_coders.swap(_key_coders);
+ // cluster keys
+ _key_coders.clear();
+ _key_index_size.clear();
+ _num_key_columns = _tablet_schema->cluster_key_idxes().size();
Review Comment:
num_key_columns was set as columns of primary key and is set to columns of
cluster key. We should add some comment to explain it, comment should be put in
.h too.
--
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]