aokolnychyi commented on a change in pull request #135: Use big-endian byte
order for UUIDs in Conversions
URL: https://github.com/apache/incubator-iceberg/pull/135#discussion_r269941987
##########
File path: api/src/main/java/org/apache/iceberg/types/Conversions.java
##########
@@ -117,7 +117,12 @@ public static ByteBuffer toByteBuffer(Type type, Object
value) {
}
private static Object internalFromByteBuffer(Type type, ByteBuffer buffer) {
- ByteBuffer tmp = buffer.duplicate().order(ByteOrder.LITTLE_ENDIAN);
+ ByteBuffer tmp = buffer.duplicate();
+ if (type == Types.UUIDType.get() || type instanceof Types.DecimalType) {
Review comment:
I set the byte order for decimals explicitly to avoid any confusion.
However, it is not mandatory because of the way we read bytes later.
```
case DECIMAL:
Types.DecimalType decimal = (Types.DecimalType) type;
byte[] unscaledBytes = new byte[buffer.remaining()];
tmp.get(unscaledBytes);
return new BigDecimal(new BigInteger(unscaledBytes), decimal.scale());
```
The byte order doesn't matter in the code snippet above.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]