2323
2424// IWYU pragma: no_include <opentelemetry/common/threadlocal.h>
2525#include " cloud/config.h"
26+ #include " common/cast_set.h"
2627#include " common/compiler_util.h" // IWYU pragma: keep
2728#include " common/config.h"
2829#include " common/logging.h" // LOG
7071
7172namespace doris {
7273namespace segment_v2 {
74+ #include " common/compile_check_begin.h"
7375
7476using namespace ErrorCode ;
7577
@@ -106,7 +108,7 @@ SegmentWriter::SegmentWriter(io::FileWriter* file_writer, uint32_t segment_id,
106108 for (size_t cid = 0 ; cid < _num_sort_key_columns; ++cid) {
107109 const auto & column = _tablet_schema->column (cid);
108110 _key_coders.push_back (get_key_coder (column.type ()));
109- _key_index_size.push_back (column.index_length ());
111+ _key_index_size.push_back (cast_set< uint16_t >( column.index_length () ));
110112 }
111113 if (_is_mow ()) {
112114 // encode the sequence id into the primary key index
@@ -127,7 +129,7 @@ SegmentWriter::SegmentWriter(io::FileWriter* file_writer, uint32_t segment_id,
127129 for (auto cid : _tablet_schema->cluster_key_uids ()) {
128130 const auto & column = _tablet_schema->column_by_uid (cid);
129131 _key_coders.push_back (get_key_coder (column.type ()));
130- _key_index_size.push_back (column.index_length ());
132+ _key_index_size.push_back (cast_set< uint16_t >( column.index_length () ));
131133 }
132134 }
133135 }
@@ -168,7 +170,7 @@ void SegmentWriter::init_column_meta(ColumnMetaPB* meta, uint32_t column_id,
168170
169171Status SegmentWriter::init () {
170172 std::vector<uint32_t > column_ids;
171- int column_cnt = _tablet_schema->num_columns ();
173+ auto column_cnt = cast_set< int >( _tablet_schema->num_columns () );
172174 for (uint32_t i = 0 ; i < column_cnt; ++i) {
173175 column_ids.emplace_back (i);
174176 }
@@ -204,8 +206,8 @@ Status SegmentWriter::_create_column_writer(uint32_t cid, const TabletColumn& co
204206 return Status::NotSupported (" Do not support ngram bloom filter for bf_size: " ,
205207 gram_bf_size);
206208 }
207- opts.gram_size = gram_size;
208- opts.gram_bf_size = gram_bf_size;
209+ opts.gram_size = cast_set< uint8_t >( gram_size) ;
210+ opts.gram_bf_size = cast_set< uint16_t >( gram_bf_size) ;
209211 }
210212
211213 opts.need_bitmap_index = column.has_bitmap_index ();
@@ -401,7 +403,7 @@ Status SegmentWriter::append_block_with_variant_subcolumns(vectorized::Block& da
401403 continue ;
402404 }
403405 CHECK (entry->data .is_finalized ());
404- int current_column_id = column_id++;
406+ auto current_column_id = cast_set< int >( column_id++) ;
405407 TabletColumn tablet_column = generate_column_info (entry);
406408 vectorized::schema_util::inherit_column_attributes (*parent_column, tablet_column,
407409 _flush_schema);
@@ -473,8 +475,8 @@ void SegmentWriter::_serialize_block_to_row_column(vectorized::Block& block) {
473475 vectorized::DataTypeSerDeSPtrs serdes =
474476 vectorized::create_data_type_serdes (block.get_data_types ());
475477 vectorized::JsonbSerializeUtil::block_to_jsonb (
476- *_tablet_schema, block, *row_store_column, _tablet_schema-> num_columns (),
477- serdes,
478+ *_tablet_schema, block, *row_store_column,
479+ cast_set< int >(_tablet_schema-> num_columns ()), serdes,
478480 {_tablet_schema->row_columns_uids ().begin (),
479481 _tablet_schema->row_columns_uids ().end ()});
480482 break ;
@@ -496,9 +498,9 @@ Status SegmentWriter::probe_key_for_mow(
496498 RowLocation loc;
497499 // save rowset shared ptr so this rowset wouldn't delete
498500 RowsetSharedPtr rowset;
499- auto st = _tablet->lookup_row_key (key, _tablet_schema. get (), have_input_seq_column,
500- specified_rowsets, &loc, _mow_context-> max_version ,
501- segment_caches, &rowset);
501+ auto st = _tablet->lookup_row_key (
502+ key, _tablet_schema. get (), have_input_seq_column, specified_rowsets, &loc,
503+ cast_set< uint32_t >(_mow_context-> max_version ), segment_caches, &rowset);
502504 if (st.is <KEY_NOT_FOUND>()) {
503505 if (!have_delete_sign) {
504506 RETURN_IF_ERROR (not_found_cb ());
@@ -537,7 +539,7 @@ Status SegmentWriter::probe_key_for_mow(
537539 // for this row, we need to ensure that each column is aligned
538540 _mow_context->delete_bitmap ->add (
539541 {_opts.rowset_ctx ->rowset_id , _segment_id, DeleteBitmap::TEMP_VERSION_COMMON},
540- segment_pos);
542+ cast_set< uint32_t >( segment_pos) );
541543 ++stats.num_rows_deleted ;
542544 } else {
543545 _mow_context->delete_bitmap ->add (
@@ -678,7 +680,8 @@ Status SegmentWriter::append_block_with_partial_content(const vectorized::Block*
678680 auto not_found_cb = [&]() {
679681 return _opts.rowset_ctx ->partial_update_info ->handle_new_key (
680682 *_tablet_schema, [&]() -> std::string {
681- return block->dump_one_line (block_pos, _num_sort_key_columns);
683+ return block->dump_one_line (block_pos,
684+ cast_set<int >(_num_sort_key_columns));
682685 });
683686 };
684687 auto update_read_plan = [&](const RowLocation& loc) {
@@ -699,7 +702,8 @@ Status SegmentWriter::append_block_with_partial_content(const vectorized::Block*
699702 // read to fill full block
700703 RETURN_IF_ERROR (read_plan.fill_missing_columns (
701704 _opts.rowset_ctx , _rsid_to_rowset, *_tablet_schema, full_block,
702- use_default_or_null_flag, has_default_or_nullable, segment_start_pos, block));
705+ use_default_or_null_flag, has_default_or_nullable,
706+ cast_set<uint32_t >(segment_start_pos), block));
703707
704708 // convert block to row store format
705709 _serialize_block_to_row_column (full_block);
@@ -959,7 +963,7 @@ std::string SegmentWriter::_encode_keys(
959963template <typename RowType>
960964Status SegmentWriter::append_row (const RowType& row) {
961965 for (size_t cid = 0 ; cid < _column_writers.size (); ++cid) {
962- auto cell = row.cell (cid);
966+ auto cell = row.cell (cast_set< uint32_t >( cid) );
963967 RETURN_IF_ERROR (_column_writers[cid]->append (cell));
964968 }
965969 std::string full_encoded_key;
@@ -1207,7 +1211,7 @@ Status SegmentWriter::_write_footer() {
12071211
12081212 faststring fixed_buf;
12091213 // footer's size
1210- put_fixed32_le (&fixed_buf, footer_buf.size ());
1214+ put_fixed32_le (&fixed_buf, cast_set< uint32_t >( footer_buf.size () ));
12111215 // footer's checksum
12121216 uint32_t checksum = crc32c::Value (footer_buf.data (), footer_buf.size ());
12131217 put_fixed32_le (&fixed_buf, checksum);
@@ -1324,5 +1328,6 @@ inline bool SegmentWriter::_is_mow() {
13241328inline bool SegmentWriter::_is_mow_with_cluster_key () {
13251329 return _is_mow () && !_tablet_schema->cluster_key_uids ().empty ();
13261330}
1331+ #include " common/compile_check_end.h"
13271332} // namespace segment_v2
13281333} // namespace doris
0 commit comments