From d9e9ce9b1e9fe74e941c914ca0b62f6381a88b83 Mon Sep 17 00:00:00 2001 From: Kazuaki Ishizaki Date: Tue, 3 Nov 2020 02:08:54 +0000 Subject: [PATCH] address review comments --- .../java/org/apache/arrow/vector/util/DecimalUtility.java | 2 +- .../arrow/vector/complex/impl/TestComplexCopier.java | 7 ++++--- .../arrow/vector/complex/writer/TestComplexWriter.java | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/java/vector/src/main/java/org/apache/arrow/vector/util/DecimalUtility.java b/java/vector/src/main/java/org/apache/arrow/vector/util/DecimalUtility.java index f524e1f77aba0..f778bcb209fa9 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/util/DecimalUtility.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/util/DecimalUtility.java @@ -135,7 +135,7 @@ public static void writeBigDecimalToArrowBuf(BigDecimal value, ArrowBuf bytebuf, */ public static void writeLongToArrowBuf(long value, ArrowBuf bytebuf, int index, int byteWidth) { if (byteWidth != 16 && byteWidth != 32) { - throw new UnsupportedOperationException("DeciimalUtility.writeLongToArrowBuf() currently supports " + + throw new UnsupportedOperationException("DecimalUtility.writeLongToArrowBuf() currently supports " + "128-bit or 256-bit width data"); } final long addressOfValue = bytebuf.memoryAddress() + (long) index * byteWidth; diff --git a/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestComplexCopier.java b/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestComplexCopier.java index fa445c70a2bc1..0c560abe23deb 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestComplexCopier.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestComplexCopier.java @@ -24,6 +24,7 @@ import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.RootAllocator; +import org.apache.arrow.vector.DecimalVector; import org.apache.arrow.vector.compare.VectorEqualsVisitor; import org.apache.arrow.vector.complex.FixedSizeListVector; import org.apache.arrow.vector.complex.ListVector; @@ -526,7 +527,7 @@ public void testCopyFixedSizedListOfDecimalsVector() { to.addOrGetVector(FieldType.nullable(new ArrowType.Decimal(3, 0, 128))); DecimalHolder holder = new DecimalHolder(); - holder.buffer = allocator.buffer(16); + holder.buffer = allocator.buffer(DecimalVector.TYPE_WIDTH); ArrowType arrowType = new ArrowType.Decimal(3, 0, 128); // populate from vector @@ -535,13 +536,13 @@ public void testCopyFixedSizedListOfDecimalsVector() { writer.startList(); writer.decimal().writeDecimal(BigDecimal.valueOf(i)); - DecimalUtility.writeBigDecimalToArrowBuf(new BigDecimal(i * 2), holder.buffer, 0, /*byteWidth=*/16); + DecimalUtility.writeBigDecimalToArrowBuf(new BigDecimal(i * 2), holder.buffer, 0, DecimalVector.TYPE_WIDTH); holder.start = 0; holder.scale = 0; holder.precision = 3; writer.decimal().write(holder); - DecimalUtility.writeBigDecimalToArrowBuf(new BigDecimal(i * 3), holder.buffer, 0, /*byteWidth=*/16); + DecimalUtility.writeBigDecimalToArrowBuf(new BigDecimal(i * 3), holder.buffer, 0, DecimalVector.TYPE_WIDTH); writer.decimal().writeDecimal(0, holder.buffer, arrowType); writer.decimal().writeBigEndianBytesToDecimal(BigDecimal.valueOf(i * 4).unscaledValue().toByteArray(), diff --git a/java/vector/src/test/java/org/apache/arrow/vector/complex/writer/TestComplexWriter.java b/java/vector/src/test/java/org/apache/arrow/vector/complex/writer/TestComplexWriter.java index c92e396e06a21..c378f6d53f012 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/complex/writer/TestComplexWriter.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/complex/writer/TestComplexWriter.java @@ -30,6 +30,7 @@ import org.apache.arrow.memory.RootAllocator; import org.apache.arrow.util.AutoCloseables; import org.apache.arrow.vector.BigIntVector; +import org.apache.arrow.vector.DecimalVector; import org.apache.arrow.vector.Float4Vector; import org.apache.arrow.vector.Float8Vector; import org.apache.arrow.vector.IntVector; @@ -310,7 +311,7 @@ public void listDecimalType() { listVector.allocateNew(); UnionListWriter listWriter = new UnionListWriter(listVector); DecimalHolder holder = new DecimalHolder(); - holder.buffer = allocator.buffer(16); + holder.buffer = allocator.buffer(DecimalVector.TYPE_WIDTH); ArrowType arrowType = new ArrowType.Decimal(10, 0, 128); for (int i = 0; i < COUNT; i++) { listWriter.startList(); @@ -318,13 +319,13 @@ public void listDecimalType() { if (j % 4 == 0) { listWriter.writeDecimal(new BigDecimal(j)); } else if (j % 4 == 1) { - DecimalUtility.writeBigDecimalToArrowBuf(new BigDecimal(j), holder.buffer, 0, 16); + DecimalUtility.writeBigDecimalToArrowBuf(new BigDecimal(j), holder.buffer, 0, DecimalVector.TYPE_WIDTH); holder.start = 0; holder.scale = 0; holder.precision = 10; listWriter.write(holder); } else if (j % 4 == 2) { - DecimalUtility.writeBigDecimalToArrowBuf(new BigDecimal(j), holder.buffer, 0, 16); + DecimalUtility.writeBigDecimalToArrowBuf(new BigDecimal(j), holder.buffer, 0, DecimalVector.TYPE_WIDTH); listWriter.writeDecimal(0, holder.buffer, arrowType); } else { byte[] value = BigDecimal.valueOf(j).unscaledValue().toByteArray();