HappenLee commented on code in PR #26160: URL: https://github.com/apache/doris/pull/26160#discussion_r1378386424
########## be/src/vec/exprs/vcompound_pred.h: ########## @@ -52,86 +54,196 @@ class VCompoundPred : public VectorizedFnCall { const std::string& expr_name() const override { return _expr_name; } Status execute(VExprContext* context, Block* block, int* result_column_id) override { - if (children().size() == 1 || !_all_child_is_compound_and_not_const() || - _children[0]->is_nullable() || _children[1]->is_nullable()) { - // TODO: - // When the child is nullable, make the optimization also take effect, and the processing of this piece may be more complicated - // https://dev.mysql.com/doc/refman/8.0/en/logical-operators.html + if (children().size() == 1 || !_all_child_is_compound_and_not_const()) { return VectorizedFnCall::execute(context, block, result_column_id); } int lhs_id = -1; int rhs_id = -1; RETURN_IF_ERROR(_children[0]->execute(context, block, &lhs_id)); - ColumnPtr lhs_column = - block->get_by_position(lhs_id).column->convert_to_full_column_if_const(); - + //should deal with const column ? + ColumnPtr lhs_column = block->get_by_position(lhs_id).column; size_t size = lhs_column->size(); - uint8* __restrict data = _get_raw_data(lhs_column); - int filted = simd::count_zero_num((int8_t*)data, size); - bool full = filted == 0; - bool empty = filted == size; + bool lhs_is_nullable = lhs_column->is_nullable(); + auto [lhs_data_column, lhs_null_map] = + _get_raw_data_and_null_map(lhs_column, lhs_is_nullable); + int filted = simd::count_zero_num((int8_t*)lhs_data_column, size); + bool lhs_all_true = (filted == 0); + bool lhs_all_false = (filted == size); + + bool lhs_all_is_not_null = false; + if (lhs_is_nullable) { + filted = simd::count_zero_num((int8_t*)lhs_null_map, size); + lhs_all_is_not_null = (filted == size); + } ColumnPtr rhs_column = nullptr; - uint8* __restrict data_rhs = nullptr; - bool full_rhs = false; - bool empty_rhs = false; + uint8* __restrict rhs_data_column = nullptr; + uint8* __restrict rhs_null_map = nullptr; + bool rhs_is_nullable = false; + bool rhs_all_true = false; + bool rhs_all_false = false; + bool rhs_all_is_not_null = false; + bool result_is_nullable = _data_type->is_nullable(); auto get_rhs_colum = [&]() { Review Comment: why not use same func to dispose the left column? ########## be/src/vec/exprs/vcompound_pred.h: ########## @@ -52,86 +54,196 @@ class VCompoundPred : public VectorizedFnCall { const std::string& expr_name() const override { return _expr_name; } Status execute(VExprContext* context, Block* block, int* result_column_id) override { - if (children().size() == 1 || !_all_child_is_compound_and_not_const() || - _children[0]->is_nullable() || _children[1]->is_nullable()) { - // TODO: - // When the child is nullable, make the optimization also take effect, and the processing of this piece may be more complicated - // https://dev.mysql.com/doc/refman/8.0/en/logical-operators.html + if (children().size() == 1 || !_all_child_is_compound_and_not_const()) { return VectorizedFnCall::execute(context, block, result_column_id); } int lhs_id = -1; int rhs_id = -1; RETURN_IF_ERROR(_children[0]->execute(context, block, &lhs_id)); - ColumnPtr lhs_column = - block->get_by_position(lhs_id).column->convert_to_full_column_if_const(); - + //should deal with const column ? + ColumnPtr lhs_column = block->get_by_position(lhs_id).column; size_t size = lhs_column->size(); - uint8* __restrict data = _get_raw_data(lhs_column); - int filted = simd::count_zero_num((int8_t*)data, size); - bool full = filted == 0; - bool empty = filted == size; + bool lhs_is_nullable = lhs_column->is_nullable(); + auto [lhs_data_column, lhs_null_map] = + _get_raw_data_and_null_map(lhs_column, lhs_is_nullable); + int filted = simd::count_zero_num((int8_t*)lhs_data_column, size); + bool lhs_all_true = (filted == 0); + bool lhs_all_false = (filted == size); + + bool lhs_all_is_not_null = false; + if (lhs_is_nullable) { + filted = simd::count_zero_num((int8_t*)lhs_null_map, size); + lhs_all_is_not_null = (filted == size); + } ColumnPtr rhs_column = nullptr; - uint8* __restrict data_rhs = nullptr; - bool full_rhs = false; - bool empty_rhs = false; + uint8* __restrict rhs_data_column = nullptr; + uint8* __restrict rhs_null_map = nullptr; + bool rhs_is_nullable = false; + bool rhs_all_true = false; + bool rhs_all_false = false; + bool rhs_all_is_not_null = false; + bool result_is_nullable = _data_type->is_nullable(); auto get_rhs_colum = [&]() { Review Comment: why not use same func to dispose the left column? -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org