Replace constants with static factory methods#11660
Replace constants with static factory methods#11660arhimondr merged 6 commits intoprestodb:masterfrom
Conversation
There was a problem hiding this comment.
i prefer to keep static factory methods above the instance fields (and below class constants)
There was a problem hiding this comment.
Everywhere else in the code the static factory methods are below the fields.
(Symbol, ExpressionInterpreter, TupleDomain, Domain, MetadataManager, ...)
Some clases define static factor methods after constructor, but i don't think it is right. As we try to define methods in the order of their appearance. So if method A uses method B, method A comes first and the method B comes second. Similar with static factory methods. Since factory methods use constructor, they should come before constructor.
There was a problem hiding this comment.
It would be nice to have a build check for that to not to go back and forth
|
@findepi I addressed all the comments, could you please accept this? So i can merge it and open the second refactoring PR? |
There was a problem hiding this comment.
There should be 2 separate situations. When rows count is 0, and if it is not, and distinctValuesCount is zero - that means that all the remaining values are null. Added a separate branch for outputRowCount == 0.0
There was a problem hiding this comment.
After i added a separate branch for outputRowCount == 0.0 i'm getting a lot of test failures. I'm not fixing them. Removing the branch.
There was a problem hiding this comment.
NaN if outputRowCount is 0
There was a problem hiding this comment.
If all values are null - row size is zero. If row count is zero - row size is NaN
There was a problem hiding this comment.
It looks like inlining zero is error prone, see number of places where you missed NaN
There was a problem hiding this comment.
It would be nice to have a build check for that to not to go back and forth
findepi
left a comment
There was a problem hiding this comment.
LGTM except for "Remove SymbolStatsEstimate#ZERO constant" commit.
We need to verify empirically this change does not inadvertently introduce planning changes.
presto-main/src/main/java/com/facebook/presto/sql/planner/planPrinter/PlanPrinter.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
After this change, there is no UNKNOWN_STATS constant, so you could as well return symbolStats
There was a problem hiding this comment.
Returning SymbolStatsEstimate.unknown() is more explicit. Think of it as of
if(variable == null){
return null;
}
There was a problem hiding this comment.
Is there any practical difference in doing this? SymbolStatsEstimate.unknown() is a constant, and always be a constant. Why do we need to generate additional bootstrap methods for invokedynamic to pass it as a lambda?
There was a problem hiding this comment.
Introduce local variables for these.
|
I was badly trying to remove the Also i realized that we threat I'm pretty sure that we would have to reopen that box at some point, but for now let's keep it closed. This PR is supposed to be simple refactor, and not something bigger. I replaced the commit that removes |
Usually if output rows in unknown there is no reason to consider symbol stats
246a54c to
29cc280
Compare
Move static factory methods after class fields and before the constructor
29cc280 to
3ab6145
Compare
I ran the tests from the #11665, the plans are the same. |
kokosing
left a comment
There was a problem hiding this comment.
But please wait for others.
findepi
left a comment
There was a problem hiding this comment.
LGTM although I would prefer that we don't do this refactors at all.
In the absence of precise rules, this can be viewed as "some style" vs "some other style". In particular, my preference was with the code before.
|
I think i already tried to explain why am i doing this, but apparently that comment got lost. My goal is to avoid making estimates out of the blue. We had a real problem with a greatly overestimated joins when column statistics were missing. That over estimated join led to completely wrong join order. First of all i was trying to fix that without doing any major refactoring. I didn't want to remove At that step i realized that having Once i removed |
|
@arhimondr thanks for taking time to explain this to me (once again). Really appreciated. |
Haha =) We found each other =) |
No description provided.