liyafan82 commented on a change in pull request #8475:
URL: https://github.com/apache/arrow/pull/8475#discussion_r508273170
##########
File path:
java/vector/src/main/java/org/apache/arrow/vector/util/DecimalUtility.java
##########
@@ -119,34 +121,47 @@ public static boolean checkPrecisionAndScale(int
decimalPrecision, int decimalSc
* UnsupportedOperationException if the decimal size is greater than the
Decimal vector byte
* width.
*/
- public static void writeBigDecimalToArrowBuf(BigDecimal value, ArrowBuf
bytebuf, int index) {
+ public static void writeBigDecimalToArrowBuf(BigDecimal value, ArrowBuf
bytebuf, int index, int byteWidth) {
final byte[] bytes = value.unscaledValue().toByteArray();
- writeByteArrayToArrowBufHelper(bytes, bytebuf, index);
+ writeByteArrayToArrowBufHelper(bytes, bytebuf, index, byteWidth);
}
/**
* Write the given long to the ArrowBuf at the given value index.
*/
public static void writeLongToArrowBuf(long value, ArrowBuf bytebuf, int
index) {
- final long addressOfValue = bytebuf.memoryAddress() + (long) index *
DECIMAL_BYTE_LENGTH;
+ final long addressOfValue = bytebuf.memoryAddress() + (long) index * 16;
PlatformDependent.putLong(addressOfValue, value);
final long padValue = Long.signum(value) == -1 ? -1L : 0L;
PlatformDependent.putLong(addressOfValue + Long.BYTES, padValue);
}
+ /**
+ * Write value to the buffer extending it to 32 bytes at the given index.
+ */
+ public static void writeLongToArrowBufBigDecimal(long value, ArrowBuf
bytebuf, int index) {
+ final long addressOfValue = bytebuf.memoryAddress() + (long) index * 32;
+ PlatformDependent.putLong(addressOfValue, value);
+ final long padValue = Long.signum(value) == -1 ? -1L : 0L;
+ PlatformDependent.putLong(addressOfValue + Long.BYTES, padValue);
+ PlatformDependent.putLong(addressOfValue + 2 * Long.BYTES, padValue);
+ PlatformDependent.putLong(addressOfValue + 3 * Long.BYTES, padValue);
Review comment:
We should write 4 longs in total, so the last putLong is not needed?
----------------------------------------------------------------
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]