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

Remove binary scalar operator number selector caching #98

Merged
merged 3 commits into from
Oct 26, 2022

Conversation

saswatamcode
Copy link
Member

This PR removes the number selector caching from the binary scalar operator, which caused wrong results if a scalar selects from storage.
This caching is now handled by the step invariant operator instead.

For example,

For expression: 10 + scalar(max(http_requests_total))

[*CancellableOperator]: [*scalarOperator] +:
├──[*CancellableOperator]: [*stepInvariantOperator]:
│  └──[*CancellableOperator]: [*numberLiteralSelector] 10
└──[*CancellableOperator]: [*functionOperator] scalar(max(http_requests_total)):
   └──[*CancellableOperator]: [*concurrencyOperator(buff=2)]:
      └──[*CancellableOperator]: [*aggregate] max by ([]):
         └──[*CancellableOperator]: [*coalesceOperator]:
            ├──[*concurrencyOperator(buff=2)]:
            │  └──[*CancellableOperator]: [*vectorSelector] {[__name__="http_requests_total"]} 0 mod 4
            ├──[*concurrencyOperator(buff=2)]:
            │  └──[*CancellableOperator]: [*vectorSelector] {[__name__="http_requests_total"]} 1 mod 4
            ├──[*concurrencyOperator(buff=2)]:
            │  └──[*CancellableOperator]: [*vectorSelector] {[__name__="http_requests_total"]} 2 mod 4
            └──[*concurrencyOperator(buff=2)]:
               └──[*CancellableOperator]: [*vectorSelector] {[__name__="http_requests_total"]} 3 mod 4

For expression: scalar(max(http_requests_total)) + 10

[*CancellableOperator]: [*scalarOperator] +:
├──[*CancellableOperator]: [*functionOperator] scalar(max(http_requests_total)):
│  └──[*CancellableOperator]: [*concurrencyOperator(buff=2)]:
│     └──[*CancellableOperator]: [*aggregate] max by ([]):
│        └──[*CancellableOperator]: [*coalesceOperator]:
│           ├──[*concurrencyOperator(buff=2)]:
│           │  └──[*CancellableOperator]: [*vectorSelector] {[__name__="http_requests_total"]} 0 mod 4
│           ├──[*concurrencyOperator(buff=2)]:
│           │  └──[*CancellableOperator]: [*vectorSelector] {[__name__="http_requests_total"]} 1 mod 4
│           ├──[*concurrencyOperator(buff=2)]:
│           │  └──[*CancellableOperator]: [*vectorSelector] {[__name__="http_requests_total"]} 2 mod 4
│           └──[*concurrencyOperator(buff=2)]:
│              └──[*CancellableOperator]: [*vectorSelector] {[__name__="http_requests_total"]} 3 mod 4
└──[*CancellableOperator]: [*stepInvariantOperator]:
   └──[*CancellableOperator]: [*numberLiteralSelector] 10

Fixes #87.

execution/binary/scalar.go Show resolved Hide resolved
execution/binary/scalar.go Show resolved Hide resolved
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Copy link
Collaborator

@fpetkovski fpetkovski left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this, lgtm 👍

Copy link
Member

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

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

👍

@GiedriusS GiedriusS merged commit 1087b44 into thanos-io:main Oct 26, 2022
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.

Results do not match for scalar binary expressions which select from storage
3 participants