Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](expr)Remove the _can_fast_execute flag from VExpr. (#45542) #45662

Merged
merged 2 commits into from
Dec 22, 2024

Conversation

Mryange
Copy link
Contributor

@Mryange Mryange commented Dec 19, 2024

#45655
In the past, a _can_fast_execute flag was maintained in VExpr. However, since exec executes concurrently, errors would occur when using the _can_fast_execute judgment.

In fact, we don't need the _can_fast_execute variable because fast_execute will perform the necessary checks itself.

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

In the past, a _can_fast_execute flag was maintained in VExpr.
However, since exec executes concurrently, errors would occur when using
the _can_fast_execute judgment.

In fact, we don't need the _can_fast_execute variable
because fast_execute will perform the necessary checks itself.
@hello-stephen
Copy link
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See 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?

@Mryange
Copy link
Contributor Author

Mryange commented Dec 19, 2024

run buildall

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@@ -144,15 +144,13 @@ class VCompoundPred : public VectorizedFnCall {
}

if (all_pass && !res.is_empty()) {
// set fast_execute when expr evaluated by inverted index correctly
_can_fast_execute = true;
context->get_inverted_index_context()->set_inverted_index_result_for_expr(this, res);
}
return Status::OK();
}

Status execute(VExprContext* context, Block* block, int* result_column_id) override {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'execute' has cognitive complexity of 111 (threshold 50) [readability-function-cognitive-complexity]

    Status execute(VExprContext* context, Block* block, int* result_column_id) override {
           ^
Additional context

be/src/vec/exprs/vcompound_pred.h:152: +1, including nesting penalty of 0, nesting level increased to 1

        if (fast_execute(context, block, result_column_id)) {
        ^

be/src/vec/exprs/vcompound_pred.h:155: +1, including nesting penalty of 0, nesting level increased to 1

        if (children().size() == 1 || !_all_child_is_compound_and_not_const()) {
        ^

be/src/vec/exprs/vcompound_pred.h:161: +1, including nesting penalty of 0, nesting level increased to 1

        RETURN_IF_ERROR(_children[0]->execute(context, block, &lhs_id));
        ^

be/src/common/status.h:622: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/vec/exprs/vcompound_pred.h:161: +2, including nesting penalty of 1, nesting level increased to 2

        RETURN_IF_ERROR(_children[0]->execute(context, block, &lhs_id));
        ^

be/src/common/status.h:624: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/vec/exprs/vcompound_pred.h:173: +1, including nesting penalty of 0, nesting level increased to 1

        if (lhs_is_nullable) {
        ^

be/src/vec/exprs/vcompound_pred.h:187: nesting level increased to 1

        auto get_rhs_colum = [&]() {
                             ^

be/src/vec/exprs/vcompound_pred.h:188: +2, including nesting penalty of 1, nesting level increased to 2

            if (rhs_id == -1) {
            ^

be/src/vec/exprs/vcompound_pred.h:189: +3, including nesting penalty of 2, nesting level increased to 3

                RETURN_IF_ERROR(_children[1]->execute(context, block, &rhs_id));
                ^

be/src/common/status.h:622: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/vec/exprs/vcompound_pred.h:189: +4, including nesting penalty of 3, nesting level increased to 4

                RETURN_IF_ERROR(_children[1]->execute(context, block, &rhs_id));
                ^

be/src/common/status.h:624: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/vec/exprs/vcompound_pred.h:199: +3, including nesting penalty of 2, nesting level increased to 3

                if (rhs_is_nullable) {
                ^

be/src/vec/exprs/vcompound_pred.h:207: nesting level increased to 1

        auto return_result_column_id = [&](ColumnPtr res_column, int res_id) -> int {
                                       ^

be/src/vec/exprs/vcompound_pred.h:208: +2, including nesting penalty of 1, nesting level increased to 2

            if (result_is_nullable && !res_column->is_nullable()) {
            ^

be/src/vec/exprs/vcompound_pred.h:208: +1

            if (result_is_nullable && !res_column->is_nullable()) {
                                   ^

be/src/vec/exprs/vcompound_pred.h:217: nesting level increased to 1

        auto create_null_map_column = [&](ColumnPtr& null_map_column,
                                      ^

be/src/vec/exprs/vcompound_pred.h:219: +2, including nesting penalty of 1, nesting level increased to 2

            if (null_map_data == nullptr) {
            ^

be/src/vec/exprs/vcompound_pred.h:228: nesting level increased to 1

        auto vector_vector_null = [&]<bool is_and_op>() {
                                  ^

be/src/vec/exprs/vcompound_pred.h:238: +2, including nesting penalty of 1, nesting level increased to 2

            if constexpr (is_and_op) {
            ^

be/src/vec/exprs/vcompound_pred.h:239: +3, including nesting penalty of 2, nesting level increased to 3

                for (size_t i = 0; i < size; ++i) {
                ^

be/src/vec/exprs/vcompound_pred.h:244: +1, nesting level increased to 2

            } else {
              ^

be/src/vec/exprs/vcompound_pred.h:245: +3, including nesting penalty of 2, nesting level increased to 3

                for (size_t i = 0; i < size; ++i) {
                ^

be/src/vec/exprs/vcompound_pred.h:258: +1, including nesting penalty of 0, nesting level increased to 1

        if (_op == TExprOpcode::COMPOUND_AND) {
        ^

be/src/vec/exprs/vcompound_pred.h:261: +2, including nesting penalty of 1, nesting level increased to 2

            if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) {
            ^

be/src/vec/exprs/vcompound_pred.h:261: +1

            if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) {
                                                    ^

be/src/vec/exprs/vcompound_pred.h:261: +1

            if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) {
                               ^

be/src/vec/exprs/vcompound_pred.h:261: +1

            if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) {
                                                                      ^

be/src/vec/exprs/vcompound_pred.h:264: +1, nesting level increased to 2

            } else {
              ^

be/src/vec/exprs/vcompound_pred.h:265: +3, including nesting penalty of 2, nesting level increased to 3

                RETURN_IF_ERROR(get_rhs_colum());
                ^

be/src/common/status.h:622: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/vec/exprs/vcompound_pred.h:265: +4, including nesting penalty of 3, nesting level increased to 4

                RETURN_IF_ERROR(get_rhs_colum());
                ^

be/src/common/status.h:624: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/vec/exprs/vcompound_pred.h:267: +3, including nesting penalty of 2, nesting level increased to 3

                if ((lhs_all_true && !lhs_is_nullable) ||    //not null column
                ^

be/src/vec/exprs/vcompound_pred.h:267: +1

                if ((lhs_all_true && !lhs_is_nullable) ||    //not null column
                                                       ^

be/src/vec/exprs/vcompound_pred.h:267: +1

                if ((lhs_all_true && !lhs_is_nullable) ||    //not null column
                                  ^

be/src/vec/exprs/vcompound_pred.h:268: +1

                    (lhs_all_true && lhs_all_is_not_null)) { //nullable column
                                  ^

be/src/vec/exprs/vcompound_pred.h:271: +1, nesting level increased to 3

                } else if ((rhs_all_false && !rhs_is_nullable) ||
                       ^

be/src/vec/exprs/vcompound_pred.h:271: +1

                } else if ((rhs_all_false && !rhs_is_nullable) ||
                                                               ^

be/src/vec/exprs/vcompound_pred.h:271: +1

                } else if ((rhs_all_false && !rhs_is_nullable) ||
                                          ^

be/src/vec/exprs/vcompound_pred.h:272: +1

                           (rhs_all_false && rhs_all_is_not_null)) {
                                          ^

be/src/vec/exprs/vcompound_pred.h:275: +1, nesting level increased to 3

                } else if ((rhs_all_true && !rhs_is_nullable) ||
                       ^

be/src/vec/exprs/vcompound_pred.h:275: +1

                } else if ((rhs_all_true && !rhs_is_nullable) ||
                                                              ^

be/src/vec/exprs/vcompound_pred.h:275: +1

                } else if ((rhs_all_true && !rhs_is_nullable) ||
                                         ^

be/src/vec/exprs/vcompound_pred.h:276: +1

                           (rhs_all_true && rhs_all_is_not_null)) {
                                         ^

be/src/vec/exprs/vcompound_pred.h:279: +1, nesting level increased to 3

                } else {
                  ^

be/src/vec/exprs/vcompound_pred.h:280: +4, including nesting penalty of 3, nesting level increased to 4

                    if (!result_is_nullable) {
                    ^

be/src/vec/exprs/vcompound_pred.h:282: +5, including nesting penalty of 4, nesting level increased to 5

                        for (size_t i = 0; i < size; i++) {
                        ^

be/src/vec/exprs/vcompound_pred.h:285: +1, nesting level increased to 4

                    } else {
                      ^

be/src/vec/exprs/vcompound_pred.h:290: +1, nesting level increased to 1

        } else if (_op == TExprOpcode::COMPOUND_OR) {
               ^

be/src/vec/exprs/vcompound_pred.h:293: +2, including nesting penalty of 1, nesting level increased to 2

            if ((lhs_all_true && !lhs_is_nullable) || (lhs_all_true && lhs_all_is_not_null)) {
            ^

be/src/vec/exprs/vcompound_pred.h:293: +1

            if ((lhs_all_true && !lhs_is_nullable) || (lhs_all_true && lhs_all_is_not_null)) {
                                                   ^

be/src/vec/exprs/vcompound_pred.h:293: +1

            if ((lhs_all_true && !lhs_is_nullable) || (lhs_all_true && lhs_all_is_not_null)) {
                              ^

be/src/vec/exprs/vcompound_pred.h:293: +1

            if ((lhs_all_true && !lhs_is_nullable) || (lhs_all_true && lhs_all_is_not_null)) {
                                                                    ^

be/src/vec/exprs/vcompound_pred.h:296: +1, nesting level increased to 2

            } else {
              ^

be/src/vec/exprs/vcompound_pred.h:297: +3, including nesting penalty of 2, nesting level increased to 3

                RETURN_IF_ERROR(get_rhs_colum());
                ^

be/src/common/status.h:622: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/vec/exprs/vcompound_pred.h:297: +4, including nesting penalty of 3, nesting level increased to 4

                RETURN_IF_ERROR(get_rhs_colum());
                ^

be/src/common/status.h:624: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/vec/exprs/vcompound_pred.h:298: +3, including nesting penalty of 2, nesting level increased to 3

                if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) {
                ^

be/src/vec/exprs/vcompound_pred.h:298: +1

                if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) {
                                                        ^

be/src/vec/exprs/vcompound_pred.h:298: +1

                if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) {
                                   ^

be/src/vec/exprs/vcompound_pred.h:298: +1

                if ((lhs_all_false && !lhs_is_nullable) || (lhs_all_false && lhs_all_is_not_null)) {
                                                                          ^

be/src/vec/exprs/vcompound_pred.h:301: +1, nesting level increased to 3

                } else if ((rhs_all_true && !rhs_is_nullable) ||
                       ^

be/src/vec/exprs/vcompound_pred.h:301: +1

                } else if ((rhs_all_true && !rhs_is_nullable) ||
                                                              ^

be/src/vec/exprs/vcompound_pred.h:301: +1

                } else if ((rhs_all_true && !rhs_is_nullable) ||
                                         ^

be/src/vec/exprs/vcompound_pred.h:302: +1

                           (rhs_all_true && rhs_all_is_not_null)) {
                                         ^

be/src/vec/exprs/vcompound_pred.h:305: +1, nesting level increased to 3

                } else if ((rhs_all_false && !rhs_is_nullable) ||
                       ^

be/src/vec/exprs/vcompound_pred.h:305: +1

                } else if ((rhs_all_false && !rhs_is_nullable) ||
                                                               ^

be/src/vec/exprs/vcompound_pred.h:305: +1

                } else if ((rhs_all_false && !rhs_is_nullable) ||
                                          ^

be/src/vec/exprs/vcompound_pred.h:306: +1

                           (rhs_all_false && rhs_all_is_not_null)) {
                                          ^

be/src/vec/exprs/vcompound_pred.h:309: +1, nesting level increased to 3

                } else {
                  ^

be/src/vec/exprs/vcompound_pred.h:310: +4, including nesting penalty of 3, nesting level increased to 4

                    if (!result_is_nullable) {
                    ^

be/src/vec/exprs/vcompound_pred.h:312: +5, including nesting penalty of 4, nesting level increased to 5

                        for (size_t i = 0; i < size; i++) {
                        ^

be/src/vec/exprs/vcompound_pred.h:315: +1, nesting level increased to 4

                    } else {
                      ^

be/src/vec/exprs/vcompound_pred.h:320: +1, nesting level increased to 1

        } else {
          ^

@Mryange
Copy link
Contributor Author

Mryange commented Dec 19, 2024

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 36.46% (9569/26244)
Line Coverage: 27.92% (78656/281683)
Region Coverage: 26.60% (40383/151817)
Branch Coverage: 23.35% (20443/87564)
Coverage Report: http://coverage.selectdb-in.cc/coverage/8bae95d8a7699f6b4a175a4ae6291945c66f456f_8bae95d8a7699f6b4a175a4ae6291945c66f456f/report/index.html

@yiguolei yiguolei merged commit 367ecc3 into apache:branch-2.1 Dec 22, 2024
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants