liyafan82 commented on a change in pull request #8475:
URL: https://github.com/apache/arrow/pull/8475#discussion_r506270123
##########
File path:
java/vector/src/main/java/org/apache/arrow/vector/util/DecimalUtility.java
##########
@@ -32,24 +32,26 @@
private DecimalUtility() {}
public static final int DECIMAL_BYTE_LENGTH = 16;
- public static final byte [] zeroes = new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0};
- public static final byte [] minus_one = new byte[] {-1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
+ public static final byte [] zeroes = new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0};
+ public static final byte [] minus_one = new byte[] {-1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
/**
* Read an ArrowType.Decimal at the given value index in the ArrowBuf and
convert to a BigDecimal
* with the given scale.
*/
- public static BigDecimal getBigDecimalFromArrowBuf(ArrowBuf bytebuf, int
index, int scale) {
- byte[] value = new byte[DECIMAL_BYTE_LENGTH];
+ public static BigDecimal getBigDecimalFromArrowBuf(ArrowBuf bytebuf, int
index, int scale, int byteWidth) {
+ byte[] value = new byte[byteWidth];
byte temp;
- final int startIndex = index * DECIMAL_BYTE_LENGTH;
+ final long startIndex = index * byteWidth;
Review comment:
Maybe we need a cast here
Otherwise, it first multiplies two (32-bit) integers, and the promote it to
a long.
If the result of the multiplication overflows, it just promotes the
overflown value to a long, which is useless.
----------------------------------------------------------------
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]