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

opt: move fraction function from statistics code to selectivity #60012

Merged
merged 1 commit into from
Feb 8, 2021

Conversation

angelazxu
Copy link
Contributor

The fraction function in the statistics builder code was only being used to
construct Selectivity, used inside the MakeSelectivity method.

This change moves the logic from the fraction function into the code for
Selectivity. It is an additional clean-up to #59413, to get rid of direct
numerical operations on Selectivity.

Fixes: #53860

Release note: None

@angelazxu angelazxu requested a review from a team as a code owner February 8, 2021 20:56
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

Nice! :lgtm:

Reviewed 3 of 3 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @angelazxu)


pkg/sql/opt/props/selectivity.go, line 38 at r1 (raw file):

// MakeSelectivityFromFraction calculates selectivity as a fraction of a and b
// if a is less than b and returns 1 otherwise.

[nit] "... and returns OneSelectivity otherwise."


pkg/sql/opt/props/selectivity_test.go, line 67 at r1 (raw file):

	test(MakeSelectivityFromFraction(1.5, 1), s(1))
	test(MakeSelectivityFromFraction(1, 0), s(1))
	test(MakeSelectivityFromFraction(0, 0), s(1))

Why use s(1) three times here instead of OneSelectivity?

The fraction function in the statistics builder code was only being used to
construct Selectivity, used inside the MakeSelectivity method.

This change moves the logic from the fraction function into the code for
Selectivity. It is an additional clean-up to cockroachdb#59413, to get rid of direct
numerical operations on Selectivity.

Fixes: cockroachdb#53860

Release note: None
@angelazxu angelazxu force-pushed the selectivity_fraction branch from 8039e77 to 1b88044 Compare February 8, 2021 22:02
Copy link
Contributor Author

@angelazxu angelazxu left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @mgartner)


pkg/sql/opt/props/selectivity_test.go, line 67 at r1 (raw file):

Previously, mgartner (Marcus Gartner) wrote…

Why use s(1) three times here instead of OneSelectivity?

fixed!

@angelazxu
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Feb 8, 2021

Build succeeded:

@craig craig bot merged commit 0e839ab into cockroachdb:master Feb 8, 2021
@angelazxu angelazxu deleted the selectivity_fraction branch February 9, 2021 00:05
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.

opt: create a special type for selectivity to clean up stats code
3 participants