-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: Add int/bigint/double conversion functions from bytes #8426
Conversation
@jzaralim Instead of the proposed |
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 want to add docs to Scalar functions?
@UdfParameter(description = "The byte order of the number bytes representation") | ||
final String byteOrder | ||
) { | ||
if (byteOrder.equalsIgnoreCase(ByteOrder.BIG_ENDIAN.toString())) { |
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.
We should do a null check for byteOrder
(other two functions as well)
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
public Integer intFromBytes( | ||
@UdfParameter(description = "The bytes value to convert.") | ||
final ByteBuffer value, | ||
@UdfParameter(description = "The byte order of the number bytes representation") |
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 add the names of the byte orders in the description (LITTLE_ENDIAN and BIG_ENDIAN)? (also applies to the other two 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.
Done
f116957
to
6a2dd34
Compare
@JimGalasyn I updated the doc |
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.
LGTM with a few copy edits.
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.
LGTM with a nit
@@ -65,6 +67,18 @@ private BytesUtils() { | |||
Encoding.BASE64, v -> base64Decoding(v) | |||
); | |||
|
|||
public static ByteOrder byteOrderType(final String byteOrderStr) { | |||
if (byteOrderStr.equalsIgnoreCase(ByteOrder.BIG_ENDIAN.toString())) { |
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.
If byteOrderStr
is null then byteOrderStr.equalsIgnoreCase
will throw an NPE
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
1ce8ec9
to
56e14ce
Compare
56e14ce
to
99277e6
Compare
Description
Add
INT_FROM_BYTES
,BIGINT_FROM_BYTES
, andDOUBLE_FROM_BYTES
functions.All functions use the byte order
BIG_ENDIAN
as default. A 2nd parameter is accepted to specify the byte order:Testing done
Describe the testing strategy. Unit and integration tests are expected for any behavior changes.
Reviewer checklist