rubenada commented on a change in pull request #1814: [CALCITE-3804] Use
RelCollation interface in RelCollationImpl compareTo and satisfies methods
URL: https://github.com/apache/calcite/pull/1814#discussion_r380761223
##########
File path: core/src/main/java/org/apache/calcite/rel/RelCollationImpl.java
##########
@@ -97,9 +96,11 @@ public boolean isTop() {
}
public int compareTo(@Nonnull RelMultipleTrait o) {
- final RelCollationImpl that = (RelCollationImpl) o;
- final UnmodifiableIterator<RelFieldCollation> iterator =
- that.fieldCollations.iterator();
+ if (this == o) {
+ return 0;
+ }
+ final RelCollation that = (RelCollation) o;
Review comment:
@zabetak, thanks for your comment.
There is no particular need for this change, I was just looking at this code
and though that it might be "more correct" to work at interface level in these
methods.
I agree that comparison between classes can be risky, although we already do
something like this in `RelDistributionImpl#compareTo`. But I have no problem
to remove this change, your example makes clear that it can lead to risky
consequences.
I docthink that the change in `satisfies` is harmless. We could move it as
default implementation of the `RelCollation` interface, but then I believe it
would be inconsistent with other methods in implemented in `RelCollationImpl`
that could be moved as default is `RelCollation` too. IMHO `RelCollationImpl`
is like our de-facto default implementation of `RelCollation`, so we should put
the methods implementations in there.
This is a minor, cosmetic modification, so no big deal if we decide to
discard some / all changes.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services