[ https://issues.apache.org/jira/browse/ARROW-6472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16924198#comment-16924198 ]
Liya Fan commented on ARROW-6472: --------------------------------- My suggestions: 1. We need to use both left and right vectors in the constructors. The reason is for performance: this is a short-cut and avoids repeated type check. 2. For each visit invocation, we first check if the parameter is the same as the left vector (which is usually true). If it is true, we go ahead to call the compare methods. If it is false, we 1) override the left vector; 2) do the type check; 3) call the compare methods. public void visit(Vector left, Range range) { if (left != this.left) { this.left = left; typeCheck(); } compareXXX(); } This method keeps the good performance, while avoiding the problem indicated by [~Pindikura Ravindra]. What do you think? > [Java] ValueVector#accept may has potential cast exception > ---------------------------------------------------------- > > Key: ARROW-6472 > URL: https://issues.apache.org/jira/browse/ARROW-6472 > Project: Apache Arrow > Issue Type: Bug > Components: Java > Reporter: Ji Liu > Assignee: Ji Liu > Priority: Major > > Per discussion > [https://github.com/apache/arrow/pull/5195#issuecomment-528425302] > We may use API this way: > {code:java} > RangeEqualsVisitor visitor = new RangeEqualsVisitor(vector1, vector2); > vector3.accept(visitor, range){code} > if vector1/vector2 are say, {{StructVector}}s and vector3 is an {{IntVector}} > - things can go bad. we'll use the {{compareBaseFixedWidthVectors()}} and do > wrong type-casts for vector1/vector2. -- This message was sent by Atlassian Jira (v8.3.2#803003)