Skip to content

Commit 7f7ee55

Browse files
committed
[chore](cleanup) remove useless field is_materialized in SlotDescriptor (#58320)
removed `is_materialized` and `need_materialize` in BE. tagged with deprecated in thrift and protobuf. remove `need_materialize` in FE.
1 parent 919f84c commit 7f7ee55

39 files changed

+61
-265
lines changed

be/src/exec/es/es_scroll_parser.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,11 +660,8 @@ Status ScrollParser::fill_columns(const TupleDescriptor* tuple_desc,
660660

661661
for (int i = 0; i < tuple_desc->slots().size(); ++i) {
662662
const SlotDescriptor* slot_desc = tuple_desc->slots()[i];
663-
auto col_ptr = columns[i].get();
663+
auto* col_ptr = columns[i].get();
664664

665-
if (!slot_desc->is_materialized()) {
666-
continue;
667-
}
668665
if (slot_desc->col_name() == FIELD_ID) {
669666
// actually this branch will not be reached, this is guaranteed by Doris FE.
670667
if (pure_doc_value) {

be/src/olap/push_handler.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,7 @@ Status PushBrokerReader::_convert_to_output_block(vectorized::Block* block) {
525525
size_t rows = _src_block.rows();
526526
auto filter_column = vectorized::ColumnUInt8::create(rows, 1);
527527

528-
for (auto slot_desc : _dest_tuple_desc->slots()) {
529-
if (!slot_desc->is_materialized()) {
530-
continue;
531-
}
528+
for (auto* slot_desc : _dest_tuple_desc->slots()) {
532529
int dest_index = ctx_idx++;
533530
vectorized::ColumnPtr column_ptr;
534531

@@ -612,9 +609,6 @@ Status PushBrokerReader::_init_expr_ctxes() {
612609
}
613610
bool has_slot_id_map = _params.__isset.dest_sid_to_src_sid_without_trans;
614611
for (auto slot_desc : _dest_tuple_desc->slots()) {
615-
if (!slot_desc->is_materialized()) {
616-
continue;
617-
}
618612
auto it = _params.expr_of_dest_slot.find(slot_desc->id());
619613
if (it == std::end(_params.expr_of_dest_slot)) {
620614
return Status::InternalError("No expr for dest slot, id={}, name={}", slot_desc->id(),

be/src/pipeline/exec/es_scan_operator.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,7 @@ Status EsScanOperatorX::prepare(RuntimeState* state) {
142142
}
143143

144144
// set up column name vector for ESScrollQueryBuilder
145-
for (auto slot_desc : _tuple_desc->slots()) {
146-
if (!slot_desc->is_materialized()) {
147-
continue;
148-
}
145+
for (auto* slot_desc : _tuple_desc->slots()) {
149146
_column_names.push_back(slot_desc->col_name());
150147
}
151148

be/src/pipeline/exec/result_sink_operator.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,6 @@ Status ResultSinkOperatorX::prepare(RuntimeState* state) {
121121
// prepare output_expr
122122
// From the thrift expressions create the real exprs.
123123
RETURN_IF_ERROR(vectorized::VExpr::create_expr_trees(_t_output_expr, _output_vexpr_ctxs));
124-
if (_fetch_option.use_two_phase_fetch) {
125-
for (auto& expr_ctx : _output_vexpr_ctxs) {
126-
// Must materialize if it a slot, or the slot column id will be -1
127-
expr_ctx->set_force_materialize_slot();
128-
}
129-
}
130124
// Prepare the exprs to run.
131125
RETURN_IF_ERROR(vectorized::VExpr::prepare(_output_vexpr_ctxs, state, _row_desc));
132126

be/src/runtime/descriptor_helper.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class TSlotDescriptorBuilder {
7777
return type_desc;
7878
}
7979

80-
TSlotDescriptorBuilder() { _slot_desc.isMaterialized = true; }
80+
TSlotDescriptorBuilder() = default;
8181
TSlotDescriptorBuilder& type(PrimitiveType type) {
8282
_slot_desc.slotType = get_common_type(to_thrift(type));
8383
return *this;
@@ -97,10 +97,6 @@ class TSlotDescriptorBuilder {
9797
_slot_desc.nullIndicatorByte = (nullable) ? 0 : -1;
9898
return *this;
9999
}
100-
TSlotDescriptorBuilder& is_materialized(bool is_materialized) {
101-
_slot_desc.isMaterialized = is_materialized;
102-
return *this;
103-
}
104100
TSlotDescriptorBuilder& column_name(const std::string& name) {
105101
_slot_desc.colName = name;
106102
return *this;
@@ -135,10 +131,6 @@ class TSlotDescriptorBuilder {
135131
_slot_desc.slotIdx = slotIdx;
136132
return *this;
137133
}
138-
TSlotDescriptorBuilder& set_isMaterialized(bool isMaterialized) {
139-
_slot_desc.isMaterialized = isMaterialized;
140-
return *this;
141-
}
142134
TSlotDescriptorBuilder& set_colName(std::string colName) {
143135
_slot_desc.colName = colName;
144136
return *this;

be/src/runtime/descriptors.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ SlotDescriptor::SlotDescriptor(const TSlotDescriptor& tdesc)
6060
_col_unique_id(tdesc.col_unique_id),
6161
_slot_idx(tdesc.slotIdx),
6262
_field_idx(-1),
63-
_is_materialized(tdesc.isMaterialized && tdesc.need_materialize),
6463
_is_key(tdesc.is_key),
6564
_column_paths(tdesc.column_paths),
6665
_is_auto_increment(tdesc.__isset.is_auto_increment ? tdesc.is_auto_increment : false),
@@ -95,7 +94,6 @@ SlotDescriptor::SlotDescriptor(const PSlotDescriptor& pdesc)
9594
_col_unique_id(pdesc.col_unique_id()),
9695
_slot_idx(pdesc.slot_idx()),
9796
_field_idx(-1),
98-
_is_materialized(pdesc.is_materialized()),
9997
_is_key(pdesc.is_key()),
10098
_column_paths(pdesc.column_paths().begin(), pdesc.column_paths().end()),
10199
_is_auto_increment(pdesc.is_auto_increment()) {}
@@ -109,7 +107,6 @@ SlotDescriptor::SlotDescriptor()
109107
_col_unique_id(0),
110108
_slot_idx(0),
111109
_field_idx(-1),
112-
_is_materialized(true),
113110
_is_key(false),
114111
_is_auto_increment(false) {}
115112
#endif
@@ -124,7 +121,6 @@ void SlotDescriptor::to_protobuf(PSlotDescriptor* pslot) const {
124121
pslot->set_null_indicator_bit(_type->is_nullable() ? 0 : -1);
125122
pslot->set_col_name(_col_name);
126123
pslot->set_slot_idx(_slot_idx);
127-
pslot->set_is_materialized(_is_materialized);
128124
pslot->set_col_unique_id(_col_unique_id);
129125
pslot->set_is_key(_is_key);
130126
pslot->set_is_auto_increment(_is_auto_increment);
@@ -366,15 +362,12 @@ TupleDescriptor::TupleDescriptor(const PTupleDescriptor& pdesc, bool own_slots)
366362

367363
void TupleDescriptor::add_slot(SlotDescriptor* slot) {
368364
_slots.push_back(slot);
365+
++_num_materialized_slots;
369366

370-
if (slot->is_materialized()) {
371-
++_num_materialized_slots;
372-
373-
if (is_complex_type(slot->type()->get_primitive_type()) ||
374-
is_var_len_object(slot->type()->get_primitive_type()) ||
375-
is_string_type(slot->type()->get_primitive_type())) {
376-
_has_varlen_slots = true;
377-
}
367+
if (is_complex_type(slot->type()->get_primitive_type()) ||
368+
is_var_len_object(slot->type()->get_primitive_type()) ||
369+
is_string_type(slot->type()->get_primitive_type())) {
370+
_has_varlen_slots = true;
378371
}
379372
}
380373

@@ -565,13 +558,10 @@ std::string RowDescriptor::debug_string() const {
565558
return ss.str();
566559
}
567560

568-
int RowDescriptor::get_column_id(int slot_id, bool force_materialize_slot) const {
561+
int RowDescriptor::get_column_id(int slot_id) const {
569562
int column_id_counter = 0;
570563
for (auto* const tuple_desc : _tuple_desc_map) {
571564
for (auto* const slot : tuple_desc->slots()) {
572-
if (!force_materialize_slot && !slot->is_materialized()) {
573-
continue;
574-
}
575565
if (slot->id() == slot_id) {
576566
return column_id_counter;
577567
}

be/src/runtime/descriptors.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#include <gen_cpp/Types_types.h>
2626
#include <glog/logging.h>
2727
#include <google/protobuf/stubs/port.h>
28-
#include <stdint.h>
2928

29+
#include <cstdint>
3030
#include <ostream>
3131
#include <string>
3232
#include <unordered_map>
@@ -42,6 +42,7 @@
4242
#include "runtime/define_primitive_type.h"
4343
#include "runtime/types.h"
4444
#include "vec/data_types/data_type.h"
45+
4546
namespace google::protobuf {
4647
template <typename Element>
4748
class RepeatedField;
@@ -57,14 +58,13 @@ class SlotDescriptor {
5758
public:
5859
MOCK_DEFINE(virtual ~SlotDescriptor() = default;)
5960
SlotId id() const { return _id; }
60-
const vectorized::DataTypePtr type() const { return _type; }
61+
vectorized::DataTypePtr type() const { return _type; }
6162
TupleId parent() const { return _parent; }
6263
// Returns the column index of this slot, including partition keys.
6364
// (e.g., col_pos - num_partition_keys = the table column this slot corresponds to)
6465
int col_pos() const { return _col_pos; }
6566
// Returns the field index in the generated llvm struct for this slot's tuple
6667
int field_idx() const { return _field_idx; }
67-
bool is_materialized() const { return _is_materialized; }
6868
bool is_nullable() const;
6969
vectorized::DataTypePtr get_data_type_ptr() const;
7070

@@ -123,8 +123,6 @@ class SlotDescriptor {
123123
// leading null bytes.
124124
int _field_idx;
125125

126-
const bool _is_materialized;
127-
128126
const bool _is_key;
129127
const std::vector<std::string> _column_paths;
130128

@@ -499,7 +497,7 @@ class RowDescriptor {
499497

500498
std::string debug_string() const;
501499

502-
int get_column_id(int slot_id, bool force_materialize_slot = false) const;
500+
int get_column_id(int slot_id) const;
503501

504502
private:
505503
// Initializes tupleIdxMap during c'tor using the _tuple_desc_map.

be/src/vec/common/sort/sorter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ class MergeSorterState {
5656
// create_empty_block should ignore invalid slots, unsorted_block
5757
// should be same structure with arrival block from child node
5858
// since block from child node may ignored these slots
59-
: _unsorted_block(Block::create_unique(
60-
VectorizedUtils::create_empty_block(row_desc, true /*ignore invalid slot*/))),
59+
: _unsorted_block(Block::create_unique(VectorizedUtils::create_empty_block(row_desc))),
6160
_offset(offset) {}
6261

6362
~MergeSorterState() = default;

be/src/vec/core/block.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,26 +86,21 @@ Block::Block(std::initializer_list<ColumnWithTypeAndName> il) : data {il} {}
8686

8787
Block::Block(ColumnsWithTypeAndName data_) : data {std::move(data_)} {}
8888

89-
Block::Block(const std::vector<SlotDescriptor*>& slots, size_t block_size,
90-
bool ignore_trivial_slot) {
89+
Block::Block(const std::vector<SlotDescriptor*>& slots, size_t block_size) {
9190
for (auto* const slot_desc : slots) {
92-
if (ignore_trivial_slot && !slot_desc->is_materialized()) {
93-
continue;
94-
}
9591
auto column_ptr = slot_desc->get_empty_mutable_column();
9692
column_ptr->reserve(block_size);
9793
insert(ColumnWithTypeAndName(std::move(column_ptr), slot_desc->get_data_type_ptr(),
9894
slot_desc->col_name()));
9995
}
10096
}
10197

102-
Block::Block(const std::vector<SlotDescriptor>& slots, size_t block_size,
103-
bool ignore_trivial_slot) {
98+
Block::Block(const std::vector<SlotDescriptor>& slots, size_t block_size) {
10499
std::vector<SlotDescriptor*> slot_ptrs(slots.size());
105100
for (size_t i = 0; i < slots.size(); ++i) {
106101
slot_ptrs[i] = const_cast<SlotDescriptor*>(&slots[i]);
107102
}
108-
*this = Block(slot_ptrs, block_size, ignore_trivial_slot);
103+
*this = Block(slot_ptrs, block_size);
109104
}
110105

111106
Status Block::deserialize(const PBlock& pblock, size_t* uncompressed_bytes,

be/src/vec/core/block.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,8 @@ class Block {
7979
Block() = default;
8080
Block(std::initializer_list<ColumnWithTypeAndName> il);
8181
Block(ColumnsWithTypeAndName data_);
82-
Block(const std::vector<SlotDescriptor*>& slots, size_t block_size,
83-
bool ignore_trivial_slot = false);
84-
Block(const std::vector<SlotDescriptor>& slots, size_t block_size,
85-
bool ignore_trivial_slot = false);
82+
Block(const std::vector<SlotDescriptor*>& slots, size_t block_size);
83+
Block(const std::vector<SlotDescriptor>& slots, size_t block_size);
8684

8785
MOCK_FUNCTION ~Block() = default;
8886
Block(const Block& block) = default;

0 commit comments

Comments
 (0)