-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
ARROW-5918: [Java] Add get to BaseIntVector interface #4859
Changes from 6 commits
5739cc4
9f2fc09
9b8afa6
fe9c2ec
e65473c
26d30be
7ddce12
1562ae1
3732a78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,10 +98,11 @@ public static ValueVector decode(ValueVector indices, Dictionary dictionary) { | |
// copy the dictionary values into the decoded vector | ||
TransferPair transfer = dictionaryVector.getTransferPair(indices.getAllocator()); | ||
transfer.getTo().allocateNewSafe(); | ||
|
||
BaseIntVector baseIntVector = (BaseIntVector) indices; | ||
for (int i = 0; i < count; i++) { | ||
Object index = indices.getObject(i); | ||
if (index != null) { | ||
int indexAsInt = ((Number) index).intValue(); | ||
if (!baseIntVector.isNull(i)) { | ||
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. encoded value can never be null? 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. 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. I see. The benefit of not encoding null is efficient storage. However, the benefit of encoding null is efficient computation (no if branch in the encoding/decoding logic, which makes the CPU pipeline/prefetch more efficient). We may need some investigation on this. For this particular case, it may be OK to stick to the original assumption. |
||
int indexAsInt = (int) baseIntVector.getValueAsLong(i); | ||
if (indexAsInt > dictionaryCount) { | ||
throw new IllegalArgumentException("Provided dictionary does not contain value for index " + indexAsInt); | ||
} | ||
|
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.
Do we also need a setSafe method here?
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, this method is implemented with setSafe in sub classes :)
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. Thanks. I am not sure if we should use separate APIs for set and setSafe methods.
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.
Lets update the javadoc to indicate this is the safe version. Unfortuantely, I think this made it into the 0.14.0, so we should try not to rename it. We can always add an unsafe version later.
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.
Sure, thanks, will also add a method like "setUnsafeWithPossibleTruncate"
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 for your efforts, PR updated.