Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.3k
ARROW-6022: [Java] Support equals API in ValueVector to compare two vectors equal#4933
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
6bc3f6810dca2ce58c15800268823c9f0661d95c9cb942794c7081c20dfa943694d9f6226a20fa5d22fd7e20f79File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -21,6 +21,7 @@ | ||
| import org.apache.arrow.memory.BufferAllocator; | ||
| import org.apache.arrow.memory.OutOfMemoryException; | ||
| import org.apache.arrow.vector.compare.RangeEqualsVisitor; | ||
| import org.apache.arrow.vector.complex.reader.FieldReader; | ||
| import org.apache.arrow.vector.types.Types.MinorType; | ||
| import org.apache.arrow.vector.types.pojo.Field; | ||
| @@ -272,4 +273,11 @@ public interface ValueVector extends Closeable, Iterable<ValueVector> { | ||
| * @param from source vector | ||
| */ | ||
| void copyFromSafe(int fromIndex, int thisIndex, ValueVector from); | ||
| /** | ||
| * Compare range values in this vector and vector in visitor. | ||
| * @param visitor visitor which holds the vector to compare. | ||
| * @return true if equals, otherwise false. | ||
| */ | ||
| boolean accept(RangeEqualsVisitor visitor); | ||
pravindra marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -25,6 +25,7 @@ | ||
| import org.apache.arrow.memory.BufferAllocator; | ||
| import org.apache.arrow.memory.OutOfMemoryException; | ||
| import org.apache.arrow.vector.compare.RangeEqualsVisitor; | ||
| import org.apache.arrow.vector.complex.impl.NullReader; | ||
| import org.apache.arrow.vector.complex.reader.FieldReader; | ||
| import org.apache.arrow.vector.ipc.message.ArrowFieldNode; | ||
| @@ -264,4 +265,9 @@ public void copyFrom(int fromIndex, int thisIndex, ValueVector from) { | ||
| public void copyFromSafe(int fromIndex, int thisIndex, ValueVector from) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
| @Override | ||
| public boolean accept(RangeEqualsVisitor visitor) { | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a unit test to check if ZeroVector == ZeroVector? ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, done. | ||
| return true; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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'm not sure why we have
equalsthat checks a range of values and accpet aRangeEqualsVisitor? That seems redundantThere 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.
Equals(int index, ValueVector vector, int toIndex) compares single value and RangeEqualsVisitor compares a range of values.
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 must have missed the discussion when
equalswas added to compare a single value. It doesn't seem like that would be very useful to me, was there a specific use case to support this?Uh oh!
There was an error while loading. Please reload this page.
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.
Yes, we did a refactor for dictionary encoding few weeks ago, hashCode/equals API are used for DictionaryHashTable (https://github.com/apache/arrow/blob/master/java/vector/src/main/java/org/apache/arrow/vector/dictionary/DictionaryHashTable.java#L138) to avoid memory copy introduced by previous implementation.
PR is here #4846.
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.
agree with @BryanCutler - this causes duplication of code/tests. Is there a reason to not use the RangeEquals API (with range = 1) instead ?
I'm fine if you want to do this in a different PR.
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.
@pravindra Ah, I have already made it reuse RangeEquals API(range ==1).
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, I meant can we remove the equals() API from ValueVector, and it's callers be modified to instead use the RangeEquals() API ? I think keeping the minimal interface in ValueVector is ideal.
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 see, right, could be done in a different PR.