-
Notifications
You must be signed in to change notification settings - Fork 3.7k
GH-40933: [Java] Enhance the copyFrom* functionality in StringView #41752
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
@lidavidm should we also include test cases for |
We should test both types yes |
@lidavidm this PR is ready for review. |
@ParameterizedTest | ||
@MethodSource("vectorProvider") | ||
public void testCopyFromSafeWithNulls(Class<? extends BaseVariableWidthViewVector> vectorClass) | ||
throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { | ||
try (final BaseVariableWidthViewVector vector = vectorClass.getConstructor(String.class, BufferAllocator.class) | ||
.newInstance(EMPTY_SCHEMA_PATH, allocator); | ||
final BaseVariableWidthViewVector vector2 = vectorClass.getConstructor(String.class, BufferAllocator.class) | ||
.newInstance(EMPTY_SCHEMA_PATH, allocator)) { |
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 avoid reflection and just parameterize with the instance instead of the class?
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 definitely. It looks cool, but unreadable at the same time ;)
java/vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthViewVector.java
Outdated
Show resolved
Hide resolved
@@ -568,7 +568,7 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { | |||
return new VarBinaryWriterImpl((VarBinaryVector) vector); | |||
} | |||
}, | |||
VIEWVARBINARY(Binary.INSTANCE) { |
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.
typo fixed here.
@@ -1451,6 +1455,200 @@ public void testSafeOverwriteLongFromALongerLongString() { | |||
} | |||
} | |||
|
|||
static Stream<Arguments> vectorTypeAndClassProvider() { |
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.
@lidavidm If we take instances, then we have a bit of a hard time deallocating memory. Rather I used the types, is this okay?
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.
Just use factory functions?
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 updated. Is it as expected?
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.
No, you want something like Function<BufferAllocator, BaseVariableWidthViewVector>
.
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 updated. Does it look okay?
|
||
@ParameterizedTest | ||
@MethodSource({"vectorTypeAndClassProvider"}) | ||
@MethodSource({"vectorTypeProvider"}) |
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.
No, so: why not just directly have the Function be the parameter? Instead of bouncing through the type? We never use type
in the actual tests.
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.
Ah right. I updated.
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.
Resolving conflicts...
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.
Done!
…iew (apache#41752) ### Rationale for this change Initial implementation of StringView doesn't contain `copy` functionality. This PR adds that feature. ### What changes are included in this PR? This PR adds `copyFrom` and `copyFromSafe` functions to `BaseVariableWidthViewVector`. ### Are these changes tested? Yes ### Are there any user-facing changes? No * GitHub Issue: apache#40933 Lead-authored-by: Vibhatha Abeykoon <vibhatha@gmail.com> Co-authored-by: Vibhatha Lakmal Abeykoon <vibhatha@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
After merging your PR, Conbench analyzed the 6 benchmarking runs that have been run so far on merge-commit 54dfb82. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 11 possible false positives for unstable benchmarks that are known to sometimes produce them. |
Rationale for this change
Initial implementation of StringView doesn't contain
copy
functionality. This PR adds that feature.What changes are included in this PR?
This PR adds
copyFrom
andcopyFromSafe
functions toBaseVariableWidthViewVector
.Are these changes tested?
Yes
Are there any user-facing changes?
No
copyFrom*
functionality in StringView #40933