-
Couldn't load subscription status.
- Fork 3.9k
ARROW-6266: [Java] Resolve the ambiguous method overload in RangeEqualsVisitor #5100
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
Conversation
|
cc @tianchen92 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @liyafan82 , LGTM.
| @Override | ||
| public boolean accept(RangeEqualsVisitor visitor) { | ||
| return visitor.visit(getUnderlyingVector()); | ||
| return visitor.visitGeneral(getUnderlyingVector()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we instead do -
return getUnderlyingVector().accept(visitor)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is also ok, and then should remove RangeEqualsVisitor#visit(ValueVector left, Void value).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method suggested by @pravindra works. With the suggested change, method visit(ValueVector left) can be removed altogether.
…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>
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.