ARROW-6266: [Java] Resolve the ambiguous method overload in RangeEqualsVisitor#5100
Closed
liyafan82 wants to merge 2 commits intoapache:masterfrom
Closed
ARROW-6266: [Java] Resolve the ambiguous method overload in RangeEqualsVisitor#5100liyafan82 wants to merge 2 commits intoapache:masterfrom
liyafan82 wants to merge 2 commits intoapache:masterfrom
Conversation
Contributor
Author
|
cc @tianchen92 |
tianchen92
approved these changes
Aug 16, 2019
Contributor
tianchen92
left a comment
There was a problem hiding this comment.
Thanks @liyafan82 , LGTM.
pravindra
reviewed
Aug 16, 2019
| @Override | ||
| public boolean accept(RangeEqualsVisitor visitor) { | ||
| return visitor.visit(getUnderlyingVector()); | ||
| return visitor.visitGeneral(getUnderlyingVector()); |
Contributor
There was a problem hiding this comment.
can we instead do -
return getUnderlyingVector().accept(visitor)
Contributor
There was a problem hiding this comment.
I think this is also ok, and then should remove RangeEqualsVisitor#visit(ValueVector left, Void value).
Contributor
There was a problem hiding this comment.
Sorry for correction, if we don't have visitGeneral I think the API below will throw exception
public boolean equals(ValueVector left) {
return this.visit(left, null);
}
Contributor
Author
There was a problem hiding this comment.
The method suggested by @pravindra works. With the suggested change, method visit(ValueVector left) can be removed altogether.
pravindra
approved these changes
Aug 16, 2019
pribor
pushed a commit
to GlobalWebIndex/arrow
that referenced
this pull request
Oct 24, 2025
…lsVisitor In RangeEqualsVisitor, there are overload methods for both super class and sub class. This will lead to unexpected behavior. For example, if we call RangeEqualsVisitor#visit(v), where v is a fixed width vector, the method actually called may be visit(ValueVector), which is unexpected. In general, in the visitor pattern, it is not a good idea to support method overload for both super class and sub-class as parameters. Closes apache#5100 from liyafan82/fly_0816_visit and squashes the following commits: 6b5e5c5 <liyafan82> Remove the general visit mothod f7ed538 <liyafan82> Resolve the ambiguous method overload in RangeEqualsVisitor Authored-by: liyafan82 <fan_li_ya@foxmail.com> Signed-off-by: Pindikura Ravindra <ravindra@dremio.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In RangeEqualsVisitor, there are overload methods for both super class and sub class. This will lead to unexpected behavior.
For example, if we call RangeEqualsVisitor#visit(v), where v is a fixed width vector, the method actually called may be visit(ValueVector), which is unexpected.
In general, in the visitor pattern, it is not a good idea to support method overload for both super class and sub-class as parameters.