From 49085ad3b9030f0c298f4b1fcc9231bebdf718ec Mon Sep 17 00:00:00 2001 From: Bryan Cutler Date: Tue, 4 Sep 2018 16:21:52 -0700 Subject: [PATCH 01/10] enabled line length checks --- java/dev/checkstyle/suppressions.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/dev/checkstyle/suppressions.xml b/java/dev/checkstyle/suppressions.xml index c3a7ffdcb30..092037bfde3 100644 --- a/java/dev/checkstyle/suppressions.xml +++ b/java/dev/checkstyle/suppressions.xml @@ -33,5 +33,7 @@ - + From 4f137dc63b19f7a8bb06d71635058656aede47f8 Mon Sep 17 00:00:00 2001 From: Bryan Cutler Date: Wed, 5 Sep 2018 14:17:21 -0700 Subject: [PATCH 02/10] increase line length to 120 --- java/dev/checkstyle/checkstyle.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/dev/checkstyle/checkstyle.xml b/java/dev/checkstyle/checkstyle.xml index 62132e50d81..1efd4d39de6 100644 --- a/java/dev/checkstyle/checkstyle.xml +++ b/java/dev/checkstyle/checkstyle.xml @@ -84,7 +84,7 @@ - + From 9fab0192422390bc2a4653cc32888137499a89a8 Mon Sep 17 00:00:00 2001 From: Bryan Cutler Date: Wed, 5 Sep 2018 14:22:56 -0700 Subject: [PATCH 03/10] fixed line length for arrow-memory --- .../arrow/memory/AllocationListener.java | 6 +- .../apache/arrow/memory/BaseAllocator.java | 25 ++++---- .../apache/arrow/memory/BufferAllocator.java | 6 +- .../arrow/memory/TestBaseAllocator.java | 63 ++++++++++++------- 4 files changed, 60 insertions(+), 40 deletions(-) diff --git a/java/memory/src/main/java/org/apache/arrow/memory/AllocationListener.java b/java/memory/src/main/java/org/apache/arrow/memory/AllocationListener.java index 67a7b9c63c9..f7f89e0a21a 100644 --- a/java/memory/src/main/java/org/apache/arrow/memory/AllocationListener.java +++ b/java/memory/src/main/java/org/apache/arrow/memory/AllocationListener.java @@ -45,9 +45,9 @@ public boolean onFailedAllocation(long size, AllocationOutcome outcome) { void onAllocation(long size); /** - * Called whenever an allocation failed, giving the caller a chance to create some space in the allocator - * (either by freeing some resource, or by changing the limit), and, if successful, allowing the allocator - * to retry the allocation. + * Called whenever an allocation failed, giving the caller a chance to create some space in the + * allocator (either by freeing some resource, or by changing the limit), and, if successful, + * allowing the allocator to retry the allocation. * * @param size the buffer size that was being allocated * @param outcome the outcome of the failed allocation. Carries information of what failed diff --git a/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java b/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java index ba2a275aee0..de185cd5a13 100644 --- a/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java +++ b/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java @@ -59,11 +59,12 @@ public abstract class BaseAllocator extends Accountant implements BufferAllocato /** * Initialize an allocator * @param parentAllocator parent allocator. null if defining a root allocator - * @param listener listener callback. Must be non-null -- use {@link AllocationListener#NOOP} if no listener - * desired + * @param listener listener callback. Must be non-null -- use + * {@link AllocationListener#NOOP} if no listener desired * @param name name of this allocator * @param initReservation initial reservation. Cannot be modified after construction - * @param maxAllocation limit. Allocations past the limit fail. Can be modified after construction + * @param maxAllocation limit. Allocations past the limit fail. Can be modified after + * construction */ protected BaseAllocator( final BaseAllocator parentAllocator, @@ -110,13 +111,12 @@ private static String createErrorMsg(final BufferAllocator allocator, final int int requested) { if (rounded != requested) { return String.format( - "Unable to allocate buffer of size %d (rounded from %d) due to memory limit. Current " + - "allocation: %d", - rounded, requested, allocator.getAllocatedMemory()); + "Unable to allocate buffer of size %d (rounded from %d) due to memory limit. Current " + + "allocation: %d", rounded, requested, allocator.getAllocatedMemory()); } else { - return String.format("Unable to allocate buffer of size %d due to memory limit. Current " + - "allocation: %d", - rounded, allocator.getAllocatedMemory()); + return String.format( + "Unable to allocate buffer of size %d due to memory limit. Current " + + "allocation: %d", rounded, allocator.getAllocatedMemory()); } } @@ -286,9 +286,10 @@ public ArrowBuf buffer(final int initialRequestSize, BufferManager manager) { return buffer; } catch (OutOfMemoryError e) { /* - * OutOfDirectMemoryError is thrown by Netty when we exceed the direct memory limit defined by -XX:MaxDirectMemorySize. - * OutOfMemoryError with "Direct buffer memory" message is thrown by java.nio.Bits when we exceed the direct memory limit. - * This should never be hit in practice as Netty is expected to throw an OutOfDirectMemoryError first. + * OutOfDirectMemoryError is thrown by Netty when we exceed the direct memory limit defined by + * -XX:MaxDirectMemorySize. OutOfMemoryError with "Direct buffer memory" message is thrown by + * java.nio.Bits when we exceed the direct memory limit. This should never be hit in practice + * as Netty is expected to throw an OutOfDirectMemoryError first. */ if (e instanceof OutOfDirectMemoryError || "Direct buffer memory".equals(e.getMessage())) { throw new OutOfMemoryException(e); diff --git a/java/memory/src/main/java/org/apache/arrow/memory/BufferAllocator.java b/java/memory/src/main/java/org/apache/arrow/memory/BufferAllocator.java index 94ea62e6aad..67eb94ca562 100644 --- a/java/memory/src/main/java/org/apache/arrow/memory/BufferAllocator.java +++ b/java/memory/src/main/java/org/apache/arrow/memory/BufferAllocator.java @@ -77,7 +77,11 @@ public interface BufferAllocator extends AutoCloseable { * @param maxAllocation maximum amount of space the new allocator can allocate * @return the new allocator, or null if it can't be created */ - public BufferAllocator newChildAllocator(String name, AllocationListener listener, long initReservation, long maxAllocation); + public BufferAllocator newChildAllocator( + String name, + AllocationListener listener, + long initReservation, + long maxAllocation); /** * Close and release all buffers generated from this buffer pool. diff --git a/java/memory/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java b/java/memory/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java index b826d168a64..6286faae1b6 100644 --- a/java/memory/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java +++ b/java/memory/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java @@ -31,7 +31,6 @@ import io.netty.buffer.ArrowBuf.TransferResult; public class TestBaseAllocator { - // private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestBaseAllocator.class); private final static int MAX_ALLOCATION = 8 * 1024; @@ -149,8 +148,10 @@ public void testAllocator_transferOwnership() throws Exception { @Test public void testAllocator_shareOwnership() throws Exception { try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { - final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("shareOwnership1", 0, MAX_ALLOCATION); - final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("shareOwnership2", 0, MAX_ALLOCATION); + final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("shareOwnership1", 0, + MAX_ALLOCATION); + final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("shareOwnership2", 0, + MAX_ALLOCATION); final ArrowBuf arrowBuf1 = childAllocator1.buffer(MAX_ALLOCATION / 4); rootAllocator.verify(); @@ -161,13 +162,15 @@ public void testAllocator_shareOwnership() throws Exception { assertNotEquals(arrowBuf2, arrowBuf1); assertEquiv(arrowBuf1, arrowBuf2); - // release original buffer (thus transferring ownership to allocator 2. (should leave allocator 1 in empty state) + // release original buffer (thus transferring ownership to allocator 2. (should leave + // allocator 1 in empty state) arrowBuf1.release(); rootAllocator.verify(); childAllocator1.close(); rootAllocator.verify(); - final BufferAllocator childAllocator3 = rootAllocator.newChildAllocator("shareOwnership3", 0, MAX_ALLOCATION); + final BufferAllocator childAllocator3 = rootAllocator.newChildAllocator("shareOwnership3", 0, + MAX_ALLOCATION); final ArrowBuf arrowBuf3 = arrowBuf1.retain(childAllocator3); assertNotNull(arrowBuf3); assertNotEquals(arrowBuf3, arrowBuf1); @@ -189,8 +192,8 @@ public void testAllocator_shareOwnership() throws Exception { @Test public void testRootAllocator_createChildAndUse() throws Exception { try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { - try (final BufferAllocator childAllocator = rootAllocator.newChildAllocator("createChildAndUse", 0, - MAX_ALLOCATION)) { + try (final BufferAllocator childAllocator = rootAllocator.newChildAllocator( + "createChildAndUse", 0, MAX_ALLOCATION)) { final ArrowBuf arrowBuf = childAllocator.buffer(512); assertNotNull("allocation failed", arrowBuf); arrowBuf.release(); @@ -202,8 +205,8 @@ public void testRootAllocator_createChildAndUse() throws Exception { public void testRootAllocator_createChildDontClose() throws Exception { try { try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { - final BufferAllocator childAllocator = rootAllocator.newChildAllocator("createChildDontClose", 0, - MAX_ALLOCATION); + final BufferAllocator childAllocator = rootAllocator.newChildAllocator( + "createChildDontClose", 0, MAX_ALLOCATION); final ArrowBuf arrowBuf = childAllocator.buffer(512); assertNotNull("allocation failed", arrowBuf); } @@ -314,10 +317,12 @@ public void testRootAllocator_listenerAllocationFail() throws Exception { TestAllocationListener l1 = new TestAllocationListener(); assertEquals(0, l1.getNumCalls()); assertEquals(0, l1.getTotalMem()); - // Test attempts to allocate too much from a child whose limit is set to half of the max allocation - // The listener's callback triggers, expanding the child allocator's limit, so then the allocation succeeds + // Test attempts to allocate too much from a child whose limit is set to half of the max + // allocation. The listener's callback triggers, expanding the child allocator's limit, so then + // the allocation succeeds. try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { - try (final BufferAllocator c1 = rootAllocator.newChildAllocator("c1", l1,0, MAX_ALLOCATION / 2)) { + try (final BufferAllocator c1 = rootAllocator.newChildAllocator("c1", l1, 0, + MAX_ALLOCATION / 2)) { try { c1.buffer(MAX_ALLOCATION); fail("allocated memory beyond max allowed"); @@ -433,14 +438,16 @@ public void testAllocator_createSlices() throws Exception { try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { testAllocator_sliceUpBufferAndRelease(rootAllocator, rootAllocator); - try (final BufferAllocator childAllocator = rootAllocator.newChildAllocator("createSlices", 0, MAX_ALLOCATION)) { + try (final BufferAllocator childAllocator = rootAllocator.newChildAllocator("createSlices", 0, + MAX_ALLOCATION)) { testAllocator_sliceUpBufferAndRelease(rootAllocator, childAllocator); } rootAllocator.verify(); testAllocator_sliceUpBufferAndRelease(rootAllocator, rootAllocator); - try (final BufferAllocator childAllocator = rootAllocator.newChildAllocator("createSlices", 0, MAX_ALLOCATION)) { + try (final BufferAllocator childAllocator = rootAllocator.newChildAllocator("createSlices", 0, + MAX_ALLOCATION)) { try (final BufferAllocator childAllocator2 = childAllocator.newChildAllocator("createSlices", 0, MAX_ALLOCATION)) { final ArrowBuf arrowBuf1 = childAllocator2.buffer(MAX_ALLOCATION / 8); @@ -556,8 +563,10 @@ public void testAllocator_slicesOfSlices() throws Exception { @Test public void testAllocator_transferSliced() throws Exception { try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { - final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("transferSliced1", 0, MAX_ALLOCATION); - final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("transferSliced2", 0, MAX_ALLOCATION); + final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("transferSliced1", 0, + MAX_ALLOCATION); + final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("transferSliced2", 0, + MAX_ALLOCATION); final ArrowBuf arrowBuf1 = childAllocator1.buffer(MAX_ALLOCATION / 8); final ArrowBuf arrowBuf2 = childAllocator2.buffer(MAX_ALLOCATION / 8); @@ -588,8 +597,10 @@ public void testAllocator_transferSliced() throws Exception { @Test public void testAllocator_shareSliced() throws Exception { try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { - final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("transferSliced", 0, MAX_ALLOCATION); - final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("transferSliced", 0, MAX_ALLOCATION); + final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("transferSliced", 0, + MAX_ALLOCATION); + final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("transferSliced", 0, + MAX_ALLOCATION); final ArrowBuf arrowBuf1 = childAllocator1.buffer(MAX_ALLOCATION / 8); final ArrowBuf arrowBuf2 = childAllocator2.buffer(MAX_ALLOCATION / 8); @@ -620,9 +631,12 @@ public void testAllocator_shareSliced() throws Exception { @Test public void testAllocator_transferShared() throws Exception { try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { - final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("transferShared1", 0, MAX_ALLOCATION); - final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("transferShared2", 0, MAX_ALLOCATION); - final BufferAllocator childAllocator3 = rootAllocator.newChildAllocator("transferShared3", 0, MAX_ALLOCATION); + final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("transferShared1", 0, + MAX_ALLOCATION); + final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("transferShared2", 0, + MAX_ALLOCATION); + final BufferAllocator childAllocator3 = rootAllocator.newChildAllocator("transferShared3", 0, + MAX_ALLOCATION); final ArrowBuf arrowBuf1 = childAllocator1.buffer(MAX_ALLOCATION / 8); @@ -650,7 +664,8 @@ public void testAllocator_transferShared() throws Exception { childAllocator2.close(); rootAllocator.verify(); - final BufferAllocator childAllocator4 = rootAllocator.newChildAllocator("transferShared4", 0, MAX_ALLOCATION); + final BufferAllocator childAllocator4 = rootAllocator.newChildAllocator("transferShared4", 0, + MAX_ALLOCATION); TransferResult result2 = arrowBuf3.transferOwnership(childAllocator4); allocationFit = result.allocationFit; final ArrowBuf arrowBuf4 = result2.buffer; @@ -685,8 +700,8 @@ public void testAllocator_unclaimedReservation() throws Exception { public void testAllocator_claimedReservation() throws Exception { try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { - try (final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("claimedReservation", 0, - MAX_ALLOCATION)) { + try (final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator( + "claimedReservation", 0, MAX_ALLOCATION)) { try (final AllocationReservation reservation = childAllocator1.newReservation()) { assertTrue(reservation.add(32)); From 4d9ca04094727b44be0168e755bab1f0fb2f6c5f Mon Sep 17 00:00:00 2001 From: Bryan Cutler Date: Wed, 5 Sep 2018 15:11:39 -0700 Subject: [PATCH 04/10] fixed line length for arrow-vector --- .../apache/arrow/vector/AllocationHelper.java | 7 +- .../apache/arrow/vector/DecimalVector.java | 7 +- .../arrow/vector/TimeStampMicroTZVector.java | 6 +- .../arrow/vector/TimeStampMilliTZVector.java | 6 +- .../arrow/vector/TimeStampNanoTZVector.java | 10 +- .../arrow/vector/TimeStampSecTZVector.java | 7 +- .../org/apache/arrow/vector/TypeLayout.java | 3 +- .../org/apache/arrow/vector/VectorLoader.java | 12 +- .../complex/AbstractContainerVector.java | 3 +- .../vector/complex/AbstractStructVector.java | 6 +- .../vector/complex/RepeatedValueVector.java | 6 +- .../arrow/vector/complex/StateTool.java | 3 +- .../arrow/vector/complex/StructVector.java | 3 +- .../complex/impl/ComplexWriterImpl.java | 14 +- .../impl/NullableStructWriterFactory.java | 6 +- .../vector/complex/impl/PromotableWriter.java | 16 +- .../vector/dictionary/DictionaryEncoder.java | 3 +- .../apache/arrow/vector/ipc/ArrowWriter.java | 3 +- .../arrow/vector/ipc/JsonFileReader.java | 3 +- .../arrow/vector/ipc/JsonFileWriter.java | 18 +- .../vector/ipc/message/ArrowRecordBatch.java | 4 +- .../vector/ipc/message/MessageSerializer.java | 33 +-- .../vector/types/FloatingPointPrecision.java | 3 +- .../org/apache/arrow/vector/types/Types.java | 228 +++++++++++++++--- .../apache/arrow/vector/types/pojo/Field.java | 1 + .../vector/util/ByteFunctionHelpers.java | 32 ++- .../apache/arrow/vector/util/DateUtility.java | 3 +- .../arrow/vector/util/DecimalUtility.java | 4 +- .../arrow/vector/util/DictionaryUtility.java | 6 +- .../arrow/vector/util/MapWithOrdinal.java | 13 +- .../util/OversizedAllocationException.java | 9 +- .../util/SchemaChangeRuntimeException.java | 6 +- .../org/apache/arrow/vector/util/Text.java | 82 ++++--- .../apache/arrow/vector/util/Validator.java | 24 +- .../apache/arrow/vector/TestBitVector.java | 12 +- .../org/apache/arrow/vector/TestCopyFrom.java | 8 +- .../arrow/vector/TestDecimalVector.java | 15 +- .../arrow/vector/TestFixedSizeListVector.java | 12 +- .../apache/arrow/vector/TestListVector.java | 3 +- .../apache/arrow/vector/TestValueVector.java | 9 +- .../apache/arrow/vector/TestVectorReset.java | 15 +- .../arrow/vector/TestVectorUnloadLoad.java | 18 +- .../complex/impl/TestPromotableWriter.java | 6 +- .../complex/writer/TestComplexWriter.java | 3 +- .../apache/arrow/vector/ipc/BaseFileTest.java | 14 +- .../arrow/vector/ipc/TestArrowFile.java | 39 ++- .../arrow/vector/ipc/TestArrowFooter.java | 3 +- .../vector/ipc/TestArrowReaderWriter.java | 3 +- .../arrow/vector/ipc/TestArrowStream.java | 6 +- .../apache/arrow/vector/ipc/TestJSONFile.java | 3 +- .../apache/arrow/vector/pojo/TestConvert.java | 18 +- .../arrow/vector/types/pojo/TestSchema.java | 8 +- 52 files changed, 548 insertions(+), 237 deletions(-) diff --git a/java/vector/src/main/java/org/apache/arrow/vector/AllocationHelper.java b/java/vector/src/main/java/org/apache/arrow/vector/AllocationHelper.java index 2a0f39d0cb5..7b173be4468 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/AllocationHelper.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/AllocationHelper.java @@ -22,13 +22,16 @@ import org.apache.arrow.vector.complex.RepeatedVariableWidthVectorLike; public class AllocationHelper { -// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AllocationHelper.class); public static void allocate(ValueVector v, int valueCount, int bytesPerValue) { allocate(v, valueCount, bytesPerValue, 5); } - public static void allocatePrecomputedChildCount(ValueVector v, int valueCount, int bytesPerValue, int childValCount) { + public static void allocatePrecomputedChildCount( + ValueVector v, + int valueCount, + int bytesPerValue, + int childValCount) { if (v instanceof FixedWidthVector) { ((FixedWidthVector) v).allocateNew(valueCount); } else if (v instanceof VariableWidthVector) { diff --git a/java/vector/src/main/java/org/apache/arrow/vector/DecimalVector.java b/java/vector/src/main/java/org/apache/arrow/vector/DecimalVector.java index 1b3550b5db1..897c6e877fc 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/DecimalVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/DecimalVector.java @@ -26,6 +26,7 @@ import org.apache.arrow.vector.holders.DecimalHolder; import org.apache.arrow.vector.holders.NullableDecimalHolder; import org.apache.arrow.vector.types.Types.MinorType; +import org.apache.arrow.vector.types.pojo.ArrowType; import org.apache.arrow.vector.types.pojo.FieldType; import org.apache.arrow.vector.util.DecimalUtility; import org.apache.arrow.vector.util.TransferPair; @@ -52,8 +53,8 @@ public class DecimalVector extends BaseFixedWidthVector { */ public DecimalVector(String name, BufferAllocator allocator, int precision, int scale) { - this(name, FieldType.nullable(new org.apache.arrow.vector.types.pojo.ArrowType.Decimal(precision, scale)), - allocator); + this(name, FieldType.nullable( + new ArrowType.Decimal(precision, scale)), allocator); } /** @@ -65,7 +66,7 @@ public DecimalVector(String name, BufferAllocator allocator, */ public DecimalVector(String name, FieldType fieldType, BufferAllocator allocator) { super(name, allocator, fieldType, TYPE_WIDTH); - org.apache.arrow.vector.types.pojo.ArrowType.Decimal arrowType = (org.apache.arrow.vector.types.pojo.ArrowType.Decimal) fieldType.getType(); + ArrowType.Decimal arrowType = (ArrowType.Decimal) fieldType.getType(); reader = new DecimalReaderImpl(DecimalVector.this); this.precision = arrowType.getPrecision(); this.scale = arrowType.getScale(); diff --git a/java/vector/src/main/java/org/apache/arrow/vector/TimeStampMicroTZVector.java b/java/vector/src/main/java/org/apache/arrow/vector/TimeStampMicroTZVector.java index daeda403390..b3b0a32a293 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/TimeStampMicroTZVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/TimeStampMicroTZVector.java @@ -25,6 +25,7 @@ import org.apache.arrow.vector.holders.TimeStampMicroTZHolder; import org.apache.arrow.vector.types.TimeUnit; import org.apache.arrow.vector.types.Types.MinorType; +import org.apache.arrow.vector.types.pojo.ArrowType; import org.apache.arrow.vector.types.pojo.FieldType; import org.apache.arrow.vector.util.TransferPair; @@ -44,8 +45,7 @@ public class TimeStampMicroTZVector extends TimeStampVector { * @param allocator allocator for memory management. */ public TimeStampMicroTZVector(String name, BufferAllocator allocator, String timeZone) { - this(name, FieldType.nullable(new org.apache.arrow.vector.types.pojo.ArrowType.Timestamp(TimeUnit.MICROSECOND, timeZone)), - allocator); + this(name, FieldType.nullable(new ArrowType.Timestamp(TimeUnit.MICROSECOND, timeZone)), allocator); } /** @@ -57,7 +57,7 @@ public TimeStampMicroTZVector(String name, BufferAllocator allocator, String tim */ public TimeStampMicroTZVector(String name, FieldType fieldType, BufferAllocator allocator) { super(name, fieldType, allocator); - org.apache.arrow.vector.types.pojo.ArrowType.Timestamp arrowType = (org.apache.arrow.vector.types.pojo.ArrowType.Timestamp) fieldType.getType(); + ArrowType.Timestamp arrowType = (ArrowType.Timestamp) fieldType.getType(); timeZone = arrowType.getTimezone(); reader = new TimeStampMicroTZReaderImpl(TimeStampMicroTZVector.this); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/TimeStampMilliTZVector.java b/java/vector/src/main/java/org/apache/arrow/vector/TimeStampMilliTZVector.java index f98bcfe308e..665bfb3743b 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/TimeStampMilliTZVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/TimeStampMilliTZVector.java @@ -25,6 +25,7 @@ import org.apache.arrow.vector.holders.TimeStampMilliTZHolder; import org.apache.arrow.vector.types.TimeUnit; import org.apache.arrow.vector.types.Types.MinorType; +import org.apache.arrow.vector.types.pojo.ArrowType; import org.apache.arrow.vector.types.pojo.FieldType; import org.apache.arrow.vector.util.TransferPair; @@ -44,8 +45,7 @@ public class TimeStampMilliTZVector extends TimeStampVector { * @param allocator allocator for memory management. */ public TimeStampMilliTZVector(String name, BufferAllocator allocator, String timeZone) { - this(name, FieldType.nullable(new org.apache.arrow.vector.types.pojo.ArrowType.Timestamp(TimeUnit.MILLISECOND, timeZone)), - allocator); + this(name, FieldType.nullable(new ArrowType.Timestamp(TimeUnit.MILLISECOND, timeZone)), allocator); } /** @@ -57,7 +57,7 @@ public TimeStampMilliTZVector(String name, BufferAllocator allocator, String tim */ public TimeStampMilliTZVector(String name, FieldType fieldType, BufferAllocator allocator) { super(name, fieldType, allocator); - org.apache.arrow.vector.types.pojo.ArrowType.Timestamp arrowType = (org.apache.arrow.vector.types.pojo.ArrowType.Timestamp) fieldType.getType(); + ArrowType.Timestamp arrowType = (ArrowType.Timestamp) fieldType.getType(); timeZone = arrowType.getTimezone(); reader = new TimeStampMilliTZReaderImpl(TimeStampMilliTZVector.this); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/TimeStampNanoTZVector.java b/java/vector/src/main/java/org/apache/arrow/vector/TimeStampNanoTZVector.java index 9ced90596e5..0c6b0a409fa 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/TimeStampNanoTZVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/TimeStampNanoTZVector.java @@ -25,6 +25,7 @@ import org.apache.arrow.vector.holders.TimeStampNanoTZHolder; import org.apache.arrow.vector.types.TimeUnit; import org.apache.arrow.vector.types.Types.MinorType; +import org.apache.arrow.vector.types.pojo.ArrowType; import org.apache.arrow.vector.types.pojo.FieldType; import org.apache.arrow.vector.util.TransferPair; @@ -44,8 +45,7 @@ public class TimeStampNanoTZVector extends TimeStampVector { * @param allocator allocator for memory management. */ public TimeStampNanoTZVector(String name, BufferAllocator allocator, String timeZone) { - this(name, FieldType.nullable(new org.apache.arrow.vector.types.pojo.ArrowType.Timestamp(TimeUnit.NANOSECOND, timeZone)), - allocator); + this(name, FieldType.nullable(new ArrowType.Timestamp(TimeUnit.NANOSECOND, timeZone)), allocator); } /** @@ -57,7 +57,7 @@ public TimeStampNanoTZVector(String name, BufferAllocator allocator, String time */ public TimeStampNanoTZVector(String name, FieldType fieldType, BufferAllocator allocator) { super(name, fieldType, allocator); - org.apache.arrow.vector.types.pojo.ArrowType.Timestamp arrowType = (org.apache.arrow.vector.types.pojo.ArrowType.Timestamp) fieldType.getType(); + ArrowType.Timestamp arrowType = (ArrowType.Timestamp) fieldType.getType(); timeZone = arrowType.getTimezone(); reader = new TimeStampNanoTZReaderImpl(TimeStampNanoTZVector.this); } @@ -165,7 +165,9 @@ public void set(int index, TimeStampNanoTZHolder holder) { * @param index position of element * @param holder nullable data holder for value of element */ - public void setSafe(int index, NullableTimeStampNanoTZHolder holder) throws IllegalArgumentException { + public void setSafe( + int index, + NullableTimeStampNanoTZHolder holder) throws IllegalArgumentException { handleSafe(index); set(index, holder); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/TimeStampSecTZVector.java b/java/vector/src/main/java/org/apache/arrow/vector/TimeStampSecTZVector.java index d06564e3d12..ec514e8a64c 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/TimeStampSecTZVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/TimeStampSecTZVector.java @@ -23,7 +23,9 @@ import org.apache.arrow.vector.complex.reader.FieldReader; import org.apache.arrow.vector.holders.NullableTimeStampSecTZHolder; import org.apache.arrow.vector.holders.TimeStampSecTZHolder; +import org.apache.arrow.vector.types.TimeUnit; import org.apache.arrow.vector.types.Types.MinorType; +import org.apache.arrow.vector.types.pojo.ArrowType; import org.apache.arrow.vector.types.pojo.FieldType; import org.apache.arrow.vector.util.TransferPair; @@ -43,8 +45,7 @@ public class TimeStampSecTZVector extends TimeStampVector { * @param allocator allocator for memory management. */ public TimeStampSecTZVector(String name, BufferAllocator allocator, String timeZone) { - this(name, FieldType.nullable(new org.apache.arrow.vector.types.pojo.ArrowType.Timestamp(org.apache.arrow.vector.types.TimeUnit.SECOND, timeZone)), - allocator); + this(name, FieldType.nullable(new ArrowType.Timestamp(TimeUnit.SECOND, timeZone)), allocator); } /** @@ -56,7 +57,7 @@ public TimeStampSecTZVector(String name, BufferAllocator allocator, String timeZ */ public TimeStampSecTZVector(String name, FieldType fieldType, BufferAllocator allocator) { super(name, fieldType, allocator); - org.apache.arrow.vector.types.pojo.ArrowType.Timestamp arrowType = (org.apache.arrow.vector.types.pojo.ArrowType.Timestamp) fieldType.getType(); + ArrowType.Timestamp arrowType = (ArrowType.Timestamp) fieldType.getType(); timeZone = arrowType.getTimezone(); reader = new TimeStampSecTZReaderImpl(TimeStampSecTZVector.this); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/TypeLayout.java b/java/vector/src/main/java/org/apache/arrow/vector/TypeLayout.java index 4c05b97b4ac..cccb3b2c3af 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/TypeLayout.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/TypeLayout.java @@ -158,7 +158,8 @@ public TypeLayout visit(Utf8 type) { } private TypeLayout newVariableWidthTypeLayout() { - return newPrimitiveTypeLayout(BufferLayout.validityVector(), BufferLayout.offsetBuffer(), BufferLayout.byteVector()); + return newPrimitiveTypeLayout(BufferLayout.validityVector(), BufferLayout.offsetBuffer(), + BufferLayout.byteVector()); } private TypeLayout newPrimitiveTypeLayout(BufferLayout... vectors) { diff --git a/java/vector/src/main/java/org/apache/arrow/vector/VectorLoader.java b/java/vector/src/main/java/org/apache/arrow/vector/VectorLoader.java index c933d149f8d..d0f85591571 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/VectorLoader.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/VectorLoader.java @@ -62,11 +62,16 @@ public void load(ArrowRecordBatch recordBatch) { } root.setRowCount(recordBatch.getLength()); if (nodes.hasNext() || buffers.hasNext()) { - throw new IllegalArgumentException("not all nodes and buffers were consumed. nodes: " + Iterators.toString(nodes) + " buffers: " + Iterators.toString(buffers)); + throw new IllegalArgumentException("not all nodes and buffers were consumed. nodes: " + + Iterators.toString(nodes) + " buffers: " + Iterators.toString(buffers)); } } - private void loadBuffers(FieldVector vector, Field field, Iterator buffers, Iterator nodes) { + private void loadBuffers( + FieldVector vector, + Field field, + Iterator buffers, + Iterator nodes) { checkArgument(nodes.hasNext(), "no more field nodes for for field " + field + " and vector " + vector); ArrowFieldNode fieldNode = nodes.next(); @@ -84,7 +89,8 @@ private void loadBuffers(FieldVector vector, Field field, Iterator buf List children = field.getChildren(); if (children.size() > 0) { List childrenFromFields = vector.getChildrenFromFields(); - checkArgument(children.size() == childrenFromFields.size(), "should have as many children as in the schema: found " + childrenFromFields.size() + " expected " + children.size()); + checkArgument(children.size() == childrenFromFields.size(), "should have as many children as in the schema: " + + "found " + childrenFromFields.size() + " expected " + children.size()); for (int i = 0; i < childrenFromFields.size(); i++) { Field child = children.get(i); FieldVector fieldVector = childrenFromFields.get(i); diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractContainerVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractContainerVector.java index d2a3c4a62ef..b9d0dc75a6b 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractContainerVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractContainerVector.java @@ -82,7 +82,8 @@ protected T typeify(ValueVector v, Class clazz) { if (clazz.isAssignableFrom(v.getClass())) { return clazz.cast(v); } - throw new IllegalStateException(String.format("Vector requested [%s] was different than type stored [%s]. Arrow doesn't yet support heterogenous types.", clazz.getSimpleName(), v.getClass().getSimpleName())); + throw new IllegalStateException(String.format("Vector requested [%s] was different than type stored [%s]. Arrow " + + "doesn't yet support heterogenous types.", clazz.getSimpleName(), v.getClass().getSimpleName())); } protected boolean supportsDirectRead() { diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractStructVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractStructVector.java index 8ea8b379f92..c1e2ba055fe 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractStructVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractStructVector.java @@ -136,7 +136,8 @@ public T addOrGet(String childName, FieldType fieldType, } return vector; } - final String message = "Arrow does not support schema change yet. Existing[%s] and desired[%s] vector types mismatch"; + final String message = "Arrow does not support schema change yet. Existing[%s] and desired[%s] vector types " + + "mismatch"; throw new IllegalStateException(String.format(message, existing.getClass().getSimpleName(), clazz.getSimpleName())); } @@ -179,7 +180,8 @@ public T getChild(String name, Class clazz) { protected ValueVector add(String childName, FieldType fieldType) { final ValueVector existing = getChild(childName); if (existing != null) { - throw new IllegalStateException(String.format("Vector already exists: Existing[%s], Requested[%s] ", existing.getClass().getSimpleName(), fieldType)); + throw new IllegalStateException(String.format("Vector already exists: Existing[%s], Requested[%s] ", + existing.getClass().getSimpleName(), fieldType)); } FieldVector vector = fieldType.createNewSingleVector(childName, allocator, callBack); putChild(childName, vector); diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/RepeatedValueVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/RepeatedValueVector.java index a7f6d439379..3660bb61fae 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/RepeatedValueVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/RepeatedValueVector.java @@ -25,9 +25,9 @@ /** * An abstraction representing repeated value vectors. * - * A repeated vector contains values that may either be flat or nested. A value consists of zero or more cells(inner values). - * Current design maintains data and offsets vectors. Each cell is stored in the data vector. Repeated vector - * uses the offset vector to determine the sequence of cells pertaining to an individual value. + * A repeated vector contains values that may either be flat or nested. A value consists of zero or more + * cells(inner values). Current design maintains data and offsets vectors. Each cell is stored in the data vector. + * Repeated vector uses the offset vector to determine the sequence of cells pertaining to an individual value. */ public interface RepeatedValueVector extends ValueVector, DensityAwareVector { diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/StateTool.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/StateTool.java index 627998045c9..c443324face 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/StateTool.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/StateTool.java @@ -29,7 +29,8 @@ public static > void check(T currentState, T... expectedStates return; } } - throw new IllegalArgumentException(String.format("Expected to be in one of these states %s but was actually in state %s", Arrays.toString(expectedStates), currentState)); + throw new IllegalArgumentException(String.format("Expected to be in one of these states %s but was actually in " + + "state %s", Arrays.toString(expectedStates), currentState)); } } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/StructVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/StructVector.java index 29464e0c099..cef51ebdae1 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/StructVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/StructVector.java @@ -71,7 +71,8 @@ public StructVector(String name, BufferAllocator allocator, DictionaryEncoding d public StructVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack) { super(name, checkNotNull(allocator), fieldType, callBack); this.validityBuffer = allocator.getEmpty(); - this.validityAllocationSizeInBytes = BitVectorHelper.getValidityBufferSize(BaseValueVector.INITIAL_VALUE_ALLOCATION); + this.validityAllocationSizeInBytes = + BitVectorHelper.getValidityBufferSize(BaseValueVector.INITIAL_VALUE_ALLOCATION); } @Override diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/ComplexWriterImpl.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/ComplexWriterImpl.java index 4169adb6cb6..603178f7383 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/ComplexWriterImpl.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/ComplexWriterImpl.java @@ -28,7 +28,6 @@ import com.google.common.base.Preconditions; public class ComplexWriterImpl extends AbstractFieldWriter implements ComplexWriter { -// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ComplexWriterImpl.class); private NullableStructWriter structRoot; private UnionListWriter listRoot; @@ -41,14 +40,17 @@ public class ComplexWriterImpl extends AbstractFieldWriter implements ComplexWri private enum Mode {INIT, STRUCT, LIST} - ; - - public ComplexWriterImpl(String name, NonNullableStructVector container, boolean unionEnabled, boolean caseSensitive) { + public ComplexWriterImpl( + String name, + NonNullableStructVector container, + boolean unionEnabled, + boolean caseSensitive) { this.name = name; this.container = container; this.unionEnabled = unionEnabled; - nullableStructWriterFactory = caseSensitive ? NullableStructWriterFactory.getNullableCaseSensitiveStructWriterFactoryInstance() : - NullableStructWriterFactory.getNullableStructWriterFactoryInstance(); + nullableStructWriterFactory = caseSensitive ? + NullableStructWriterFactory.getNullableCaseSensitiveStructWriterFactoryInstance() : + NullableStructWriterFactory.getNullableStructWriterFactoryInstance(); } public ComplexWriterImpl(String name, NonNullableStructVector container, boolean unionEnabled) { diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableStructWriterFactory.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableStructWriterFactory.java index 7499687c947..f4cba2348ed 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableStructWriterFactory.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableStructWriterFactory.java @@ -22,8 +22,10 @@ public class NullableStructWriterFactory { private final boolean caseSensitive; - private static final NullableStructWriterFactory nullableStructWriterFactory = new NullableStructWriterFactory(false); - private static final NullableStructWriterFactory nullableCaseSensitiveWriterFactory = new NullableStructWriterFactory(true); + private static final NullableStructWriterFactory nullableStructWriterFactory = + new NullableStructWriterFactory(false); + private static final NullableStructWriterFactory nullableCaseSensitiveWriterFactory = + new NullableStructWriterFactory(true); public NullableStructWriterFactory(boolean caseSensitive) { this.caseSensitive = caseSensitive; diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/PromotableWriter.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/PromotableWriter.java index 4b25c862067..0338017668a 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/PromotableWriter.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/PromotableWriter.java @@ -39,9 +39,9 @@ /** * This FieldWriter implementation delegates all FieldWriter API calls to an inner FieldWriter. This inner field writer - * can start as a specific type, and this class will promote the writer to a UnionWriter if a call is made that the specifically - * typed writer cannot handle. A new UnionVector is created, wrapping the original vector, and replaces the original vector - * in the parent vector, which can be either an AbstractStructVector or a ListVector. + * can start as a specific type, and this class will promote the writer to a UnionWriter if a call is made that the + * specifically typed writer cannot handle. A new UnionVector is created, wrapping the original vector, and replaces the + * original vector in the parent vector, which can be either an AbstractStructVector or a ListVector. */ public class PromotableWriter extends AbstractPromotableFieldWriter { @@ -66,7 +66,10 @@ public PromotableWriter(ValueVector v, AbstractStructVector parentContainer) { this(v, parentContainer, NullableStructWriterFactory.getNullableStructWriterFactoryInstance()); } - public PromotableWriter(ValueVector v, AbstractStructVector parentContainer, NullableStructWriterFactory nullableStructWriterFactory) { + public PromotableWriter( + ValueVector v, + AbstractStructVector parentContainer, + NullableStructWriterFactory nullableStructWriterFactory) { this.parentContainer = parentContainer; this.listVector = null; this.nullableStructWriterFactory = nullableStructWriterFactory; @@ -77,7 +80,10 @@ public PromotableWriter(ValueVector v, ListVector listVector) { this(v, listVector, NullableStructWriterFactory.getNullableStructWriterFactoryInstance()); } - public PromotableWriter(ValueVector v, ListVector listVector, NullableStructWriterFactory nullableStructWriterFactory) { + public PromotableWriter( + ValueVector v, + ListVector listVector, + NullableStructWriterFactory nullableStructWriterFactory) { this.listVector = listVector; this.parentContainer = null; this.nullableStructWriterFactory = nullableStructWriterFactory; diff --git a/java/vector/src/main/java/org/apache/arrow/vector/dictionary/DictionaryEncoder.java b/java/vector/src/main/java/org/apache/arrow/vector/dictionary/DictionaryEncoder.java index eb28ab604bc..744cf95ab31 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/dictionary/DictionaryEncoder.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/dictionary/DictionaryEncoder.java @@ -136,7 +136,8 @@ public static ValueVector decode(ValueVector indices, Dictionary dictionary) { private static void validateType(MinorType type) { // byte arrays don't work as keys in our dictionary map - we could wrap them with something to // implement equals and hashcode if we want that functionality - if (type == MinorType.VARBINARY || type == MinorType.FIXEDSIZEBINARY || type == MinorType.LIST || type == MinorType.STRUCT || type == MinorType.UNION) { + if (type == MinorType.VARBINARY || type == MinorType.FIXEDSIZEBINARY || type == MinorType.LIST || + type == MinorType.STRUCT || type == MinorType.UNION) { throw new IllegalArgumentException("Dictionary encoding for complex types not implemented: type " + type); } } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/ipc/ArrowWriter.java b/java/vector/src/main/java/org/apache/arrow/vector/ipc/ArrowWriter.java index 93f2521ac1f..73c6b6f213f 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/ipc/ArrowWriter.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/ipc/ArrowWriter.java @@ -84,7 +84,8 @@ protected ArrowWriter(VectorSchemaRoot root, DictionaryProvider provider, Writab Dictionary dictionary = provider.lookup(id); FieldVector vector = dictionary.getVector(); int count = vector.getValueCount(); - VectorSchemaRoot dictRoot = new VectorSchemaRoot(ImmutableList.of(vector.getField()), ImmutableList.of(vector), count); + VectorSchemaRoot dictRoot = new VectorSchemaRoot(ImmutableList.of(vector.getField()), ImmutableList.of(vector), + count); VectorUnloader unloader = new VectorUnloader(dictRoot); ArrowRecordBatch batch = unloader.getRecordBatch(); this.dictionaries.add(new ArrowDictionaryBatch(id, batch)); diff --git a/java/vector/src/main/java/org/apache/arrow/vector/ipc/JsonFileReader.java b/java/vector/src/main/java/org/apache/arrow/vector/ipc/JsonFileReader.java index 64170173f62..e4f4e57ced8 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/ipc/JsonFileReader.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/ipc/JsonFileReader.java @@ -136,7 +136,8 @@ private void readDictionaryBatches() throws JsonParseException, IOException { } if (token != END_ARRAY) { - throw new IllegalArgumentException("Invalid token: " + token + " expected end of array at " + parser.getTokenLocation()); + throw new IllegalArgumentException("Invalid token: " + token + " expected end of array at " + + parser.getTokenLocation()); } } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/ipc/JsonFileWriter.java b/java/vector/src/main/java/org/apache/arrow/vector/ipc/JsonFileWriter.java index 6d099b6997d..e6f12753d83 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/ipc/JsonFileWriter.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/ipc/JsonFileWriter.java @@ -113,7 +113,8 @@ public void start(Schema schema, DictionaryProvider provider) throws IOException generator.writeArrayFieldStart("batches"); } - private void writeDictionaryBatches(JsonGenerator generator, Set dictionaryIdsUsed, DictionaryProvider provider) throws IOException { + private void writeDictionaryBatches(JsonGenerator generator, Set dictionaryIdsUsed, DictionaryProvider provider) + throws IOException { generator.writeArrayFieldStart("dictionaries"); for (Long id : dictionaryIdsUsed) { generator.writeStartObject(); @@ -157,7 +158,8 @@ private void writeFromVectorIntoJson(Field field, FieldVector vector) throws IOE List vectorTypes = TypeLayout.getTypeLayout(field.getType()).getBufferTypes(); List vectorBuffers = vector.getFieldBuffers(); if (vectorTypes.size() != vectorBuffers.size()) { - throw new IllegalArgumentException("vector types and inner vector buffers are not the same size: " + vectorTypes.size() + " != " + vectorBuffers.size()); + throw new IllegalArgumentException("vector types and inner vector buffers are not the same size: " + + vectorTypes.size() + " != " + vectorBuffers.size()); } generator.writeStartObject(); { @@ -183,7 +185,8 @@ private void writeFromVectorIntoJson(Field field, FieldVector vector) throws IOE List fields = field.getChildren(); List children = vector.getChildrenFromFields(); if (fields.size() != children.size()) { - throw new IllegalArgumentException("fields and children are not the same size: " + fields.size() + " != " + children.size()); + throw new IllegalArgumentException("fields and children are not the same size: " + fields.size() + " != " + + children.size()); } if (fields.size() > 0) { generator.writeArrayFieldStart("children"); @@ -198,9 +201,12 @@ private void writeFromVectorIntoJson(Field field, FieldVector vector) throws IOE generator.writeEndObject(); } - private void writeValueToGenerator(BufferType bufferType, ArrowBuf buffer, - ArrowBuf offsetBuffer, FieldVector vector, - final int index) throws IOException { + private void writeValueToGenerator( + BufferType bufferType, + ArrowBuf buffer, + ArrowBuf offsetBuffer, + FieldVector vector, + final int index) throws IOException { if (bufferType.equals(TYPE)) { generator.writeNumber(buffer.getByte(index * TinyIntVector.TYPE_WIDTH)); } else if (bufferType.equals(OFFSET)) { diff --git a/java/vector/src/main/java/org/apache/arrow/vector/ipc/message/ArrowRecordBatch.java b/java/vector/src/main/java/org/apache/arrow/vector/ipc/message/ArrowRecordBatch.java index 6c6481e74dd..83d7c0654a1 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/ipc/message/ArrowRecordBatch.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/ipc/message/ArrowRecordBatch.java @@ -141,8 +141,8 @@ public void close() { @Override public String toString() { - return "ArrowRecordBatch [length=" + length + ", nodes=" + nodes + ", #buffers=" + buffers.size() + ", buffersLayout=" - + buffersLayout + ", closed=" + closed + "]"; + return "ArrowRecordBatch [length=" + length + ", nodes=" + nodes + ", #buffers=" + buffers.size() + + ", buffersLayout=" + buffersLayout + ", closed=" + closed + "]"; } /** diff --git a/java/vector/src/main/java/org/apache/arrow/vector/ipc/message/MessageSerializer.java b/java/vector/src/main/java/org/apache/arrow/vector/ipc/message/MessageSerializer.java index 5aace0c6d40..5d69ee2c7d6 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/ipc/message/MessageSerializer.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/ipc/message/MessageSerializer.java @@ -94,7 +94,8 @@ public static void intToBytes(int value, byte[] bytes) { * @return Number of bytes written * @throws IOException */ - public static int writeMessageBuffer(WriteChannel out, int messageLength, ByteBuffer messageBuffer) throws IOException { + public static int writeMessageBuffer(WriteChannel out, int messageLength, ByteBuffer messageBuffer) + throws IOException { // ensure that message aligns to 8 byte padding - 4 bytes for size, then message body if ((messageLength + 4) % 8 != 0) { @@ -169,8 +170,7 @@ public static Schema deserializeSchema(ReadChannel in) throws IOException { * @return the serialized block metadata * @throws IOException if something went wrong */ - public static ArrowBlock serialize(WriteChannel out, ArrowRecordBatch batch) - throws IOException { + public static ArrowBlock serialize(WriteChannel out, ArrowRecordBatch batch) throws IOException { long start = out.getCurrentPosition(); int bodyLength = batch.computeBodyLength(); @@ -278,8 +278,8 @@ public static ArrowRecordBatch deserializeRecordBatch(ReadChannel in, BufferAllo * @return the deserialized ArrowRecordBatch * @throws IOException if something went wrong */ - public static ArrowRecordBatch deserializeRecordBatch(ReadChannel in, ArrowBlock block, - BufferAllocator alloc) throws IOException { + public static ArrowRecordBatch deserializeRecordBatch(ReadChannel in, ArrowBlock block, BufferAllocator alloc) + throws IOException { // Metadata length contains integer prefix plus byte padding long totalLen = block.getMetadataLength() + block.getBodyLength(); @@ -313,8 +313,7 @@ public static ArrowRecordBatch deserializeRecordBatch(ReadChannel in, ArrowBlock * @return ArrowRecordBatch from metadata and in-memory body * @throws IOException */ - public static ArrowRecordBatch deserializeRecordBatch(RecordBatch recordBatchFB, - ArrowBuf body) throws IOException { + public static ArrowRecordBatch deserializeRecordBatch(RecordBatch recordBatchFB, ArrowBuf body) throws IOException { // Now read the body int nodesLength = recordBatchFB.nodesLength(); List nodes = new ArrayList<>(); @@ -391,7 +390,8 @@ public static ArrowBlock serialize(WriteChannel out, ArrowDictionaryBatch batch) * @return the deserialized ArrowDictionaryBatch * @throws IOException if something went wrong */ - public static ArrowDictionaryBatch deserializeDictionaryBatch(Message message, ArrowBuf bodyBuffer) throws IOException { + public static ArrowDictionaryBatch deserializeDictionaryBatch(Message message, ArrowBuf bodyBuffer) + throws IOException { DictionaryBatch dictionaryBatchFB = (DictionaryBatch) message.header(new DictionaryBatch()); ArrowRecordBatch recordBatch = deserializeRecordBatch(dictionaryBatchFB.data(), bodyBuffer); return new ArrowDictionaryBatch(dictionaryBatchFB.id(), recordBatch); @@ -406,7 +406,8 @@ public static ArrowDictionaryBatch deserializeDictionaryBatch(Message message, A * @return the deserialized ArrowDictionaryBatch * @throws IOException */ - public static ArrowDictionaryBatch deserializeDictionaryBatch(ReadChannel in, BufferAllocator allocator) throws IOException { + public static ArrowDictionaryBatch deserializeDictionaryBatch(ReadChannel in, BufferAllocator allocator) + throws IOException { MessageMetadataResult result = readMessage(in); if (result == null) { throw new IOException("Unexpected end of input when reading a DictionaryBatch"); @@ -429,9 +430,10 @@ public static ArrowDictionaryBatch deserializeDictionaryBatch(ReadChannel in, Bu * @return the deserialized ArrowDictionaryBatch * @throws IOException if something went wrong */ - public static ArrowDictionaryBatch deserializeDictionaryBatch(ReadChannel in, - ArrowBlock block, - BufferAllocator alloc) throws IOException { + public static ArrowDictionaryBatch deserializeDictionaryBatch( + ReadChannel in, + ArrowBlock block, + BufferAllocator alloc) throws IOException { // Metadata length contains integer prefix plus byte padding long totalLen = block.getMetadataLength() + block.getBodyLength(); @@ -508,8 +510,11 @@ public static ArrowMessage deserializeMessageBatch(ReadChannel in, BufferAllocat * @param bodyLength body length field * @return the corresponding ByteBuffer */ - public static ByteBuffer serializeMessage(FlatBufferBuilder builder, byte headerType, - int headerOffset, int bodyLength) { + public static ByteBuffer serializeMessage( + FlatBufferBuilder builder, + byte headerType, + int headerOffset, + int bodyLength) { Message.startMessage(builder); Message.addHeaderType(builder, headerType); Message.addHeader(builder, headerOffset); diff --git a/java/vector/src/main/java/org/apache/arrow/vector/types/FloatingPointPrecision.java b/java/vector/src/main/java/org/apache/arrow/vector/types/FloatingPointPrecision.java index ec253287b26..2b76052aa71 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/types/FloatingPointPrecision.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/types/FloatingPointPrecision.java @@ -25,7 +25,8 @@ public enum FloatingPointPrecision { SINGLE(Precision.SINGLE), DOUBLE(Precision.DOUBLE); - private static final FloatingPointPrecision[] valuesByFlatbufId = new FloatingPointPrecision[FloatingPointPrecision.values().length]; + private static final FloatingPointPrecision[] valuesByFlatbufId = + new FloatingPointPrecision[FloatingPointPrecision.values().length]; static { for (FloatingPointPrecision v : FloatingPointPrecision.values()) { diff --git a/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java b/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java index d79f72f61ee..04ed5f53334 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java @@ -122,7 +122,11 @@ public class Types { public enum MinorType { NULL(Null.INSTANCE) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return ZeroVector.INSTANCE; } @@ -133,7 +137,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, STRUCT(Struct.INSTANCE) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new StructVector(name, allocator, fieldType, schemaChangeCallback); } @@ -144,7 +152,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, TINYINT(new Int(8, true)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new TinyIntVector(name, fieldType, allocator); } @@ -155,7 +167,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, SMALLINT(new Int(16, true)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new SmallIntVector(name, fieldType, allocator); } @@ -166,7 +182,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, INT(new Int(32, true)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new IntVector(name, fieldType, allocator); } @@ -177,7 +197,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, BIGINT(new Int(64, true)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new BigIntVector(name, fieldType, allocator); } @@ -188,7 +212,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, DATEDAY(new Date(DateUnit.DAY)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new DateDayVector(name, fieldType, allocator); } @@ -199,7 +227,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, DATEMILLI(new Date(DateUnit.MILLISECOND)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new DateMilliVector(name, fieldType, allocator); } @@ -210,7 +242,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, TIMESEC(new Time(TimeUnit.SECOND, 32)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new TimeSecVector(name, fieldType, allocator); } @@ -221,7 +257,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, TIMEMILLI(new Time(TimeUnit.MILLISECOND, 32)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new TimeMilliVector(name, fieldType, allocator); } @@ -232,7 +272,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, TIMEMICRO(new Time(TimeUnit.MICROSECOND, 64)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new TimeMicroVector(name, fieldType, allocator); } @@ -243,7 +287,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, TIMENANO(new Time(TimeUnit.NANOSECOND, 64)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new TimeNanoVector(name, fieldType, allocator); } @@ -255,7 +303,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { // time in second from the Unix epoch, 00:00:00.000000 on 1 January 1970, UTC. TIMESTAMPSEC(new Timestamp(org.apache.arrow.vector.types.TimeUnit.SECOND, null)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new TimeStampSecVector(name, fieldType, allocator); } @@ -267,7 +319,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { // time in millis from the Unix epoch, 00:00:00.000 on 1 January 1970, UTC. TIMESTAMPMILLI(new Timestamp(org.apache.arrow.vector.types.TimeUnit.MILLISECOND, null)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new TimeStampMilliVector(name, fieldType, allocator); } @@ -279,7 +335,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { // time in microsecond from the Unix epoch, 00:00:00.000000 on 1 January 1970, UTC. TIMESTAMPMICRO(new Timestamp(org.apache.arrow.vector.types.TimeUnit.MICROSECOND, null)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new TimeStampMicroVector(name, fieldType, allocator); } @@ -291,7 +351,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { // time in nanosecond from the Unix epoch, 00:00:00.000000000 on 1 January 1970, UTC. TIMESTAMPNANO(new Timestamp(org.apache.arrow.vector.types.TimeUnit.NANOSECOND, null)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new TimeStampNanoVector(name, fieldType, allocator); } @@ -302,7 +366,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, INTERVALDAY(new Interval(IntervalUnit.DAY_TIME)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new IntervalDayVector(name, fieldType, allocator); } @@ -313,7 +381,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, INTERVALYEAR(new Interval(IntervalUnit.YEAR_MONTH)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new IntervalYearVector(name, fieldType, allocator); } @@ -325,7 +397,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { // 4 byte ieee 754 FLOAT4(new FloatingPoint(SINGLE)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new Float4Vector(name, fieldType, allocator); } @@ -337,7 +413,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { // 8 byte ieee 754 FLOAT8(new FloatingPoint(DOUBLE)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new Float8Vector(name, fieldType, allocator); } @@ -348,7 +428,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, BIT(Bool.INSTANCE) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new BitVector(name, fieldType, allocator); } @@ -359,7 +443,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, VARCHAR(Utf8.INSTANCE) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new VarCharVector(name, fieldType, allocator); } @@ -370,7 +458,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, VARBINARY(Binary.INSTANCE) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new VarBinaryVector(name, fieldType, allocator); } @@ -381,7 +473,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, DECIMAL(null) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new DecimalVector(name, fieldType, allocator); } @@ -392,7 +488,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, FIXEDSIZEBINARY(null) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new FixedSizeBinaryVector(name, fieldType, allocator); } @@ -403,7 +503,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, UINT1(new Int(8, false)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new UInt1Vector(name, fieldType, allocator); } @@ -414,7 +518,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, UINT2(new Int(16, false)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new UInt2Vector(name, fieldType, allocator); } @@ -425,7 +533,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, UINT4(new Int(32, false)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new UInt4Vector(name, fieldType, allocator); } @@ -436,7 +548,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, UINT8(new Int(64, false)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new UInt8Vector(name, fieldType, allocator); } @@ -447,7 +563,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, LIST(List.INSTANCE) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new ListVector(name, allocator, fieldType, schemaChangeCallback); } @@ -458,20 +578,30 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, FIXED_SIZE_LIST(null) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new FixedSizeListVector(name, allocator, fieldType, schemaChangeCallback); } @Override public FieldWriter getNewFieldWriter(ValueVector vector) { - throw new UnsupportedOperationException("FieldWriter not implemented for FixedSizeList type"); + throw new UnsupportedOperationException("FieldWriter not implemented for FixedSizeList " + + "type"); } }, UNION(new Union(Sparse, null)) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { if (fieldType.getDictionary() != null) { - throw new UnsupportedOperationException("Dictionary encoding not supported for complex types"); + throw new UnsupportedOperationException("Dictionary encoding not supported for complex " + + "types"); } return new UnionVector(name, allocator, schemaChangeCallback); } @@ -483,7 +613,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, TIMESTAMPSECTZ(null) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new TimeStampSecTZVector(name, fieldType, allocator); } @@ -494,7 +628,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, TIMESTAMPMILLITZ(null) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new TimeStampMilliTZVector(name, fieldType, allocator); } @@ -505,7 +643,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, TIMESTAMPMICROTZ(null) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new TimeStampMicroTZVector(name, fieldType, allocator); } @@ -516,7 +658,11 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { }, TIMESTAMPNANOTZ(null) { @Override - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { + public FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback) { return new TimeStampNanoTZVector(name, fieldType, allocator); } @@ -539,7 +685,11 @@ public final ArrowType getType() { return type; } - public abstract FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback); + public abstract FieldVector getNewVector( + String name, + FieldType fieldType, + BufferAllocator allocator, + CallBack schemaChangeCallback); public abstract FieldWriter getNewFieldWriter(ValueVector vector); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Field.java b/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Field.java index 860cf432a38..355ac025d21 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Field.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Field.java @@ -131,6 +131,7 @@ public static Field convertField(org.apache.arrow.flatbuf.Field field) { /** * Helper method to ensure backward compatibility with schemas generated prior to ARROW-1347, ARROW-1663 + * * @param field * @param originalChildField original field which name might be mutated * @return original or mutated field diff --git a/java/vector/src/main/java/org/apache/arrow/vector/util/ByteFunctionHelpers.java b/java/vector/src/main/java/org/apache/arrow/vector/util/ByteFunctionHelpers.java index 42401c554db..67ce99b0d5b 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/util/ByteFunctionHelpers.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/util/ByteFunctionHelpers.java @@ -94,7 +94,13 @@ private static final int memEqual(final long laddr, int lStart, int lEnd, final * @param rEnd end offset in the buffer * @return 1 if left input is greater, -1 if left input is smaller, 0 otherwise */ - public static final int compare(final ArrowBuf left, int lStart, int lEnd, final ArrowBuf right, int rStart, int rEnd) { + public static final int compare( + final ArrowBuf left, + int lStart, + int lEnd, + final ArrowBuf right, + int rStart, + int rEnd) { if (BoundsChecking.BOUNDS_CHECKING_ENABLED) { left.checkBytes(lStart, lEnd); right.checkBytes(rStart, rEnd); @@ -102,7 +108,13 @@ public static final int compare(final ArrowBuf left, int lStart, int lEnd, final return memcmp(left.memoryAddress(), lStart, lEnd, right.memoryAddress(), rStart, rEnd); } - private static final int memcmp(final long laddr, int lStart, int lEnd, final long raddr, int rStart, final int rEnd) { + private static final int memcmp( + final long laddr, + int lStart, + int lEnd, + final long raddr, + int rStart, + final int rEnd) { int lLen = lEnd - lStart; int rLen = rEnd - rStart; int n = Math.min(rLen, lLen); @@ -149,7 +161,13 @@ private static final int memcmp(final long laddr, int lStart, int lEnd, final lo * @param rEnd end offset in the byte array * @return 1 if left input is greater, -1 if left input is smaller, 0 otherwise */ - public static final int compare(final ArrowBuf left, int lStart, int lEnd, final byte[] right, int rStart, final int rEnd) { + public static final int compare( + final ArrowBuf left, + int lStart, + int lEnd, + final byte[] right, + int rStart, + final int rEnd) { if (BoundsChecking.BOUNDS_CHECKING_ENABLED) { left.checkBytes(lStart, lEnd); } @@ -157,7 +175,13 @@ public static final int compare(final ArrowBuf left, int lStart, int lEnd, final } - private static final int memcmp(final long laddr, int lStart, int lEnd, final byte[] right, int rStart, final int rEnd) { + private static final int memcmp( + final long laddr, + int lStart, + int lEnd, + final byte[] right, + int rStart, + final int rEnd) { int lLen = lEnd - lStart; int rLen = rEnd - rStart; int n = Math.min(rLen, lLen); diff --git a/java/vector/src/main/java/org/apache/arrow/vector/util/DateUtility.java b/java/vector/src/main/java/org/apache/arrow/vector/util/DateUtility.java index 3dd169b8235..95d6ad00c9b 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/util/DateUtility.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/util/DateUtility.java @@ -655,7 +655,8 @@ public static DateTimeFormatter getDateTimeFormatter() { DateTimeParser optionalSec = DateTimeFormat.forPattern(".SSS").getParser(); DateTimeParser optionalZone = DateTimeFormat.forPattern(" ZZZ").getParser(); - dateTimeTZFormat = new DateTimeFormatterBuilder().append(dateFormatter).appendOptional(optionalTime).appendOptional(optionalSec).appendOptional(optionalZone).toFormatter(); + dateTimeTZFormat = new DateTimeFormatterBuilder().append(dateFormatter).appendOptional(optionalTime) + .appendOptional(optionalSec).appendOptional(optionalZone).toFormatter(); } return dateTimeTZFormat; 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 510211a835c..e6750dae901 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 @@ -188,8 +188,8 @@ public static boolean checkPrecisionAndScale(BigDecimal value, int vectorPrecisi value.scale() + " != " + vectorScale); } if (value.precision() > vectorPrecision) { - throw new UnsupportedOperationException("BigDecimal precision can not be greater than that in the Arrow vector: " + - value.precision() + " > " + vectorPrecision); + throw new UnsupportedOperationException("BigDecimal precision can not be greater than that in the Arrow " + + "vector: " + value.precision() + " > " + vectorPrecision); } return true; } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/util/DictionaryUtility.java b/java/vector/src/main/java/org/apache/arrow/vector/util/DictionaryUtility.java index 6b46dbae385..aa5b6210f40 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/util/DictionaryUtility.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/util/DictionaryUtility.java @@ -69,7 +69,8 @@ public static Field toMessageFormat(Field field, DictionaryProvider provider, Se dictionaryIdsUsed.add(id); } - return new Field(field.getName(), new FieldType(field.isNullable(), type, encoding, field.getMetadata()), updatedChildren); + return new Field(field.getName(), new FieldType(field.isNullable(), type, encoding, field.getMetadata()), + updatedChildren); } /** @@ -108,6 +109,7 @@ public static Field toMemoryFormat(Field field, BufferAllocator allocator, Map keySet() { @Override public Collection values() { - return Lists.newArrayList(Iterables.transform(secondary.entries(), new Function, V>() { + return Lists.newArrayList(Iterables.transform(secondary.entries(), + new Function, V>() { @Override public V apply(IntObjectMap.PrimitiveEntry entry) { return Preconditions.checkNotNull(entry).value(); @@ -144,7 +145,8 @@ public V apply(IntObjectMap.PrimitiveEntry entry) { @Override public Set> entrySet() { - return Sets.newHashSet(Iterables.transform(primary.entrySet(), new Function>, Entry>() { + return Sets.newHashSet(Iterables.transform(primary.entrySet(), + new Function>, Entry>() { @Override public Entry apply(Entry> entry) { return new AbstractMap.SimpleImmutableEntry<>(entry.getKey(), entry.getValue().getValue()); @@ -220,9 +222,10 @@ public boolean containsValue(Object value) { } /** - * Removes the element corresponding to the key if exists extending the semantics of {@link java.util.Map#remove} with ordinal - * re-cycling. The ordinal corresponding to the given key may be re-assigned to another tuple. It is important that - * consumer checks the ordinal value via {@link org.apache.arrow.vector.util.MapWithOrdinal#getOrdinal(Object)} before attempting to look-up by ordinal. + * Removes the element corresponding to the key if exists extending the semantics of {@link java.util.Map#remove} + * with ordinal re-cycling. The ordinal corresponding to the given key may be re-assigned to another tuple. It is + * important that consumer checks the ordinal value via + * {@link org.apache.arrow.vector.util.MapWithOrdinal#getOrdinal(Object)} before attempting to look-up by ordinal. * * @see java.util.Map#remove */ diff --git a/java/vector/src/main/java/org/apache/arrow/vector/util/OversizedAllocationException.java b/java/vector/src/main/java/org/apache/arrow/vector/util/OversizedAllocationException.java index b4ff2522daf..3a6cd6a307b 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/util/OversizedAllocationException.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/util/OversizedAllocationException.java @@ -23,14 +23,19 @@ * An exception that is used to signal that allocation request in bytes is greater than the maximum allowed by * {@link org.apache.arrow.memory.BufferAllocator#buffer(int) allocator}. * - *

Operators should handle this exception to split the batch and later resume the execution on the next iteration.

+ *

Operators should handle this exception to split the batch and later resume the execution on the next + * iteration.

*/ public class OversizedAllocationException extends RuntimeException { public OversizedAllocationException() { super(); } - public OversizedAllocationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + public OversizedAllocationException( + String message, + Throwable cause, + boolean enableSuppression, + boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/util/SchemaChangeRuntimeException.java b/java/vector/src/main/java/org/apache/arrow/vector/util/SchemaChangeRuntimeException.java index ddfea948a8f..1378b4cbce3 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/util/SchemaChangeRuntimeException.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/util/SchemaChangeRuntimeException.java @@ -24,7 +24,11 @@ public SchemaChangeRuntimeException() { super(); } - public SchemaChangeRuntimeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + public SchemaChangeRuntimeException( + String message, + Throwable cause, + boolean enableSuppression, + boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/util/Text.java b/java/vector/src/main/java/org/apache/arrow/vector/util/Text.java index 50037bf92d6..7821435b72a 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/util/Text.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/util/Text.java @@ -39,7 +39,8 @@ import com.fasterxml.jackson.databind.ser.std.StdSerializer; /** - * A simplified byte wrapper similar to Hadoop's Text class without all the dependencies. Lifted from Hadoop 2.7.1 + * A simplified byte wrapper similar to Hadoop's Text class without all the dependencies. + * Lifted from Hadoop 2.7.1 */ @JsonSerialize(using = Text.TextSerializer.class) public class Text { @@ -101,8 +102,8 @@ public Text(byte[] utf8) { } /** - * Get a copy of the bytes that is exactly the length of the data. See {@link #getBytes()} for faster access to the - * underlying array. + * Get a copy of the bytes that is exactly the length of the data. See {@link #getBytes()} for + * faster access to the underlying array. * * @return a copy of the underlying array */ @@ -113,8 +114,8 @@ public byte[] copyBytes() { } /** - * Returns the raw bytes; however, only data up to {@link #getLength()} is valid. Please use {@link #copyBytes()} if - * you need the returned array to be precisely the length of the data. + * Returns the raw bytes; however, only data up to {@link #getLength()} is valid. Please use + * {@link #copyBytes()} if you need the returned array to be precisely the length of the data. * * @return the underlying array */ @@ -130,11 +131,13 @@ public int getLength() { } /** - * Returns the Unicode Scalar Value (32-bit integer value) for the character at position. Note that this - * method avoids using the converter or doing String instantiation + * Returns the Unicode Scalar Value (32-bit integer value) for the character at + * position. Note that this method avoids using the converter or doing String + * instantiation * * @param position the index of the char we want to retrieve - * @return the Unicode scalar value at position or -1 if the position is invalid or points to a trailing byte + * @return the Unicode scalar value at position or -1 if the position is invalid or points to a + * trailing byte */ public int charAt(int position) { if (position > this.length) { @@ -153,13 +156,15 @@ public int find(String what) { } /** - * Finds any occurrence of what in the backing buffer, starting as position start. The - * starting position is measured in bytes and the return value is in terms of byte position in the buffer. The backing - * buffer is not converted to a string for this operation. + * Finds any occurrence of what in the backing buffer, starting as position + * start. The starting position is measured in bytes and the return value is in terms + * of byte position in the buffer. The backing buffer is not converted to a string for this + * operation. * * @param what the string to search for * @param start where to start from - * @return byte position of the first occurrence of the search string in the UTF-8 buffer or -1 if not found + * @return byte position of the first occurrence of the search string in the UTF-8 buffer or -1 + * if not found */ public int find(String what, int start) { try { @@ -263,18 +268,19 @@ public void append(byte[] utf8, int start, int len) { /** * Clear the string to empty. * - * Note: For performance reasons, this call does not clear the underlying byte array that is retrievable via - * {@link #getBytes()}. In order to free the byte-array memory, call {@link #set(byte[])} with an empty byte array - * (For example, new byte[0]). + * Note: For performance reasons, this call does not clear the underlying byte array that + * is retrievable via {@link #getBytes()}. In order to free the byte-array memory, call + * {@link #set(byte[])} with an empty byte array (For example, new byte[0]). */ public void clear() { length = 0; } /** - * Sets the capacity of this Text object to at least len bytes. If the current buffer is longer, - * then the capacity and existing content of the buffer are unchanged. If len is larger than the current - * capacity, the Text object's capacity is increased to match. + * Sets the capacity of this Text object to at least len bytes. If the + * current buffer is longer, then the capacity and existing content of the buffer are unchanged. + * If len is larger than the current capacity, the Text object's capacity is + * increased to match. * * @param len the number of bytes we need * @param keepData should the old data be kept @@ -299,8 +305,8 @@ public String toString() { } /** - * Read a Text object whose length is already known. This allows creating Text from a stream which uses a different - * serialization format. + * Read a Text object whose length is already known. This allows creating Text from a stream which + * uses a different serialization format. * * @param in the input to initialize from * @param len how many bytes to read from in @@ -360,8 +366,8 @@ public int hashCode() { // / STATIC UTILITIES FROM HERE DOWN /** - * Converts the provided byte array to a String using the UTF-8 encoding. If the input is malformed, replace by a - * default value. + * Converts the provided byte array to a String using the UTF-8 encoding. If the input is + * malformed, replace by a default value. * * @param utf8 bytes to decode * @return the decoded string @@ -377,9 +383,9 @@ public static String decode(byte[] utf8, int start, int length) } /** - * Converts the provided byte array to a String using the UTF-8 encoding. If replace is true, then - * malformed input is replaced with the substitution character, which is U+FFFD. Otherwise the method throws a - * MalformedInputException. + * Converts the provided byte array to a String using the UTF-8 encoding. If replace + * is true, then malformed input is replaced with the substitution character, which is U+FFFD. + * Otherwise the method throws a MalformedInputException. * * @param utf8 the bytes to decode * @param start where to start from @@ -411,8 +417,8 @@ private static String decode(ByteBuffer utf8, boolean replace) } /** - * Converts the provided String to bytes using the UTF-8 encoding. If the input is malformed, invalid chars are - * replaced by a default value. + * Converts the provided String to bytes using the UTF-8 encoding. If the input is malformed, + * invalid chars are replaced by a default value. * * @param string the string to encode * @return ByteBuffer: bytes stores at ByteBuffer.array() and length is ByteBuffer.limit() @@ -424,9 +430,9 @@ public static ByteBuffer encode(String string) } /** - * Converts the provided String to bytes using the UTF-8 encoding. If replace is true, then malformed - * input is replaced with the substitution character, which is U+FFFD. Otherwise the method throws a - * MalformedInputException. + * Converts the provided String to bytes using the UTF-8 encoding. If replace is + * true, then malformed input is replaced with the substitution character, which is U+FFFD. + * Otherwise the method throws a MalformedInputException. * * @param string the string to encode * @param replace whether to replace malformed characters with U+FFFD @@ -554,9 +560,9 @@ public static void validateUTF8(byte[] utf8, int start, int len) } /** - * Magic numbers for UTF-8. These are the number of bytes that follow a given lead byte. Trailing bytes have - * the value -1. The values 4 and 5 are presented in this table, even though valid UTF-8 cannot include the five and - * six byte sequences. + * Magic numbers for UTF-8. These are the number of bytes that follow a given lead byte. + * Trailing bytes have the value -1. The values 4 and 5 are presented in this table, even though + * valid UTF-8 cannot include the five and six byte sequences. */ static final int[] bytesFromUTF8 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -576,8 +582,8 @@ public static void validateUTF8(byte[] utf8, int start, int len) 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5}; /** - * Returns the next code point at the current position in the buffer. The buffer's position will be incremented. Any - * mark set on this buffer will be changed by this method! + * Returns the next code point at the current position in the buffer. The buffer's position will + * be incremented. Any mark set on this buffer will be changed by this method! * * @param bytes the incoming bytes * @return the corresponding unicode codepoint @@ -662,8 +668,10 @@ public TextSerializer() { } @Override - public void serialize(Text text, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) - throws IOException, JsonGenerationException { + public void serialize( + Text text, + JsonGenerator jsonGenerator, + SerializerProvider serializerProvider) throws IOException, JsonGenerationException { jsonGenerator.writeString(text.toString()); } } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/util/Validator.java b/java/vector/src/main/java/org/apache/arrow/vector/util/Validator.java index c27634a7eda..624ea1beaa4 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/util/Validator.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/util/Validator.java @@ -53,15 +53,21 @@ public static void compareSchemas(Schema schema1, Schema schema2) { /** * Validate two Dictionary encodings and dictionaries with id's from the encodings */ - public static void compareDictionaries(List encodings1, List encodings2, DictionaryProvider provider1, DictionaryProvider provider2) { + public static void compareDictionaries( + List encodings1, + List encodings2, + DictionaryProvider provider1, + DictionaryProvider provider2) { if (encodings1.size() != encodings2.size()) { - throw new IllegalArgumentException("Different dictionary encoding count:\n" + encodings1.size() + "\n" + encodings2.size()); + throw new IllegalArgumentException("Different dictionary encoding count:\n" + + encodings1.size() + "\n" + encodings2.size()); } for (int i = 0; i < encodings1.size(); i++) { if (!encodings1.get(i).equals(encodings2.get(i))) { - throw new IllegalArgumentException("Different dictionary encodings:\n" + encodings1.get(i) + "\n" + encodings2.get(i)); + throw new IllegalArgumentException("Different dictionary encodings:\n" + encodings1.get(i) + + "\n" + encodings2.get(i)); } long id = encodings1.get(i).getId(); @@ -69,7 +75,8 @@ public static void compareDictionaries(List encodings1, List Dictionary dict2 = provider2.lookup(id); if (dict1 == null || dict2 == null) { - throw new IllegalArgumentException("The DictionaryProvider did not contain the required dictionary with id: " + id + "\n" + dict1 + "\n" + dict2); + throw new IllegalArgumentException("The DictionaryProvider did not contain the required " + + "dictionary with id: " + id + "\n" + dict1 + "\n" + dict2); } try { @@ -95,7 +102,8 @@ public static void compareVectorSchemaRoot(VectorSchemaRoot root1, VectorSchemaR List vectors1 = root1.getFieldVectors(); List vectors2 = root2.getFieldVectors(); if (vectors1.size() != vectors2.size()) { - throw new IllegalArgumentException("Different column count:\n" + vectors1.toString() + "\n!=\n" + vectors2.toString()); + throw new IllegalArgumentException("Different column count:\n" + vectors1.toString() + + "\n!=\n" + vectors2.toString()); } for (int i = 0; i < vectors1.size(); i++) { compareFieldVectors(vectors1.get(i), vectors2.get(i)); @@ -112,11 +120,13 @@ public static void compareVectorSchemaRoot(VectorSchemaRoot root1, VectorSchemaR public static void compareFieldVectors(FieldVector vector1, FieldVector vector2) { Field field1 = vector1.getField(); if (!field1.equals(vector2.getField())) { - throw new IllegalArgumentException("Different Fields:\n" + field1 + "\n!=\n" + vector2.getField()); + throw new IllegalArgumentException("Different Fields:\n" + field1 + "\n!=\n" + + vector2.getField()); } int valueCount = vector1.getValueCount(); if (valueCount != vector2.getValueCount()) { - throw new IllegalArgumentException("Different value count for field " + field1 + " : " + valueCount + " != " + vector2.getValueCount()); + throw new IllegalArgumentException("Different value count for field " + field1 + " : " + + valueCount + " != " + vector2.getValueCount()); } for (int j = 0; j < valueCount; j++) { Object obj1 = vector1.getObject(j); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestBitVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestBitVector.java index 64da343d413..7cb34eb2e33 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestBitVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestBitVector.java @@ -120,8 +120,8 @@ public void testSplitAndTransfer() throws Exception { for (int i = 0; i < length; i++) { int actual = toVector.get(i); int expected = sourceVector.get(start + i); - assertEquals("different data values not expected --> sourceVector index: " + (start + i) + " toVector index: " + i, - expected, actual); + assertEquals("different data values not expected --> sourceVector index: " + (start + i) + + " toVector index: " + i, expected, actual); } } } @@ -163,8 +163,8 @@ public void testSplitAndTransfer1() throws Exception { for (int i = 0; i < length; i++) { int actual = toVector.get(i); int expected = sourceVector.get(start + i); - assertEquals("different data values not expected --> sourceVector index: " + (start + i) + " toVector index: " + i, - expected, actual); + assertEquals("different data values not expected --> sourceVector index: " + (start + i) + + " toVector index: " + i, expected, actual); } } } @@ -214,8 +214,8 @@ public void testSplitAndTransfer2() throws Exception { for (int i = 0; i < length; i++) { int actual = toVector.get(i); int expected = sourceVector.get(start + i); - assertEquals("different data values not expected --> sourceVector index: " + (start + i) + " toVector index: " + i, - expected, actual); + assertEquals("different data values not expected --> sourceVector index: " + (start + i) + + " toVector index: " + i, expected, actual); } } } diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestCopyFrom.java b/java/vector/src/test/java/org/apache/arrow/vector/TestCopyFrom.java index 427aba99142..db920f812ed 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestCopyFrom.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestCopyFrom.java @@ -71,8 +71,8 @@ public void terminate() throws Exception { @Test /* NullableVarChar */ public void testCopyFromWithNulls() { try (final VarCharVector vector = newVector(VarCharVector.class, EMPTY_SCHEMA_PATH, MinorType.VARCHAR, allocator); - final VarCharVector vector2 = newVector(VarCharVector.class, EMPTY_SCHEMA_PATH, MinorType.VARCHAR, allocator)) { - + final VarCharVector vector2 = newVector(VarCharVector.class, EMPTY_SCHEMA_PATH, MinorType.VARCHAR, allocator)) + { vector.allocateNew(); int capacity = vector.getValueCapacity(); assertEquals(4095, capacity); @@ -131,8 +131,8 @@ public void testCopyFromWithNulls() { @Test /* NullableVarChar */ public void testCopyFromWithNulls1() { try (final VarCharVector vector = newVector(VarCharVector.class, EMPTY_SCHEMA_PATH, MinorType.VARCHAR, allocator); - final VarCharVector vector2 = newVector(VarCharVector.class, EMPTY_SCHEMA_PATH, MinorType.VARCHAR, allocator)) { - + final VarCharVector vector2 = newVector(VarCharVector.class, EMPTY_SCHEMA_PATH, MinorType.VARCHAR, allocator)) + { vector.allocateNew(); int capacity = vector.getValueCapacity(); assertEquals(4095, capacity); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestDecimalVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestDecimalVector.java index 25bcf2be983..f27a7bdc832 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestDecimalVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestDecimalVector.java @@ -61,7 +61,8 @@ public void terminate() throws Exception { @Test public void testValuesWriteRead() { - try (DecimalVector decimalVector = TestUtils.newVector(DecimalVector.class, "decimal", new ArrowType.Decimal(10, scale), allocator);) { + try (DecimalVector decimalVector = TestUtils.newVector(DecimalVector.class, "decimal", + new ArrowType.Decimal(10, scale), allocator);) { try (DecimalVector oldConstructor = new DecimalVector("decimal", allocator, 10, scale);) { assertEquals(decimalVector.getField().getType(), oldConstructor.getField().getType()); @@ -86,7 +87,8 @@ public void testValuesWriteRead() { @Test public void testBigDecimalDifferentScaleAndPrecision() { - try (DecimalVector decimalVector = TestUtils.newVector(DecimalVector.class, "decimal", new ArrowType.Decimal(4, 2), allocator);) { + try (DecimalVector decimalVector = TestUtils.newVector(DecimalVector.class, "decimal", + new ArrowType.Decimal(4, 2), allocator);) { decimalVector.allocateNew(); // test BigDecimal with different scale @@ -115,7 +117,8 @@ public void testBigDecimalDifferentScaleAndPrecision() { @Test public void testWriteBigEndian() { - try (DecimalVector decimalVector = TestUtils.newVector(DecimalVector.class, "decimal", new ArrowType.Decimal(38, 9), allocator);) { + try (DecimalVector decimalVector = TestUtils.newVector(DecimalVector.class, "decimal", + new ArrowType.Decimal(38, 9), allocator);) { decimalVector.allocateNew(); BigDecimal decimal1 = new BigDecimal("123456789.000000000"); BigDecimal decimal2 = new BigDecimal("11.123456789"); @@ -159,7 +162,8 @@ public void testWriteBigEndian() { @Test public void testBigDecimalReadWrite() { - try (DecimalVector decimalVector = TestUtils.newVector(DecimalVector.class, "decimal", new ArrowType.Decimal(38, 9), allocator);) { + try (DecimalVector decimalVector = TestUtils.newVector(DecimalVector.class, "decimal", + new ArrowType.Decimal(38, 9), allocator);) { decimalVector.allocateNew(); BigDecimal decimal1 = new BigDecimal("123456789.000000000"); BigDecimal decimal2 = new BigDecimal("11.123456789"); @@ -198,7 +202,8 @@ public void testBigDecimalReadWrite() { */ @Test public void decimalBE2LE() { - try (DecimalVector decimalVector = TestUtils.newVector(DecimalVector.class, "decimal", new ArrowType.Decimal(21, 2), allocator)) { + try (DecimalVector decimalVector = TestUtils.newVector(DecimalVector.class, "decimal", + new ArrowType.Decimal(21, 2), allocator)) { decimalVector.allocateNew(); BigInteger[] testBigInts = new BigInteger[] { diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestFixedSizeListVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestFixedSizeListVector.java index 6c01c884bd1..384a49ee971 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestFixedSizeListVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestFixedSizeListVector.java @@ -79,7 +79,8 @@ public void testIntType() { @Test public void testFloatTypeNullable() { try (FixedSizeListVector vector = FixedSizeListVector.empty("list", 2, allocator)) { - Float4Vector nested = (Float4Vector) vector.addOrGetVector(FieldType.nullable(MinorType.FLOAT4.getType())).getVector(); + Float4Vector nested = (Float4Vector) vector.addOrGetVector(FieldType.nullable(MinorType.FLOAT4.getType())) + .getVector(); vector.allocateNew(); for (int i = 0; i < 10; i++) { @@ -113,8 +114,10 @@ public void testFloatTypeNullable() { @Test public void testNestedInList() { try (ListVector vector = ListVector.empty("list", allocator)) { - FixedSizeListVector tuples = (FixedSizeListVector) vector.addOrGetVector(FieldType.nullable(new ArrowType.FixedSizeList(2))).getVector(); - IntVector innerVector = (IntVector) tuples.addOrGetVector(FieldType.nullable(MinorType.INT.getType())).getVector(); + FixedSizeListVector tuples = (FixedSizeListVector) vector.addOrGetVector( + FieldType.nullable(new ArrowType.FixedSizeList(2))).getVector(); + IntVector innerVector = (IntVector) tuples.addOrGetVector(FieldType.nullable(MinorType.INT.getType())) + .getVector(); vector.allocateNew(); for (int i = 0; i < 10; i++) { @@ -156,7 +159,8 @@ public void testNestedInList() { public void testTransferPair() { try (FixedSizeListVector from = new FixedSizeListVector("from", allocator, 2, null, null); FixedSizeListVector to = new FixedSizeListVector("to", allocator, 2, null, null)) { - Float4Vector nested = (Float4Vector) from.addOrGetVector(FieldType.nullable(MinorType.FLOAT4.getType())).getVector(); + Float4Vector nested = (Float4Vector) from.addOrGetVector(FieldType.nullable(MinorType.FLOAT4.getType())) + .getVector(); from.allocateNew(); for (int i = 0; i < 10; i++) { diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestListVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestListVector.java index e0c6bd01415..a5552678d18 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestListVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestListVector.java @@ -830,7 +830,8 @@ public void testSetInitialCapacity() { @Test public void testClearAndReuse() { try (final ListVector vector = ListVector.empty("list", allocator)) { - BigIntVector bigIntVector = (BigIntVector) vector.addOrGetVector(FieldType.nullable(MinorType.BIGINT.getType())).getVector(); + BigIntVector bigIntVector = + (BigIntVector) vector.addOrGetVector(FieldType.nullable(MinorType.BIGINT.getType())).getVector(); vector.setInitialCapacity(10); vector.allocateNew(); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java index 60240f2bcc6..37ad107dc6c 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java @@ -476,7 +476,8 @@ public void testFixedType4() { public void testNullableFixedType1() { // Create a new value vector for 1024 integers. - try (final UInt4Vector vector = newVector(UInt4Vector.class, EMPTY_SCHEMA_PATH, new ArrowType.Int(32, false), allocator);) { + try (final UInt4Vector vector = newVector(UInt4Vector.class, EMPTY_SCHEMA_PATH, new ArrowType.Int(32, false), + allocator);) { boolean error = false; int initialCapacity = 1024; @@ -1413,7 +1414,8 @@ public void testFillEmptiesNotOverfill() { @Test public void testCopyFromWithNulls() { try (final VarCharVector vector = newVector(VarCharVector.class, EMPTY_SCHEMA_PATH, MinorType.VARCHAR, allocator); - final VarCharVector vector2 = newVector(VarCharVector.class, EMPTY_SCHEMA_PATH, MinorType.VARCHAR, allocator)) { + final VarCharVector vector2 = newVector(VarCharVector.class, EMPTY_SCHEMA_PATH, MinorType.VARCHAR, allocator)) + { vector.allocateNew(); int capacity = vector.getValueCapacity(); @@ -1473,7 +1475,8 @@ public void testCopyFromWithNulls() { @Test public void testCopyFromWithNulls1() { try (final VarCharVector vector = newVector(VarCharVector.class, EMPTY_SCHEMA_PATH, MinorType.VARCHAR, allocator); - final VarCharVector vector2 = newVector(VarCharVector.class, EMPTY_SCHEMA_PATH, MinorType.VARCHAR, allocator)) { + final VarCharVector vector2 = newVector(VarCharVector.class, EMPTY_SCHEMA_PATH, MinorType.VARCHAR, allocator)) + { vector.allocateNew(); int capacity = vector.getValueCapacity(); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java b/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java index 9ad4677b84e..fe6b17942fd 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java @@ -94,8 +94,10 @@ public void testVariableTypeReset() { @Test public void testListTypeReset() { - try (final ListVector variableList = new ListVector("VarList", allocator, FieldType.nullable(MinorType.INT.getType()), null); - final FixedSizeListVector fixedList = new FixedSizeListVector("FixedList", allocator, FieldType.nullable(new FixedSizeList(2)), null) + try (final ListVector variableList = + new ListVector("VarList", allocator, FieldType.nullable(MinorType.INT.getType()), null); + final FixedSizeListVector fixedList = + new FixedSizeListVector("FixedList", allocator, FieldType.nullable(new FixedSizeList(2)), null) ) { // ListVector variableList.allocateNewSafe(); @@ -115,12 +117,15 @@ public void testListTypeReset() { @Test public void testStructTypeReset() { - try (final NonNullableStructVector nonNullableStructVector = new NonNullableStructVector("Struct", allocator, FieldType.nullable(MinorType.INT.getType()), null); - final StructVector structVector = new StructVector("NullableStruct", allocator, FieldType.nullable(MinorType.INT.getType()), null) + try (final NonNullableStructVector nonNullableStructVector = + new NonNullableStructVector("Struct", allocator, FieldType.nullable(MinorType.INT.getType()), null); + final StructVector structVector = + new StructVector("NullableStruct", allocator, FieldType.nullable(MinorType.INT.getType()), null) ) { // NonNullableStructVector nonNullableStructVector.allocateNewSafe(); - IntVector structChild = nonNullableStructVector.addOrGet("child", FieldType.nullable(new Int(32, true)), IntVector.class); + IntVector structChild = nonNullableStructVector + .addOrGet("child", FieldType.nullable(new Int(32, true)), IntVector.class); structChild.setNull(0); nonNullableStructVector.setValueCount(1); resetVectorAndVerify(nonNullableStructVector, nonNullableStructVector.getBuffers(false)); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestVectorUnloadLoad.java b/java/vector/src/test/java/org/apache/arrow/vector/TestVectorUnloadLoad.java index f4deeb88a43..5d5f52ba712 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestVectorUnloadLoad.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestVectorUnloadLoad.java @@ -68,7 +68,8 @@ public void testUnloadLoad() throws IOException { Schema schema; try ( - BufferAllocator originalVectorsAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); + BufferAllocator originalVectorsAllocator = + allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); NonNullableStructVector parent = NonNullableStructVector.empty("parent", originalVectorsAllocator)) { // write some data @@ -116,7 +117,8 @@ public void testUnloadLoadAddPadding() throws IOException { int count = 10000; Schema schema; try ( - BufferAllocator originalVectorsAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); + BufferAllocator originalVectorsAllocator = + allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); NonNullableStructVector parent = NonNullableStructVector.empty("parent", originalVectorsAllocator)) { // write some data @@ -160,7 +162,8 @@ public void testUnloadLoadAddPadding() throws IOException { newBuffers.add(newBuffer); } - try (ArrowRecordBatch newBatch = new ArrowRecordBatch(recordBatch.getLength(), recordBatch.getNodes(), newBuffers);) { + try (ArrowRecordBatch newBatch = + new ArrowRecordBatch(recordBatch.getLength(), recordBatch.getNodes(), newBuffers);) { // load it VectorLoader vectorLoader = new VectorLoader(newRoot); @@ -227,7 +230,8 @@ public void testLoadValidityBuffer() throws IOException { */ try ( - ArrowRecordBatch recordBatch = new ArrowRecordBatch(count, asList(new ArrowFieldNode(count, 0), new ArrowFieldNode(count, count)), asList(values[0], values[1], values[2], values[3])); + ArrowRecordBatch recordBatch = new ArrowRecordBatch(count, asList(new ArrowFieldNode(count, 0), + new ArrowFieldNode(count, count)), asList(values[0], values[1], values[2], values[3])); BufferAllocator finalVectorsAllocator = allocator.newChildAllocator("final vectors", 0, Integer.MAX_VALUE); VectorSchemaRoot newRoot = VectorSchemaRoot.create(schema, finalVectorsAllocator); ) { @@ -277,7 +281,8 @@ public void testUnloadLoadDuplicates() throws IOException { )); try ( - BufferAllocator originalVectorsAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); + BufferAllocator originalVectorsAllocator = + allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); ) { List sources = new ArrayList<>(); for (Field field : schema.getFields()) { @@ -294,7 +299,8 @@ public void testUnloadLoadDuplicates() throws IOException { try (VectorSchemaRoot root = new VectorSchemaRoot(schema.getFields(), sources, count)) { VectorUnloader vectorUnloader = new VectorUnloader(root); try (ArrowRecordBatch recordBatch = vectorUnloader.getRecordBatch(); - BufferAllocator finalVectorsAllocator = allocator.newChildAllocator("final vectors", 0, Integer.MAX_VALUE); + BufferAllocator finalVectorsAllocator = + allocator.newChildAllocator("final vectors", 0, Integer.MAX_VALUE); VectorSchemaRoot newRoot = VectorSchemaRoot.create(schema, finalVectorsAllocator);) { // load it VectorLoader vectorLoader = new VectorLoader(newRoot); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestPromotableWriter.java b/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestPromotableWriter.java index 40b2b0d1735..beb96f6f50f 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestPromotableWriter.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestPromotableWriter.java @@ -110,8 +110,10 @@ public void testPromoteToUnion() throws Exception { Field childField1 = container.getField().getChildren().get(0).getChildren().get(0); Field childField2 = container.getField().getChildren().get(0).getChildren().get(1); - assertEquals("Child field should be union type: " + childField1.getName(), ArrowTypeID.Union, childField1.getType().getTypeID()); - assertEquals("Child field should be decimal type: " + childField2.getName(), ArrowTypeID.Decimal, childField2.getType().getTypeID()); + assertEquals("Child field should be union type: " + + childField1.getName(), ArrowTypeID.Union, childField1.getType().getTypeID()); + assertEquals("Child field should be decimal type: " + + childField2.getName(), ArrowTypeID.Decimal, childField2.getType().getTypeID()); } } } 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 6b9989951eb..5689e7512fa 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 @@ -116,7 +116,8 @@ public void transferPairSchemaChange() { } private NonNullableStructVector populateStructVector(CallBack callBack) { - NonNullableStructVector parent = new NonNullableStructVector("parent", allocator, new FieldType(false, Struct.INSTANCE, null, null), callBack); + NonNullableStructVector parent = + new NonNullableStructVector("parent", allocator, new FieldType(false, Struct.INSTANCE, null, null), callBack); ComplexWriter writer = new ComplexWriterImpl("root", parent); StructWriter rootWriter = writer.rootAsStruct(); IntWriter intWriter = rootWriter.integer("int"); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/ipc/BaseFileTest.java b/java/vector/src/test/java/org/apache/arrow/vector/ipc/BaseFileTest.java index dfb579bd0d5..9c773126886 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/ipc/BaseFileTest.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/ipc/BaseFileTest.java @@ -236,7 +236,9 @@ protected void validateDateTimeContent(int count, VectorSchemaRoot root) { } } - protected VectorSchemaRoot writeFlatDictionaryData(BufferAllocator bufferAllocator, DictionaryProvider.MapDictionaryProvider provider) { + protected VectorSchemaRoot writeFlatDictionaryData( + BufferAllocator bufferAllocator, + DictionaryProvider.MapDictionaryProvider provider) { // Define dictionaries and add to provider VarCharVector dictionary1Vector = newVarCharVector("D1", bufferAllocator); @@ -293,7 +295,8 @@ protected VectorSchemaRoot writeFlatDictionaryData(BufferAllocator bufferAllocat FieldVector encodedVector2 = (FieldVector) DictionaryEncoder.encode(vector2, dictionary2); vector2.close(); // Done with this vector after encoding - List fields = ImmutableList.of(encodedVector1A.getField(), encodedVector1B.getField(), encodedVector2.getField()); + List fields = ImmutableList.of(encodedVector1A.getField(), encodedVector1B.getField(), + encodedVector2.getField()); List vectors = ImmutableList.of(encodedVector1A, encodedVector1B, encodedVector2); return new VectorSchemaRoot(fields, vectors, encodedVector1A.getValueCount()); @@ -363,7 +366,9 @@ protected void validateFlatDictionary(VectorSchemaRoot root, DictionaryProvider Assert.assertEquals(new Text("large"), dictionaryVector.getObject(2)); } - protected VectorSchemaRoot writeNestedDictionaryData(BufferAllocator bufferAllocator, DictionaryProvider.MapDictionaryProvider provider) { + protected VectorSchemaRoot writeNestedDictionaryData( + BufferAllocator bufferAllocator, + DictionaryProvider.MapDictionaryProvider provider) { // Define the dictionary and add to the provider VarCharVector dictionaryVector = newVarCharVector("D2", bufferAllocator); @@ -442,7 +447,8 @@ protected VectorSchemaRoot writeDecimalData(BufferAllocator bufferAllocator) { decimalVector2.setValueCount(count); decimalVector3.setValueCount(count); - List fields = ImmutableList.of(decimalVector1.getField(), decimalVector2.getField(), decimalVector3.getField()); + List fields = ImmutableList.of(decimalVector1.getField(), decimalVector2.getField(), + decimalVector3.getField()); List vectors = ImmutableList.of(decimalVector1, decimalVector2, decimalVector3); return new VectorSchemaRoot(fields, vectors, count); } diff --git a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowFile.java b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowFile.java index 1200a38eec1..bd4f59f719d 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowFile.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowFile.java @@ -99,7 +99,8 @@ public void testWriteRead() throws IOException { int count = COUNT; // write - try (BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); + try (BufferAllocator originalVectorAllocator = + allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); StructVector parent = StructVector.empty("parent", originalVectorAllocator)) { writeData(count, parent); write(parent.getChild("root"), file, stream); @@ -155,7 +156,8 @@ public void testWriteReadComplex() throws IOException { int count = COUNT; // write - try (BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); + try (BufferAllocator originalVectorAllocator = + allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); StructVector parent = StructVector.empty("parent", originalVectorAllocator)) { writeComplexData(count, parent); write(parent.getChild("root"), file, stream); @@ -196,7 +198,8 @@ public void testWriteReadMultipleRBs() throws IOException { int[] counts = {10, 5}; // write - try (BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); + try (BufferAllocator originalVectorAllocator = + allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); StructVector parent = StructVector.empty("parent", originalVectorAllocator); FileOutputStream fileOutputStream = new FileOutputStream(file)) { writeData(counts[0], parent); @@ -211,7 +214,8 @@ public void testWriteReadMultipleRBs() throws IOException { streamWriter.writeBatch(); parent.allocateNew(); - writeData(counts[1], parent); // if we write the same data we don't catch that the metadata is stored in the wrong order. + // if we write the same data we don't catch that the metadata is stored in the wrong order. + writeData(counts[1], parent); root.setRowCount(counts[1]); fileWriter.writeBatch(); @@ -371,7 +375,8 @@ public void testWriteReadMetadata() throws IOException { List childFields = new ArrayList(); childFields.add(new Field("varchar-child", new FieldType(true, ArrowType.Utf8.INSTANCE, null, metadata(1)), null)); - childFields.add(new Field("float-child", new FieldType(true, new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE), null, metadata(2)), null)); + childFields.add(new Field("float-child", + new FieldType(true, new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE), null, metadata(2)), null)); childFields.add(new Field("int-child", new FieldType(false, new ArrowType.Int(32, true), null, metadata(3)), null)); childFields.add(new Field("list-child", new FieldType(true, ArrowType.List.INSTANCE, null, metadata(4)), ImmutableList.of(new Field("l1", FieldType.nullable(new ArrowType.Int(16, true)), null)))); @@ -383,7 +388,8 @@ public void testWriteReadMetadata() throws IOException { Assert.assertEquals(metadata, originalSchema.getCustomMetadata()); // write - try (BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); + try (BufferAllocator originalVectorAllocator = + allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); StructVector vector = (StructVector) field.createVector(originalVectorAllocator)) { vector.allocateNewSafe(); vector.setValueCount(0); @@ -448,7 +454,8 @@ public void testWriteReadDictionary() throws IOException { int numDictionaryBlocksWritten = 0; // write - try (BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE)) { + try (BufferAllocator originalVectorAllocator = + allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE)) { MapDictionaryProvider provider = new MapDictionaryProvider(); @@ -569,9 +576,11 @@ public void testWriteReadFixedSizeBinary() throws IOException { } // write - try (BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); + try (BufferAllocator originalVectorAllocator = + allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); StructVector parent = StructVector.empty("parent", originalVectorAllocator)) { - FixedSizeBinaryVector fixedSizeBinaryVector = parent.addOrGet("fixed-binary", FieldType.nullable(new FixedSizeBinary(typeWidth)), FixedSizeBinaryVector.class); + FixedSizeBinaryVector fixedSizeBinaryVector = parent.addOrGet("fixed-binary", + FieldType.nullable(new FixedSizeBinary(typeWidth)), FixedSizeBinaryVector.class); parent.allocateNew(); for (int i=0; iemptyList()) )); - ArrowFooter footer = new ArrowFooter(schema, Collections.emptyList(), Collections.emptyList()); + ArrowFooter footer = + new ArrowFooter(schema, Collections.emptyList(), Collections.emptyList()); ArrowFooter newFooter = roundTrip(footer); assertEquals(footer, newFooter); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowReaderWriter.java b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowReaderWriter.java index bf42fbb83c8..06a2d5c6777 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowReaderWriter.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowReaderWriter.java @@ -79,7 +79,8 @@ byte[] array(ArrowBuf buf) { @Test public void test() throws IOException { - Schema schema = new Schema(asList(new Field("testField", FieldType.nullable(new ArrowType.Int(8, true)), Collections.emptyList()))); + Schema schema = new Schema(asList(new Field("testField", FieldType.nullable(new ArrowType.Int(8, true)), + Collections.emptyList()))); ArrowType type = schema.getFields().get(0).getType(); FieldVector vector = TestUtils.newVector(FieldVector.class, "testField", type, allocator); vector.initializeChildrenFromFields(schema.getFields().get(0).getChildren()); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowStream.java b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowStream.java index f1f5c000d86..3b0ba27d485 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowStream.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowStream.java @@ -65,7 +65,8 @@ public void testStreamZeroLengthBatch() throws IOException { try (IntVector vector = new IntVector("foo", allocator);) { Schema schema = new Schema(Collections.singletonList(vector.getField()), null); - try (VectorSchemaRoot root = new VectorSchemaRoot(schema, Collections.singletonList(vector), vector.getValueCount()); + try (VectorSchemaRoot root = + new VectorSchemaRoot(schema, Collections.singletonList(vector), vector.getValueCount()); ArrowStreamWriter writer = new ArrowStreamWriter(root, null, Channels.newChannel(os));) { vector.setValueCount(0); root.setRowCount(0); @@ -131,7 +132,8 @@ public void testReadWriteMultipleBatches() throws IOException { try (IntVector vector = new IntVector("foo", allocator);) { Schema schema = new Schema(Collections.singletonList(vector.getField()), null); - try (VectorSchemaRoot root = new VectorSchemaRoot(schema, Collections.singletonList(vector), vector.getValueCount()); + try (VectorSchemaRoot root = + new VectorSchemaRoot(schema, Collections.singletonList(vector), vector.getValueCount()); ArrowStreamWriter writer = new ArrowStreamWriter(root, null, Channels.newChannel(os));) { writeBatchData(writer, vector, root); } diff --git a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestJSONFile.java b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestJSONFile.java index 3545f4519e3..c223e9c8542 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestJSONFile.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestJSONFile.java @@ -43,7 +43,8 @@ public void testWriteRead() throws IOException { int count = COUNT; // write - try (BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); + try (BufferAllocator originalVectorAllocator = + allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); StructVector parent = StructVector.empty("parent", originalVectorAllocator)) { writeData(count, parent); writeJSON(file, new VectorSchemaRoot(parent.getChild("root")), null); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/pojo/TestConvert.java b/java/vector/src/test/java/org/apache/arrow/vector/pojo/TestConvert.java index bac79a10c80..7f1062b609c 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/pojo/TestConvert.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/pojo/TestConvert.java @@ -98,7 +98,8 @@ public void list() throws Exception { Schema tempSchema = Schema.fromJSON(modifiedSchema); FlatBufferBuilder schemaBuilder = new FlatBufferBuilder(); - org.apache.arrow.vector.types.pojo.Schema schema = new org.apache.arrow.vector.types.pojo.Schema(tempSchema.getFields()); + org.apache.arrow.vector.types.pojo.Schema schema = + new org.apache.arrow.vector.types.pojo.Schema(tempSchema.getFields()); schemaBuilder.finish(schema.getSchema(schemaBuilder)); Schema finalSchema = Schema.deserialize(ByteBuffer.wrap(schemaBuilder.sizedByteArray())); assertFalse(finalSchema.toString().contains("[DEFAULT]")); @@ -137,11 +138,13 @@ public void nestedSchema() { childrenBuilder.add(new Field("child4", FieldType.nullable(new List()), ImmutableList.of( new Field("child4.1", FieldType.nullable(Utf8.INSTANCE), null) ))); - childrenBuilder.add(new Field("child5", FieldType.nullable(new Union(UnionMode.Sparse, new int[] {MinorType.TIMESTAMPMILLI.ordinal(), MinorType.FLOAT8.ordinal()})), ImmutableList.of( - new Field("child5.1", FieldType.nullable(new Timestamp(TimeUnit.MILLISECOND, null)), null), - new Field("child5.2", FieldType.nullable(new FloatingPoint(DOUBLE)), ImmutableList.of()), - new Field("child5.3", true, new Timestamp(TimeUnit.MILLISECOND, "UTC"), null) - ))); + childrenBuilder.add(new Field("child5", FieldType.nullable( + new Union(UnionMode.Sparse, new int[] {MinorType.TIMESTAMPMILLI.ordinal(), MinorType.FLOAT8.ordinal()})), + ImmutableList.of( + new Field("child5.1", FieldType.nullable(new Timestamp(TimeUnit.MILLISECOND, null)), null), + new Field("child5.2", FieldType.nullable(new FloatingPoint(DOUBLE)), ImmutableList.of()), + new Field("child5.3", true, new Timestamp(TimeUnit.MILLISECOND, "UTC"), null) + ))); Schema initialSchema = new Schema(childrenBuilder.build()); run(initialSchema); } @@ -157,7 +160,8 @@ private void run(Field initialField) { private void run(Schema initialSchema) { FlatBufferBuilder builder = new FlatBufferBuilder(); builder.finish(initialSchema.getSchema(builder)); - org.apache.arrow.flatbuf.Schema flatBufSchema = org.apache.arrow.flatbuf.Schema.getRootAsSchema(builder.dataBuffer()); + org.apache.arrow.flatbuf.Schema flatBufSchema = + org.apache.arrow.flatbuf.Schema.getRootAsSchema(builder.dataBuffer()); Schema finalSchema = Schema.convertSchema(flatBufSchema); assertEquals(initialSchema, finalSchema); } diff --git a/java/vector/src/test/java/org/apache/arrow/vector/types/pojo/TestSchema.java b/java/vector/src/test/java/org/apache/arrow/vector/types/pojo/TestSchema.java index 42cf2ee20ff..3d468aaa79d 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/types/pojo/TestSchema.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/types/pojo/TestSchema.java @@ -71,7 +71,9 @@ public void testComplex() throws IOException { )); roundTrip(schema); assertEquals( - "Schema, e: List, f: FloatingPoint(SINGLE), g: Timestamp(MILLISECOND, UTC), h: Timestamp(MICROSECOND, null), i: Interval(DAY_TIME)>", + "Schema, e: List, " + + "f: FloatingPoint(SINGLE), g: Timestamp(MILLISECOND, UTC), h: Timestamp(MICROSECOND, null), " + + "i: Interval(DAY_TIME)>", schema.toString()); } @@ -151,7 +153,9 @@ public void testTS() throws IOException { )); roundTrip(schema); assertEquals( - "Schema", + "Schema", schema.toString()); } From 27a4f15c20435be65076a7fcd1bbc83a85d39eff Mon Sep 17 00:00:00 2001 From: Bryan Cutler Date: Wed, 5 Sep 2018 15:19:21 -0700 Subject: [PATCH 05/10] fixed line length for arrow-jdbc --- .../arrow/adapter/jdbc/JdbcToArrow.java | 35 ++++++++---- .../arrow/adapter/jdbc/JdbcToArrowUtils.java | 27 +++++++-- .../adapter/jdbc/AbstractJdbcToArrowTest.java | 3 +- .../jdbc/h2/JdbcToArrowCharSetTest.java | 17 +++--- .../jdbc/h2/JdbcToArrowDataTypesTest.java | 56 ++++++++++++------- .../adapter/jdbc/h2/JdbcToArrowNullTest.java | 13 +++-- .../adapter/jdbc/h2/JdbcToArrowTest.java | 17 +++--- .../jdbc/h2/JdbcToArrowTimeZoneTest.java | 17 +++--- 8 files changed, 120 insertions(+), 65 deletions(-) diff --git a/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrow.java b/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrow.java index a9d6e44bd36..1fe5ef1dfe7 100644 --- a/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrow.java +++ b/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrow.java @@ -75,14 +75,17 @@ public class JdbcToArrow { * If you wish to use specific TimeZone or Locale for any Date, Time and Timestamp datasets, you may want use * overloaded API that taken Calendar object instance. * - * @param connection Database connection to be used. This method will not close the passed connection object. Since hte caller has passed - * the connection object it's the responsibility of the caller to close or return the connection to the pool. + * @param connection Database connection to be used. This method will not close the passed connection object. Since + * the caller has passed the connection object it's the responsibility of the caller to close or + * return the connection to the pool. * @param query The DB Query to fetch the data. * @param allocator Memory allocator * @return Arrow Data Objects {@link VectorSchemaRoot} - * @throws SQLException Propagate any SQL Exceptions to the caller after closing any resources opened such as ResultSet and Statement objects. + * @throws SQLException Propagate any SQL Exceptions to the caller after closing any resources opened such as + * ResultSet and Statement objects. */ - public static VectorSchemaRoot sqlToArrow(Connection connection, String query, BaseAllocator allocator) throws SQLException, IOException { + public static VectorSchemaRoot sqlToArrow(Connection connection, String query, BaseAllocator allocator) + throws SQLException, IOException { Preconditions.checkNotNull(connection, "JDBC connection object can not be null"); Preconditions.checkArgument(query != null && query.length() > 0, "SQL query can not be null or empty"); Preconditions.checkNotNull(allocator, "Memory allocator object can not be null"); @@ -93,15 +96,21 @@ public static VectorSchemaRoot sqlToArrow(Connection connection, String query, B /** * For the given SQL query, execute and fetch the data from Relational DB and convert it to Arrow objects. * - * @param connection Database connection to be used. This method will not close the passed connection object. Since hte caller has passed - * the connection object it's the responsibility of the caller to close or return the connection to the pool. + * @param connection Database connection to be used. This method will not close the passed connection object. Since + * the caller has passed the connection object it's the responsibility of the caller to close or + * return the connection to the pool. * @param query The DB Query to fetch the data. * @param allocator Memory allocator * @param calendar Calendar object to use to handle Date, Time and Timestamp datasets. * @return Arrow Data Objects {@link VectorSchemaRoot} - * @throws SQLException Propagate any SQL Exceptions to the caller after closing any resources opened such as ResultSet and Statement objects. + * @throws SQLException Propagate any SQL Exceptions to the caller after closing any resources opened such as + * ResultSet and Statement objects. */ - public static VectorSchemaRoot sqlToArrow(Connection connection, String query, BaseAllocator allocator, Calendar calendar) throws SQLException, IOException { + public static VectorSchemaRoot sqlToArrow( + Connection connection, + String query, + BaseAllocator allocator, + Calendar calendar) throws SQLException, IOException { Preconditions.checkNotNull(connection, "JDBC connection object can not be null"); Preconditions.checkArgument(query != null && query.length() > 0, "SQL query can not be null or empty"); Preconditions.checkNotNull(allocator, "Memory allocator object can not be null"); @@ -113,8 +122,8 @@ public static VectorSchemaRoot sqlToArrow(Connection connection, String query, B } /** - * For the given JDBC {@link ResultSet}, fetch the data from Relational DB and convert it to Arrow objects. This method - * uses the default RootAllocator and Calendar object. + * For the given JDBC {@link ResultSet}, fetch the data from Relational DB and convert it to Arrow objects. This + * method uses the default RootAllocator and Calendar object. * * @param resultSet * @return Arrow Data Objects {@link VectorSchemaRoot} @@ -134,7 +143,8 @@ public static VectorSchemaRoot sqlToArrow(ResultSet resultSet) throws SQLExcepti * @return Arrow Data Objects {@link VectorSchemaRoot} * @throws SQLException */ - public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, BaseAllocator allocator) throws SQLException, IOException { + public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, BaseAllocator allocator) + throws SQLException, IOException { Preconditions.checkNotNull(resultSet, "JDBC ResultSet object can not be null"); Preconditions.checkNotNull(allocator, "Memory Allocator object can not be null"); @@ -168,7 +178,8 @@ public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, Calendar calendar * @return Arrow Data Objects {@link VectorSchemaRoot} * @throws SQLException */ - public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, BaseAllocator allocator, Calendar calendar) throws SQLException, IOException { + public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, BaseAllocator allocator, Calendar calendar) + throws SQLException, IOException { Preconditions.checkNotNull(resultSet, "JDBC ResultSet object can not be null"); Preconditions.checkNotNull(allocator, "Memory Allocator object can not be null"); Preconditions.checkNotNull(calendar, "Calendar object can not be null"); diff --git a/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrowUtils.java b/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrowUtils.java index 407e8ebf0bf..4cf1e54641d 100644 --- a/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrowUtils.java +++ b/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrowUtils.java @@ -179,7 +179,8 @@ public static Schema jdbcToArrowSchema(ResultSetMetaData rsmd, Calendar calendar fields.add(new Field(columnName, FieldType.nullable(new ArrowType.Time(TimeUnit.MILLISECOND, 32)), null)); break; case Types.TIMESTAMP: - fields.add(new Field(columnName, FieldType.nullable(new ArrowType.Timestamp(TimeUnit.MILLISECOND, calendar.getTimeZone().getID())), null)); + fields.add(new Field(columnName, FieldType.nullable(new ArrowType.Timestamp(TimeUnit.MILLISECOND, + calendar.getTimeZone().getID())), null)); break; case Types.BINARY: case Types.VARBINARY: @@ -226,7 +227,8 @@ private static void allocateVectors(VectorSchemaRoot root, int size) { * @param root Arrow {@link VectorSchemaRoot} object to populate * @throws SQLException */ - public static void jdbcToArrowVectors(ResultSet rs, VectorSchemaRoot root, Calendar calendar) throws SQLException, IOException { + public static void jdbcToArrowVectors(ResultSet rs, VectorSchemaRoot root, Calendar calendar) + throws SQLException, IOException { Preconditions.checkNotNull(rs, "JDBC ResultSet object can't be null"); Preconditions.checkNotNull(root, "JDBC ResultSet object can't be null"); @@ -449,7 +451,11 @@ private static void updateVector(TimeMilliVector timeMilliVector, Time time, boo timeMilliVector.setValueCount(rowCount + 1); } - private static void updateVector(TimeStampVector timeStampVector, Timestamp timestamp, boolean isNonNull, int rowCount) { + private static void updateVector( + TimeStampVector timeStampVector, + Timestamp timestamp, + boolean isNonNull, + int rowCount) { //TODO: Need to handle precision such as milli, micro, nano timeStampVector.setValueCount(rowCount + 1); if (timestamp != null) { @@ -459,7 +465,11 @@ private static void updateVector(TimeStampVector timeStampVector, Timestamp time } } - private static void updateVector(VarBinaryVector varBinaryVector, InputStream is, boolean isNonNull, int rowCount) throws IOException { + private static void updateVector( + VarBinaryVector varBinaryVector, + InputStream is, + boolean isNonNull, + int rowCount) throws IOException { varBinaryVector.setValueCount(rowCount + 1); if (isNonNull && is != null) { VarBinaryHolder holder = new VarBinaryHolder(); @@ -484,7 +494,11 @@ private static void updateVector(VarBinaryVector varBinaryVector, InputStream is } } - private static void updateVector(VarCharVector varcharVector, Clob clob, boolean isNonNull, int rowCount) throws SQLException, IOException { + private static void updateVector( + VarCharVector varcharVector, + Clob clob, + boolean isNonNull, + int rowCount) throws SQLException, IOException { varcharVector.setValueCount(rowCount + 1); if (isNonNull && clob != null) { VarCharHolder holder = new VarCharHolder(); @@ -510,7 +524,8 @@ private static void updateVector(VarCharVector varcharVector, Clob clob, boolean } } - private static void updateVector(VarBinaryVector varBinaryVector, Blob blob, boolean isNonNull, int rowCount) throws SQLException, IOException { + private static void updateVector(VarBinaryVector varBinaryVector, Blob blob, boolean isNonNull, int rowCount) + throws SQLException, IOException { updateVector(varBinaryVector, blob != null ? blob.getBinaryStream() : null, isNonNull, rowCount); } diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/AbstractJdbcToArrowTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/AbstractJdbcToArrowTest.java index d02638e8f52..16c88cab94c 100644 --- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/AbstractJdbcToArrowTest.java +++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/AbstractJdbcToArrowTest.java @@ -93,7 +93,8 @@ public void destroy() throws SQLException { * @throws ClassNotFoundException * @throws IOException */ - public static Object[][] prepareTestData(String[] testFiles, Class clss) throws SQLException, ClassNotFoundException, IOException { + public static Object[][] prepareTestData(String[] testFiles, Class clss) + throws SQLException, ClassNotFoundException, IOException { Object[][] tableArr = new Object[testFiles.length][]; int i = 0; for (String testFile : testFiles) { diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowCharSetTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowCharSetTest.java index 9e542528746..68dc5869e69 100644 --- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowCharSetTest.java +++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowCharSetTest.java @@ -42,8 +42,8 @@ import org.junit.runners.Parameterized.Parameters; /** - * JUnit Test Class which contains methods to test JDBC to Arrow data conversion functionality with UTF-8 Charset, including - * the multi-byte CJK characters for H2 database + * JUnit Test Class which contains methods to test JDBC to Arrow data conversion functionality with UTF-8 Charset, + * including the multi-byte CJK characters for H2 database */ @RunWith(Parameterized.class) public class JdbcToArrowCharSetTest extends AbstractJdbcToArrowTest { @@ -106,13 +106,16 @@ public static Collection getTestData() throws SQLException, ClassNotFo */ @Test public void testJdbcToArroValues() throws SQLException, IOException { - testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); + testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE), + Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE))); - testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), new RootAllocator(Integer.MAX_VALUE), - Calendar.getInstance())); + testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), + new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()))); - testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), new RootAllocator(Integer.MAX_VALUE))); - testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), Calendar.getInstance())); + testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), + new RootAllocator(Integer.MAX_VALUE))); + testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), + Calendar.getInstance())); } /** diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowDataTypesTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowDataTypesTest.java index 3e533adb38f..218fc766318 100644 --- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowDataTypesTest.java +++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowDataTypesTest.java @@ -62,8 +62,8 @@ import org.junit.runners.Parameterized.Parameters; /** - * JUnit Test Class which contains methods to test JDBC to Arrow data conversion functionality with various data types for H2 database - * using multiple test data files + * JUnit Test Class which contains methods to test JDBC to Arrow data conversion functionality with various data types + * for H2 database using multiple test data files */ @RunWith(Parameterized.class) public class JdbcToArrowDataTypesTest extends AbstractJdbcToArrowTest { @@ -133,12 +133,14 @@ public static Collection getTestData() throws SQLException, ClassNotFo */ @Test public void testJdbcToArroValues() throws SQLException, IOException { - testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); + testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE), + Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE))); - testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), new RootAllocator(Integer.MAX_VALUE), - Calendar.getInstance())); + testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), + new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()))); - testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), new RootAllocator(Integer.MAX_VALUE))); + testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), + new RootAllocator(Integer.MAX_VALUE))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), Calendar.getInstance())); } @@ -150,49 +152,63 @@ public void testJdbcToArroValues() throws SQLException, IOException { public void testDataSets(VectorSchemaRoot root) { switch (table.getType()) { case BIGINT: - assertBigIntVectorValues((BigIntVector) root.getVector(table.getVector()), table.getValues().length, table.getLongValues()); + assertBigIntVectorValues((BigIntVector) root.getVector(table.getVector()), table.getValues().length, + table.getLongValues()); break; case BINARY: case BLOB: - assertVarBinaryVectorValues((VarBinaryVector) root.getVector(table.getVector()), table.getValues().length, table.getBinaryValues()); + assertVarBinaryVectorValues((VarBinaryVector) root.getVector(table.getVector()), table.getValues().length, + table.getBinaryValues()); break; case BIT: - assertBitVectorValues((BitVector) root.getVector(table.getVector()), table.getValues().length, table.getIntValues()); + assertBitVectorValues((BitVector) root.getVector(table.getVector()), table.getValues().length, + table.getIntValues()); break; case BOOL: - assertBooleanVectorValues((BitVector) root.getVector(table.getVector()), table.getValues().length, table.getBoolValues()); + assertBooleanVectorValues((BitVector) root.getVector(table.getVector()), table.getValues().length, + table.getBoolValues()); break; case CHAR: case VARCHAR: case CLOB: - assertVarcharVectorValues((VarCharVector) root.getVector(table.getVector()), table.getValues().length, table.getCharValues()); + assertVarcharVectorValues((VarCharVector) root.getVector(table.getVector()), table.getValues().length, + table.getCharValues()); break; case DATE: - assertDateVectorValues((DateMilliVector) root.getVector(table.getVector()), table.getValues().length, table.getLongValues()); + assertDateVectorValues((DateMilliVector) root.getVector(table.getVector()), table.getValues().length, + table.getLongValues()); break; case TIME: - assertTimeVectorValues((TimeMilliVector) root.getVector(table.getVector()), table.getValues().length, table.getLongValues()); + assertTimeVectorValues((TimeMilliVector) root.getVector(table.getVector()), table.getValues().length, + table.getLongValues()); break; case TIMESTAMP: - assertTimeStampVectorValues((TimeStampVector) root.getVector(table.getVector()), table.getValues().length, table.getLongValues()); + assertTimeStampVectorValues((TimeStampVector) root.getVector(table.getVector()), table.getValues().length, + table.getLongValues()); break; case DECIMAL: - assertDecimalVectorValues((DecimalVector) root.getVector(table.getVector()), table.getValues().length, table.getBigDecimalValues()); + assertDecimalVectorValues((DecimalVector) root.getVector(table.getVector()), table.getValues().length, + table.getBigDecimalValues()); break; case DOUBLE: - assertFloat8VectorValues((Float8Vector) root.getVector(table.getVector()), table.getValues().length, table.getDoubleValues()); + assertFloat8VectorValues((Float8Vector) root.getVector(table.getVector()), table.getValues().length, + table.getDoubleValues()); break; case INT: - assertIntVectorValues((IntVector) root.getVector(table.getVector()), table.getValues().length, table.getIntValues()); + assertIntVectorValues((IntVector) root.getVector(table.getVector()), table.getValues().length, + table.getIntValues()); break; case SMALLINT: - assertSmallIntVectorValues((SmallIntVector) root.getVector(table.getVector()), table.getValues().length, table.getIntValues()); + assertSmallIntVectorValues((SmallIntVector) root.getVector(table.getVector()), table.getValues().length, + table.getIntValues()); break; case TINYINT: - assertTinyIntVectorValues((TinyIntVector) root.getVector(table.getVector()), table.getValues().length, table.getIntValues()); + assertTinyIntVectorValues((TinyIntVector) root.getVector(table.getVector()), table.getValues().length, + table.getIntValues()); break; case REAL: - assertFloat4VectorValues((Float4Vector) root.getVector(table.getVector()), table.getValues().length, table.getFloatValues()); + assertFloat4VectorValues((Float4Vector) root.getVector(table.getVector()), table.getValues().length, + table.getFloatValues()); break; } } diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowNullTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowNullTest.java index 7df5278288a..c640057fe6e 100644 --- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowNullTest.java +++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowNullTest.java @@ -49,7 +49,8 @@ import org.junit.runners.Parameterized.Parameters; /** - * JUnit Test Class which contains methods to test JDBC to Arrow data conversion functionality with null values for H2 database + * JUnit Test Class which contains methods to test JDBC to Arrow data conversion functionality with null values for + * H2 database */ @RunWith(Parameterized.class) public class JdbcToArrowNullTest extends AbstractJdbcToArrowTest { @@ -89,12 +90,14 @@ public static Collection getTestData() throws SQLException, ClassNotFo */ @Test public void testJdbcToArroValues() throws SQLException, IOException { - testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); + testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE), + Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE))); - testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), new RootAllocator(Integer.MAX_VALUE), - Calendar.getInstance())); + testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), + new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()))); - testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), new RootAllocator(Integer.MAX_VALUE))); + testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), + new RootAllocator(Integer.MAX_VALUE))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), Calendar.getInstance())); } diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTest.java index f2751d91118..83a2858227d 100644 --- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTest.java +++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTest.java @@ -71,8 +71,8 @@ import org.junit.runners.Parameterized.Parameters; /** - * JUnit Test Class which contains methods to test JDBC to Arrow data conversion functionality with various data types for H2 database - * using single test data file + * JUnit Test Class which contains methods to test JDBC to Arrow data conversion functionality with various data types + * for H2 database using single test data file */ @RunWith(Parameterized.class) public class JdbcToArrowTest extends AbstractJdbcToArrowTest { @@ -124,13 +124,16 @@ public static Collection getTestData() throws SQLException, ClassNotFo */ @Test public void testJdbcToArroValues() throws SQLException, IOException { - testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); + testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE), + Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE))); - testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), new RootAllocator(Integer.MAX_VALUE), - Calendar.getInstance())); + testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), + new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()))); - testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), new RootAllocator(Integer.MAX_VALUE))); - testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), Calendar.getInstance())); + testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), + new RootAllocator(Integer.MAX_VALUE))); + testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), + Calendar.getInstance())); } /** diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTimeZoneTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTimeZoneTest.java index 87003d001ed..c2e2d3cef4b 100644 --- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTimeZoneTest.java +++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTimeZoneTest.java @@ -100,11 +100,11 @@ public static Collection getTestData() throws SQLException, ClassNotFo @Test public void testJdbcToArroValues() throws SQLException, IOException { testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE), - Calendar.getInstance(TimeZone.getTimeZone(table.getTimezone())))); - testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), new RootAllocator(Integer.MAX_VALUE), - Calendar.getInstance(TimeZone.getTimeZone(table.getTimezone())))); + Calendar.getInstance(TimeZone.getTimeZone(table.getTimezone())))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), - Calendar.getInstance(TimeZone.getTimeZone(table.getTimezone())))); + new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance(TimeZone.getTimeZone(table.getTimezone())))); + testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), + Calendar.getInstance(TimeZone.getTimeZone(table.getTimezone())))); } /** @@ -117,17 +117,20 @@ public void testDataSets(VectorSchemaRoot root) { case EST_DATE: case GMT_DATE: case PST_DATE: - assertDateVectorValues((DateMilliVector) root.getVector(table.getVector()), table.getValues().length, table.getLongValues()); + assertDateVectorValues((DateMilliVector) root.getVector(table.getVector()), table.getValues().length, + table.getLongValues()); break; case EST_TIME: case GMT_TIME: case PST_TIME: - assertTimeVectorValues((TimeMilliVector) root.getVector(table.getVector()), table.getValues().length, table.getLongValues()); + assertTimeVectorValues((TimeMilliVector) root.getVector(table.getVector()), table.getValues().length, + table.getLongValues()); break; case EST_TIMESTAMP: case GMT_TIMESTAMP: case PST_TIMESTAMP: - assertTimeStampVectorValues((TimeStampVector) root.getVector(table.getVector()), table.getValues().length, table.getLongValues()); + assertTimeStampVectorValues((TimeStampVector) root.getVector(table.getVector()), table.getValues().length, + table.getLongValues()); break; } } From 41379b2028c4a5481ff03c740b700feef7a1bdfd Mon Sep 17 00:00:00 2001 From: Bryan Cutler Date: Wed, 5 Sep 2018 15:40:36 -0700 Subject: [PATCH 06/10] fixed indentation for arrow-memory --- java/dev/checkstyle/suppressions.xml | 2 +- .../buffer/UnsafeDirectLittleEndian.java | 2 +- .../org/apache/arrow/memory/Accountant.java | 5 +- .../arrow/memory/AllocationManager.java | 8 +-- .../apache/arrow/memory/BaseAllocator.java | 3 +- .../arrow/memory/ValueWithKeyIncluded.java | 2 +- .../arrow/memory/TestBaseAllocator.java | 68 ++++++++----------- .../memory/TestLowCostIdentityHashMap.java | 2 +- 8 files changed, 38 insertions(+), 54 deletions(-) diff --git a/java/dev/checkstyle/suppressions.xml b/java/dev/checkstyle/suppressions.xml index 092037bfde3..cda80921bb7 100644 --- a/java/dev/checkstyle/suppressions.xml +++ b/java/dev/checkstyle/suppressions.xml @@ -34,6 +34,6 @@ diff --git a/java/memory/src/main/java/io/netty/buffer/UnsafeDirectLittleEndian.java b/java/memory/src/main/java/io/netty/buffer/UnsafeDirectLittleEndian.java index ebf0dc96d95..424bc76b62f 100644 --- a/java/memory/src/main/java/io/netty/buffer/UnsafeDirectLittleEndian.java +++ b/java/memory/src/main/java/io/netty/buffer/UnsafeDirectLittleEndian.java @@ -76,7 +76,7 @@ private long addr(int index) { @Override public long getLong(int index) { -// wrapped.checkIndex(index, 8); + // wrapped.checkIndex(index, 8); long v = PlatformDependent.getLong(addr(index)); return v; } diff --git a/java/memory/src/main/java/org/apache/arrow/memory/Accountant.java b/java/memory/src/main/java/org/apache/arrow/memory/Accountant.java index 7a2531e4ae3..4cc2f6d4c6a 100644 --- a/java/memory/src/main/java/org/apache/arrow/memory/Accountant.java +++ b/java/memory/src/main/java/org/apache/arrow/memory/Accountant.java @@ -31,8 +31,6 @@ */ @ThreadSafe class Accountant implements AutoCloseable { - // private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Accountant - // .class); /** * The parent allocator @@ -155,8 +153,7 @@ boolean forceAllocate(long size) { * @param forceAllocation Whether we should force the allocation. * @return The outcome of the allocation. */ - private AllocationOutcome allocate(final long size, final boolean incomingUpdatePeak, final - boolean forceAllocation) { + private AllocationOutcome allocate(final long size, final boolean incomingUpdatePeak, final boolean forceAllocation) { final long newLocal = locallyHeldMemory.addAndGet(size); final long beyondReservation = newLocal - reservation; final boolean beyondLimit = newLocal > allocationLimit.get(); diff --git a/java/memory/src/main/java/org/apache/arrow/memory/AllocationManager.java b/java/memory/src/main/java/org/apache/arrow/memory/AllocationManager.java index e1149774cff..6c2c25dee5b 100644 --- a/java/memory/src/main/java/org/apache/arrow/memory/AllocationManager.java +++ b/java/memory/src/main/java/org/apache/arrow/memory/AllocationManager.java @@ -60,8 +60,6 @@ * contention of acquiring a lock on AllocationManager should be very low. */ public class AllocationManager { - // private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger - // (AllocationManager.class); private static final AtomicLong MANAGER_ID_GENERATOR = new AtomicLong(0); private static final AtomicLong LEDGER_ID_GENERATOR = new AtomicLong(0); @@ -210,10 +208,8 @@ public class BufferLedger implements ValueWithKeyIncluded { // correctly private final long lCreationTime = System.nanoTime(); private final BaseAllocator allocator; - private final HistoricalLog historicalLog = BaseAllocator.DEBUG ? new HistoricalLog - (BaseAllocator.DEBUG_LOG_LENGTH, - "BufferLedger[%d]", 1) - : null; + private final HistoricalLog historicalLog = + BaseAllocator.DEBUG ? new HistoricalLog(BaseAllocator.DEBUG_LOG_LENGTH, "BufferLedger[%d]", 1) : null; private volatile long lDestructionTime = 0; private BufferLedger(BaseAllocator allocator) { diff --git a/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java b/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java index de185cd5a13..c5efb269d03 100644 --- a/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java +++ b/java/memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java @@ -107,8 +107,7 @@ protected BaseAllocator( } - private static String createErrorMsg(final BufferAllocator allocator, final int rounded, final - int requested) { + private static String createErrorMsg(final BufferAllocator allocator, final int rounded, final int requested) { if (rounded != requested) { return String.format( "Unable to allocate buffer of size %d (rounded from %d) due to memory limit. Current " + diff --git a/java/memory/src/main/java/org/apache/arrow/memory/ValueWithKeyIncluded.java b/java/memory/src/main/java/org/apache/arrow/memory/ValueWithKeyIncluded.java index 7bd9cecf970..7a91be32437 100644 --- a/java/memory/src/main/java/org/apache/arrow/memory/ValueWithKeyIncluded.java +++ b/java/memory/src/main/java/org/apache/arrow/memory/ValueWithKeyIncluded.java @@ -22,5 +22,5 @@ * key is part of the value */ public interface ValueWithKeyIncluded { - K getKey(); + K getKey(); } diff --git a/java/memory/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java b/java/memory/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java index 6286faae1b6..7d5008a3938 100644 --- a/java/memory/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java +++ b/java/memory/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java @@ -34,7 +34,7 @@ public class TestBaseAllocator { private final static int MAX_ALLOCATION = 8 * 1024; -/* + /* // ---------------------------------------- DEBUG ----------------------------------- @After @@ -48,13 +48,13 @@ public void checkBuffers() { assertEquals(0, bufferCount); } -// @AfterClass -// public static void dumpBuffers() { -// UnsafeDirectLittleEndian.logBuffers(logger); -// } + // @AfterClass + // public static void dumpBuffers() { + // UnsafeDirectLittleEndian.logBuffers(logger); + // } // ---------------------------------------- DEBUG ------------------------------------ -*/ + */ @Test @@ -88,13 +88,13 @@ public void testRootAllocator_closeWithOutstanding() throws Exception { * We expect there to be one unreleased underlying buffer because we're closing * without releasing it. */ -/* + /* // ------------------------------- DEBUG --------------------------------- final int bufferCount = UnsafeDirectLittleEndian.getBufferCount(); UnsafeDirectLittleEndian.releaseBuffers(); assertEquals(1, bufferCount); // ------------------------------- DEBUG --------------------------------- -*/ + */ } } @@ -149,9 +149,9 @@ public void testAllocator_transferOwnership() throws Exception { public void testAllocator_shareOwnership() throws Exception { try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("shareOwnership1", 0, - MAX_ALLOCATION); + MAX_ALLOCATION); final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("shareOwnership2", 0, - MAX_ALLOCATION); + MAX_ALLOCATION); final ArrowBuf arrowBuf1 = childAllocator1.buffer(MAX_ALLOCATION / 4); rootAllocator.verify(); @@ -170,7 +170,7 @@ public void testAllocator_shareOwnership() throws Exception { rootAllocator.verify(); final BufferAllocator childAllocator3 = rootAllocator.newChildAllocator("shareOwnership3", 0, - MAX_ALLOCATION); + MAX_ALLOCATION); final ArrowBuf arrowBuf3 = arrowBuf1.retain(childAllocator3); assertNotNull(arrowBuf3); assertNotEquals(arrowBuf3, arrowBuf1); @@ -206,7 +206,7 @@ public void testRootAllocator_createChildDontClose() throws Exception { try { try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { final BufferAllocator childAllocator = rootAllocator.newChildAllocator( - "createChildDontClose", 0, MAX_ALLOCATION); + "createChildDontClose", 0, MAX_ALLOCATION); final ArrowBuf arrowBuf = childAllocator.buffer(512); assertNotNull("allocation failed", arrowBuf); } @@ -215,13 +215,13 @@ public void testRootAllocator_createChildDontClose() throws Exception { * We expect one underlying buffer because we closed a child allocator without * releasing the buffer allocated from it. */ -/* + /* // ------------------------------- DEBUG --------------------------------- final int bufferCount = UnsafeDirectLittleEndian.getBufferCount(); UnsafeDirectLittleEndian.releaseBuffers(); assertEquals(1, bufferCount); // ------------------------------- DEBUG --------------------------------- -*/ + */ } } @@ -342,7 +342,7 @@ public void testRootAllocator_listenerAllocationFail() throws Exception { } } - private static void allocateAndFree(final BufferAllocator allocator) { + private static void allocateAndFree(final BufferAllocator allocator) { final ArrowBuf arrowBuf = allocator.buffer(512); assertNotNull("allocation failed", arrowBuf); arrowBuf.release(); @@ -467,7 +467,7 @@ public void testAllocator_createSlices() throws Exception { @Test public void testAllocator_sliceRanges() throws Exception { -// final AllocatorOwner allocatorOwner = new NamedOwner("sliceRanges"); + // final AllocatorOwner allocatorOwner = new NamedOwner("sliceRanges"); try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { // Populate a buffer with byte values corresponding to their indices. @@ -482,8 +482,8 @@ public void testAllocator_sliceRanges() throws Exception { assertEquals(0, slice3.readerIndex()); assertEquals(0, slice3.readableBytes()); assertEquals(0, slice3.writerIndex()); -// assertEquals(256, slice3.capacity()); -// assertEquals(256, slice3.writableBytes()); + // assertEquals(256, slice3.capacity()); + // assertEquals(256, slice3.writableBytes()); for (int i = 0; i < 256; ++i) { arrowBuf.writeByte(i); @@ -511,22 +511,22 @@ public void testAllocator_sliceRanges() throws Exception { assertEquals(i, slice2.readByte()); } -/* + /* for(int i = 256; i > 0; --i) { slice3.writeByte(i - 1); } for(int i = 0; i < 256; ++i) { assertEquals(255 - i, slice1.getByte(i)); } -*/ + */ - arrowBuf.release(); // all the derived buffers share this fate + arrowBuf.release(); // all the derived buffers share this fate } } @Test public void testAllocator_slicesOfSlices() throws Exception { -// final AllocatorOwner allocatorOwner = new NamedOwner("slicesOfSlices"); + // final AllocatorOwner allocatorOwner = new NamedOwner("slicesOfSlices"); try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { // Populate a buffer with byte values corresponding to their indices. @@ -563,10 +563,8 @@ public void testAllocator_slicesOfSlices() throws Exception { @Test public void testAllocator_transferSliced() throws Exception { try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { - final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("transferSliced1", 0, - MAX_ALLOCATION); - final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("transferSliced2", 0, - MAX_ALLOCATION); + final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("transferSliced1", 0, MAX_ALLOCATION); + final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("transferSliced2", 0, MAX_ALLOCATION); final ArrowBuf arrowBuf1 = childAllocator1.buffer(MAX_ALLOCATION / 8); final ArrowBuf arrowBuf2 = childAllocator2.buffer(MAX_ALLOCATION / 8); @@ -597,10 +595,8 @@ public void testAllocator_transferSliced() throws Exception { @Test public void testAllocator_shareSliced() throws Exception { try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { - final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("transferSliced", 0, - MAX_ALLOCATION); - final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("transferSliced", 0, - MAX_ALLOCATION); + final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("transferSliced", 0, MAX_ALLOCATION); + final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("transferSliced", 0, MAX_ALLOCATION); final ArrowBuf arrowBuf1 = childAllocator1.buffer(MAX_ALLOCATION / 8); final ArrowBuf arrowBuf2 = childAllocator2.buffer(MAX_ALLOCATION / 8); @@ -631,12 +627,9 @@ public void testAllocator_shareSliced() throws Exception { @Test public void testAllocator_transferShared() throws Exception { try (final RootAllocator rootAllocator = new RootAllocator(MAX_ALLOCATION)) { - final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("transferShared1", 0, - MAX_ALLOCATION); - final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("transferShared2", 0, - MAX_ALLOCATION); - final BufferAllocator childAllocator3 = rootAllocator.newChildAllocator("transferShared3", 0, - MAX_ALLOCATION); + final BufferAllocator childAllocator1 = rootAllocator.newChildAllocator("transferShared1", 0, MAX_ALLOCATION); + final BufferAllocator childAllocator2 = rootAllocator.newChildAllocator("transferShared2", 0, MAX_ALLOCATION); + final BufferAllocator childAllocator3 = rootAllocator.newChildAllocator("transferShared3", 0, MAX_ALLOCATION); final ArrowBuf arrowBuf1 = childAllocator1.buffer(MAX_ALLOCATION / 8); @@ -664,8 +657,7 @@ public void testAllocator_transferShared() throws Exception { childAllocator2.close(); rootAllocator.verify(); - final BufferAllocator childAllocator4 = rootAllocator.newChildAllocator("transferShared4", 0, - MAX_ALLOCATION); + final BufferAllocator childAllocator4 = rootAllocator.newChildAllocator("transferShared4", 0, MAX_ALLOCATION); TransferResult result2 = arrowBuf3.transferOwnership(childAllocator4); allocationFit = result.allocationFit; final ArrowBuf arrowBuf4 = result2.buffer; diff --git a/java/memory/src/test/java/org/apache/arrow/memory/TestLowCostIdentityHashMap.java b/java/memory/src/test/java/org/apache/arrow/memory/TestLowCostIdentityHashMap.java index 0237b38048f..766407ee46e 100644 --- a/java/memory/src/test/java/org/apache/arrow/memory/TestLowCostIdentityHashMap.java +++ b/java/memory/src/test/java/org/apache/arrow/memory/TestLowCostIdentityHashMap.java @@ -62,7 +62,7 @@ public void testIdentityHashMap() throws Exception { assertNotNull(nextValue); assertTrue((hashMap.get("s1key") == nextValue || hashMap.get("s2key") == nextValue || - hashMap.get("s5key") == nextValue)); + hashMap.get("s5key") == nextValue)); assertTrue(hashMap.containsValue(obj4)); assertTrue(hashMap.containsValue(obj2)); From 989bdbbc11c931f97e455b9c1941c5f4b9a5e86c Mon Sep 17 00:00:00 2001 From: Bryan Cutler Date: Wed, 5 Sep 2018 15:47:43 -0700 Subject: [PATCH 07/10] fixed indentation for arrow-vector --- .../arrow/vector/BaseFixedWidthVector.java | 2 +- .../arrow/vector/BaseVariableWidthVector.java | 4 +- .../org/apache/arrow/vector/BigIntVector.java | 5 +- .../org/apache/arrow/vector/BitVector.java | 49 +++++----- .../apache/arrow/vector/DateDayVector.java | 5 +- .../apache/arrow/vector/DateMilliVector.java | 5 +- .../apache/arrow/vector/DecimalVector.java | 5 +- .../org/apache/arrow/vector/Float4Vector.java | 5 +- .../org/apache/arrow/vector/Float8Vector.java | 5 +- .../org/apache/arrow/vector/IntVector.java | 5 +- .../arrow/vector/IntervalDayVector.java | 5 +- .../arrow/vector/IntervalYearVector.java | 5 +- .../apache/arrow/vector/SmallIntVector.java | 5 +- .../apache/arrow/vector/TimeMicroVector.java | 5 +- .../apache/arrow/vector/TimeMilliVector.java | 5 +- .../apache/arrow/vector/TimeNanoVector.java | 5 +- .../apache/arrow/vector/TimeSecVector.java | 5 +- .../arrow/vector/TimeStampMicroVector.java | 2 +- .../apache/arrow/vector/TimeStampVector.java | 5 +- .../apache/arrow/vector/TinyIntVector.java | 5 +- .../org/apache/arrow/vector/UInt1Vector.java | 5 +- .../org/apache/arrow/vector/UInt2Vector.java | 5 +- .../org/apache/arrow/vector/UInt4Vector.java | 5 +- .../org/apache/arrow/vector/UInt8Vector.java | 5 +- .../org/apache/arrow/vector/VectorLoader.java | 2 +- .../vector/complex/AbstractStructVector.java | 2 +- .../complex/NonNullableStructVector.java | 5 +- .../impl/NullableStructWriterFactory.java | 4 +- .../vector/dictionary/DictionaryEncoder.java | 2 +- .../apache/arrow/vector/ipc/ArrowWriter.java | 6 +- .../arrow/vector/util/MapWithOrdinal.java | 20 ++-- .../apache/arrow/vector/TestBitVector.java | 6 +- .../arrow/vector/TestBitVectorHelper.java | 68 ++++++------- .../arrow/vector/TestFixedSizeListVector.java | 8 +- .../apache/arrow/vector/TestListVector.java | 14 +-- .../arrow/vector/TestSplitAndTransfer.java | 95 +++++++++---------- .../apache/arrow/vector/TestValueVector.java | 6 +- .../apache/arrow/vector/TestVectorReset.java | 2 +- .../complex/impl/TestPromotableWriter.java | 4 +- .../complex/writer/TestComplexWriter.java | 2 +- .../apache/arrow/vector/ipc/BaseFileTest.java | 4 +- .../arrow/vector/ipc/TestArrowFile.java | 8 +- .../arrow/vector/ipc/TestArrowFooter.java | 2 +- .../vector/ipc/TestArrowReaderWriter.java | 2 +- .../apache/arrow/vector/pojo/TestConvert.java | 16 ++-- 45 files changed, 208 insertions(+), 227 deletions(-) diff --git a/java/vector/src/main/java/org/apache/arrow/vector/BaseFixedWidthVector.java b/java/vector/src/main/java/org/apache/arrow/vector/BaseFixedWidthVector.java index 6ae78b1f76c..a13b4a80ada 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/BaseFixedWidthVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/BaseFixedWidthVector.java @@ -275,7 +275,7 @@ public boolean allocateNewSafe() { throw new OversizedAllocationException("Requested amount of memory exceeds limit"); } - /* we are doing a new allocation -- release the current buffers */ + /* we are doing a new allocation -- release the current buffers */ clear(); try { diff --git a/java/vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthVector.java b/java/vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthVector.java index bddb018d874..3eb315beafb 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthVector.java @@ -571,7 +571,7 @@ public int getByteCapacity() { @Override public int getCurrentSizeInBytes() { - /* TODO */ + /* TODO */ return 0; } @@ -599,7 +599,7 @@ public int getBufferSizeFor(final int valueCount) { final int validityBufferSize = getValidityBufferSizeFromCount(valueCount); final int offsetBufferSize = (valueCount + 1) * OFFSET_WIDTH; - /* get the end offset for this valueCount */ + /* get the end offset for this valueCount */ final int dataBufferSize = offsetBuffer.getInt(valueCount * OFFSET_WIDTH); return validityBufferSize + offsetBufferSize + dataBufferSize; } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/BigIntVector.java b/java/vector/src/main/java/org/apache/arrow/vector/BigIntVector.java index 2ba3690dcf2..fa9db5360f4 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/BigIntVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/BigIntVector.java @@ -254,9 +254,8 @@ public void setSafe(int index, BigIntHolder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/BitVector.java b/java/vector/src/main/java/org/apache/arrow/vector/BitVector.java index 87def99866d..822041c35f6 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/BitVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/BitVector.java @@ -143,8 +143,7 @@ public int getBufferSize() { * @param length length of the split. * @param target destination vector */ - public void splitAndTransferTo(int startIndex, int length, - BaseFixedWidthVector target) { + public void splitAndTransferTo(int startIndex, int length, BaseFixedWidthVector target) { compareTypes(target, "splitAndTransferTo"); target.clear(); target.validityBuffer = splitAndTransferBuffer(startIndex, length, target, @@ -155,9 +154,12 @@ public void splitAndTransferTo(int startIndex, int length, target.setValueCount(length); } - private ArrowBuf splitAndTransferBuffer(int startIndex, int length, - BaseFixedWidthVector target, - ArrowBuf sourceBuffer, ArrowBuf destBuffer) { + private ArrowBuf splitAndTransferBuffer( + int startIndex, + int length, + BaseFixedWidthVector target, + ArrowBuf sourceBuffer, + ArrowBuf destBuffer) { assert startIndex + length <= valueCount; int firstByteSource = BitVectorHelper.byteIndex(startIndex); int lastByteSource = BitVectorHelper.byteIndex(valueCount - 1); @@ -166,19 +168,19 @@ private ArrowBuf splitAndTransferBuffer(int startIndex, int length, if (length > 0) { if (offset == 0) { - /* slice */ + /* slice */ if (destBuffer != null) { destBuffer.release(); } destBuffer = sourceBuffer.slice(firstByteSource, byteSizeTarget); destBuffer.retain(1); } else { - /* Copy data - * When the first bit starts from the middle of a byte (offset != 0), - * copy data from src BitVector. - * Each byte in the target is composed by a part in i-th byte, - * another part in (i+1)-th byte. - */ + /* Copy data + * When the first bit starts from the middle of a byte (offset != 0), + * copy data from src BitVector. + * Each byte in the target is composed by a part in i-th byte, + * another part in (i+1)-th byte. + */ destBuffer = allocator.buffer(byteSizeTarget); destBuffer.readerIndex(0); destBuffer.setZero(0, destBuffer.capacity()); @@ -190,15 +192,15 @@ private ArrowBuf splitAndTransferBuffer(int startIndex, int length, destBuffer.setByte(i, (b1 + b2)); } - /* Copying the last piece is done in the following manner: - * if the source vector has 1 or more bytes remaining, we copy - * the last piece as a byte formed by shifting data - * from the current byte and the next byte. - * - * if the source vector has no more bytes remaining - * (we are at the last byte), we copy the last piece as a byte - * by shifting data from the current byte. - */ + /* Copying the last piece is done in the following manner: + * if the source vector has 1 or more bytes remaining, we copy + * the last piece as a byte formed by shifting data + * from the current byte and the next byte. + * + * if the source vector has no more bytes remaining + * (we are at the last byte), we copy the last piece as a byte + * by shifting data from the current byte. + */ if ((firstByteSource + byteSizeTarget - 1) < lastByteSource) { byte b1 = BitVectorHelper.getBitsFromCurrentByte(sourceBuffer, firstByteSource + byteSizeTarget - 1, offset); @@ -408,9 +410,8 @@ public void setSafe(int index, BitHolder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/DateDayVector.java b/java/vector/src/main/java/org/apache/arrow/vector/DateDayVector.java index 7a55a1fcc83..ce541a33e32 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/DateDayVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/DateDayVector.java @@ -255,9 +255,8 @@ public void setSafe(int index, DateDayHolder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/DateMilliVector.java b/java/vector/src/main/java/org/apache/arrow/vector/DateMilliVector.java index aadc6c0f9db..19753652aba 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/DateMilliVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/DateMilliVector.java @@ -259,9 +259,8 @@ public void setSafe(int index, DateMilliHolder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/DecimalVector.java b/java/vector/src/main/java/org/apache/arrow/vector/DecimalVector.java index 897c6e877fc..16780276543 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/DecimalVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/DecimalVector.java @@ -389,9 +389,8 @@ public void setSafe(int index, DecimalHolder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/Float4Vector.java b/java/vector/src/main/java/org/apache/arrow/vector/Float4Vector.java index 5670827990e..138ea3378ec 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/Float4Vector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/Float4Vector.java @@ -255,9 +255,8 @@ public void setSafe(int index, Float4Holder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/Float8Vector.java b/java/vector/src/main/java/org/apache/arrow/vector/Float8Vector.java index cc36b05b617..6d9c20efe0e 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/Float8Vector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/Float8Vector.java @@ -255,9 +255,8 @@ public void setSafe(int index, Float8Holder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/IntVector.java b/java/vector/src/main/java/org/apache/arrow/vector/IntVector.java index f3e4305424e..fb1ce60a052 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/IntVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/IntVector.java @@ -261,9 +261,8 @@ public void setSafe(int index, IntHolder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/IntervalDayVector.java b/java/vector/src/main/java/org/apache/arrow/vector/IntervalDayVector.java index 8303b74c2a8..583c18fa911 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/IntervalDayVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/IntervalDayVector.java @@ -325,9 +325,8 @@ public void setSafe(int index, IntervalDayHolder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/IntervalYearVector.java b/java/vector/src/main/java/org/apache/arrow/vector/IntervalYearVector.java index ed627bbc72a..db97748205f 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/IntervalYearVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/IntervalYearVector.java @@ -286,9 +286,8 @@ public void setSafe(int index, IntervalYearHolder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/SmallIntVector.java b/java/vector/src/main/java/org/apache/arrow/vector/SmallIntVector.java index 09ffd1c5fd0..a66025266fe 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/SmallIntVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/SmallIntVector.java @@ -283,9 +283,8 @@ public void setSafe(int index, SmallIntHolder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/TimeMicroVector.java b/java/vector/src/main/java/org/apache/arrow/vector/TimeMicroVector.java index f8617557750..ae9f26cd628 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/TimeMicroVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/TimeMicroVector.java @@ -255,9 +255,8 @@ public void setSafe(int index, TimeMicroHolder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/TimeMilliVector.java b/java/vector/src/main/java/org/apache/arrow/vector/TimeMilliVector.java index a843c5c48c5..4ea23a302a5 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/TimeMilliVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/TimeMilliVector.java @@ -256,9 +256,8 @@ public void setSafe(int index, TimeMilliHolder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/TimeNanoVector.java b/java/vector/src/main/java/org/apache/arrow/vector/TimeNanoVector.java index 23d764f4203..aeeff00c31b 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/TimeNanoVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/TimeNanoVector.java @@ -255,9 +255,8 @@ public void setSafe(int index, TimeNanoHolder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/TimeSecVector.java b/java/vector/src/main/java/org/apache/arrow/vector/TimeSecVector.java index 3662aec34e1..81669f00b39 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/TimeSecVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/TimeSecVector.java @@ -255,9 +255,8 @@ public void setSafe(int index, TimeSecHolder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/TimeStampMicroVector.java b/java/vector/src/main/java/org/apache/arrow/vector/TimeStampMicroVector.java index b8db2d4d1cd..78219102364 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/TimeStampMicroVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/TimeStampMicroVector.java @@ -111,7 +111,7 @@ public LocalDateTime getObject(int index) { if (isSet(index) == 0) { return null; } else { - /* value is truncated when converting microseconds to milliseconds in order to use DateTime type */ + /* value is truncated when converting microseconds to milliseconds in order to use DateTime type */ final long micros = valueBuffer.getLong(index * TYPE_WIDTH); final long millis = java.util.concurrent.TimeUnit.MICROSECONDS.toMillis(micros); final org.joda.time.LocalDateTime localDateTime = new org.joda.time.LocalDateTime(millis, diff --git a/java/vector/src/main/java/org/apache/arrow/vector/TimeStampVector.java b/java/vector/src/main/java/org/apache/arrow/vector/TimeStampVector.java index c970d30381a..680812ec1f7 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/TimeStampVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/TimeStampVector.java @@ -132,9 +132,8 @@ public void setSafe(int index, long value) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/TinyIntVector.java b/java/vector/src/main/java/org/apache/arrow/vector/TinyIntVector.java index ac390b895f9..e10a63c41af 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/TinyIntVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/TinyIntVector.java @@ -282,9 +282,8 @@ public void setSafe(int index, TinyIntHolder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/UInt1Vector.java b/java/vector/src/main/java/org/apache/arrow/vector/UInt1Vector.java index fa93372cb8d..c83f8309fb4 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/UInt1Vector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/UInt1Vector.java @@ -244,9 +244,8 @@ public void setSafe(int index, UInt1Holder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/UInt2Vector.java b/java/vector/src/main/java/org/apache/arrow/vector/UInt2Vector.java index e4550b17e9e..9c6dbcb99a5 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/UInt2Vector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/UInt2Vector.java @@ -244,9 +244,8 @@ public void setSafe(int index, UInt2Holder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/UInt4Vector.java b/java/vector/src/main/java/org/apache/arrow/vector/UInt4Vector.java index cce1bd493f4..cf2ad8c6e8a 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/UInt4Vector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/UInt4Vector.java @@ -216,9 +216,8 @@ public void setSafe(int index, UInt4Holder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/UInt8Vector.java b/java/vector/src/main/java/org/apache/arrow/vector/UInt8Vector.java index c981048ab3d..ea5bd20cd45 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/UInt8Vector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/UInt8Vector.java @@ -216,9 +216,8 @@ public void setSafe(int index, UInt8Holder holder) { */ public void setNull(int index) { handleSafe(index); - /* not really needed to set the bit to 0 as long as - * the buffer always starts from 0. - */ + // not really needed to set the bit to 0 as long as + // the buffer always starts from 0. BitVectorHelper.setValidityBit(validityBuffer, index, 0); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/VectorLoader.java b/java/vector/src/main/java/org/apache/arrow/vector/VectorLoader.java index d0f85591571..06f3ec649d9 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/VectorLoader.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/VectorLoader.java @@ -90,7 +90,7 @@ private void loadBuffers( if (children.size() > 0) { List childrenFromFields = vector.getChildrenFromFields(); checkArgument(children.size() == childrenFromFields.size(), "should have as many children as in the schema: " + - "found " + childrenFromFields.size() + " expected " + children.size()); + "found " + childrenFromFields.size() + " expected " + children.size()); for (int i = 0; i < childrenFromFields.size(); i++) { Field child = children.get(i); FieldVector fieldVector = childrenFromFields.get(i); diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractStructVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractStructVector.java index c1e2ba055fe..e38492e8ae8 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractStructVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractStructVector.java @@ -137,7 +137,7 @@ public T addOrGet(String childName, FieldType fieldType, return vector; } final String message = "Arrow does not support schema change yet. Existing[%s] and desired[%s] vector types " + - "mismatch"; + "mismatch"; throw new IllegalStateException(String.format(message, existing.getClass().getSimpleName(), clazz.getSimpleName())); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableStructVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableStructVector.java index 621024f02aa..b18767d32de 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableStructVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableStructVector.java @@ -278,6 +278,7 @@ public Object getObject(int index) { @Override public boolean isNull(int index) { return false; } + @Override public int getNullCount() { return 0; } @@ -292,8 +293,8 @@ public int getValueCount() { } public ValueVector getVectorById(int id) { - return getChildByOrdinal(id); -} + return getChildByOrdinal(id); + } @Override public void setValueCount(int valueCount) { diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableStructWriterFactory.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableStructWriterFactory.java index f4cba2348ed..0da98a20034 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableStructWriterFactory.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableStructWriterFactory.java @@ -23,9 +23,9 @@ public class NullableStructWriterFactory { private final boolean caseSensitive; private static final NullableStructWriterFactory nullableStructWriterFactory = - new NullableStructWriterFactory(false); + new NullableStructWriterFactory(false); private static final NullableStructWriterFactory nullableCaseSensitiveWriterFactory = - new NullableStructWriterFactory(true); + new NullableStructWriterFactory(true); public NullableStructWriterFactory(boolean caseSensitive) { this.caseSensitive = caseSensitive; diff --git a/java/vector/src/main/java/org/apache/arrow/vector/dictionary/DictionaryEncoder.java b/java/vector/src/main/java/org/apache/arrow/vector/dictionary/DictionaryEncoder.java index 744cf95ab31..e59f385f0f7 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/dictionary/DictionaryEncoder.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/dictionary/DictionaryEncoder.java @@ -137,7 +137,7 @@ private static void validateType(MinorType type) { // byte arrays don't work as keys in our dictionary map - we could wrap them with something to // implement equals and hashcode if we want that functionality if (type == MinorType.VARBINARY || type == MinorType.FIXEDSIZEBINARY || type == MinorType.LIST || - type == MinorType.STRUCT || type == MinorType.UNION) { + type == MinorType.STRUCT || type == MinorType.UNION) { throw new IllegalArgumentException("Dictionary encoding for complex types not implemented: type " + type); } } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/ipc/ArrowWriter.java b/java/vector/src/main/java/org/apache/arrow/vector/ipc/ArrowWriter.java index 73c6b6f213f..43f1698df5c 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/ipc/ArrowWriter.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/ipc/ArrowWriter.java @@ -85,7 +85,7 @@ protected ArrowWriter(VectorSchemaRoot root, DictionaryProvider provider, Writab FieldVector vector = dictionary.getVector(); int count = vector.getValueCount(); VectorSchemaRoot dictRoot = new VectorSchemaRoot(ImmutableList.of(vector.getField()), ImmutableList.of(vector), - count); + count); VectorUnloader unloader = new VectorUnloader(dictRoot); ArrowRecordBatch batch = unloader.getRecordBatch(); this.dictionaries.add(new ArrowDictionaryBatch(id, batch)); @@ -108,14 +108,14 @@ public void writeBatch() throws IOException { protected ArrowBlock writeDictionaryBatch(ArrowDictionaryBatch batch) throws IOException { ArrowBlock block = MessageSerializer.serialize(out, batch); LOGGER.debug(String.format("DictionaryRecordBatch at %d, metadata: %d, body: %d", - block.getOffset(), block.getMetadataLength(), block.getBodyLength())); + block.getOffset(), block.getMetadataLength(), block.getBodyLength())); return block; } protected ArrowBlock writeRecordBatch(ArrowRecordBatch batch) throws IOException { ArrowBlock block = MessageSerializer.serialize(out, batch); LOGGER.debug(String.format("RecordBatch at %d, metadata: %d, body: %d", - block.getOffset(), block.getMetadataLength(), block.getBodyLength())); + block.getOffset(), block.getMetadataLength(), block.getBodyLength())); return block; } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/util/MapWithOrdinal.java b/java/vector/src/main/java/org/apache/arrow/vector/util/MapWithOrdinal.java index 99fa678ec3c..8e35979949f 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/util/MapWithOrdinal.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/util/MapWithOrdinal.java @@ -136,22 +136,22 @@ public Set keySet() { public Collection values() { return Lists.newArrayList(Iterables.transform(secondary.entries(), new Function, V>() { - @Override - public V apply(IntObjectMap.PrimitiveEntry entry) { - return Preconditions.checkNotNull(entry).value(); - } - })); + @Override + public V apply(IntObjectMap.PrimitiveEntry entry) { + return Preconditions.checkNotNull(entry).value(); + } + })); } @Override public Set> entrySet() { return Sets.newHashSet(Iterables.transform(primary.entrySet(), new Function>, Entry>() { - @Override - public Entry apply(Entry> entry) { - return new AbstractMap.SimpleImmutableEntry<>(entry.getKey(), entry.getValue().getValue()); - } - })); + @Override + public Entry apply(Entry> entry) { + return new AbstractMap.SimpleImmutableEntry<>(entry.getKey(), entry.getValue().getValue()); + } + })); } }; diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestBitVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestBitVector.java index 7cb34eb2e33..2c03bfa997d 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestBitVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestBitVector.java @@ -121,7 +121,7 @@ public void testSplitAndTransfer() throws Exception { int actual = toVector.get(i); int expected = sourceVector.get(start + i); assertEquals("different data values not expected --> sourceVector index: " + (start + i) + - " toVector index: " + i, expected, actual); + " toVector index: " + i, expected, actual); } } } @@ -164,7 +164,7 @@ public void testSplitAndTransfer1() throws Exception { int actual = toVector.get(i); int expected = sourceVector.get(start + i); assertEquals("different data values not expected --> sourceVector index: " + (start + i) + - " toVector index: " + i, expected, actual); + " toVector index: " + i, expected, actual); } } } @@ -215,7 +215,7 @@ public void testSplitAndTransfer2() throws Exception { int actual = toVector.get(i); int expected = sourceVector.get(start + i); assertEquals("different data values not expected --> sourceVector index: " + (start + i) + - " toVector index: " + i, expected, actual); + " toVector index: " + i, expected, actual); } } } diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestBitVectorHelper.java b/java/vector/src/test/java/org/apache/arrow/vector/TestBitVectorHelper.java index bcad284811e..49dc22572b2 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestBitVectorHelper.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestBitVectorHelper.java @@ -26,45 +26,45 @@ import io.netty.buffer.PooledByteBufAllocatorL; public class TestBitVectorHelper { - @Test - public void testGetNullCount() throws Exception { - // test case 1, 1 null value for 0b110 - ArrowBuf validityBuffer = new ArrowBuf( - null, null, new PooledByteBufAllocatorL().empty, - null, null, 0, 3, true); - // we set validity buffer to be 0b10110, but only have 3 items with 1st item is null - validityBuffer.setByte(0, 0b10110); + @Test + public void testGetNullCount() throws Exception { + // test case 1, 1 null value for 0b110 + ArrowBuf validityBuffer = new ArrowBuf( + null, null, new PooledByteBufAllocatorL().empty, + null, null, 0, 3, true); + // we set validity buffer to be 0b10110, but only have 3 items with 1st item is null + validityBuffer.setByte(0, 0b10110); - // we will only consider 0b110 here, since we only 3 items and only one is null - int count = BitVectorHelper.getNullCount(validityBuffer, 3); - assertEquals(count, 1); + // we will only consider 0b110 here, since we only 3 items and only one is null + int count = BitVectorHelper.getNullCount(validityBuffer, 3); + assertEquals(count, 1); - // test case 2, no null value for 0xFF - validityBuffer = new ArrowBuf( - null, null, new PooledByteBufAllocatorL().empty, - null, null, 0, 8, true); - validityBuffer.setByte(0, 0xFF); + // test case 2, no null value for 0xFF + validityBuffer = new ArrowBuf( + null, null, new PooledByteBufAllocatorL().empty, + null, null, 0, 8, true); + validityBuffer.setByte(0, 0xFF); - count = BitVectorHelper.getNullCount(validityBuffer, 8); - assertEquals(count, 0); + count = BitVectorHelper.getNullCount(validityBuffer, 8); + assertEquals(count, 0); - // test case 3, 1 null value for 0x7F - validityBuffer = new ArrowBuf( - null, null, new PooledByteBufAllocatorL().empty, - null, null, 0, 8, true); - validityBuffer.setByte(0, 0x7F); + // test case 3, 1 null value for 0x7F + validityBuffer = new ArrowBuf( + null, null, new PooledByteBufAllocatorL().empty, + null, null, 0, 8, true); + validityBuffer.setByte(0, 0x7F); - count = BitVectorHelper.getNullCount(validityBuffer, 8); - assertEquals(count, 1); + count = BitVectorHelper.getNullCount(validityBuffer, 8); + assertEquals(count, 1); - // test case 4, validity buffer has multiple bytes, 11 items - validityBuffer = new ArrowBuf( - null, null, new PooledByteBufAllocatorL().empty, - null, null, 0, 11, true); - validityBuffer.setByte(0, 0b10101010); - validityBuffer.setByte(1, 0b01010101); + // test case 4, validity buffer has multiple bytes, 11 items + validityBuffer = new ArrowBuf( + null, null, new PooledByteBufAllocatorL().empty, + null, null, 0, 11, true); + validityBuffer.setByte(0, 0b10101010); + validityBuffer.setByte(1, 0b01010101); - count = BitVectorHelper.getNullCount(validityBuffer, 11); - assertEquals(count, 5); - } + count = BitVectorHelper.getNullCount(validityBuffer, 11); + assertEquals(count, 5); + } } diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestFixedSizeListVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestFixedSizeListVector.java index 384a49ee971..0d6f975be5d 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestFixedSizeListVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestFixedSizeListVector.java @@ -80,7 +80,7 @@ public void testIntType() { public void testFloatTypeNullable() { try (FixedSizeListVector vector = FixedSizeListVector.empty("list", 2, allocator)) { Float4Vector nested = (Float4Vector) vector.addOrGetVector(FieldType.nullable(MinorType.FLOAT4.getType())) - .getVector(); + .getVector(); vector.allocateNew(); for (int i = 0; i < 10; i++) { @@ -115,9 +115,9 @@ public void testFloatTypeNullable() { public void testNestedInList() { try (ListVector vector = ListVector.empty("list", allocator)) { FixedSizeListVector tuples = (FixedSizeListVector) vector.addOrGetVector( - FieldType.nullable(new ArrowType.FixedSizeList(2))).getVector(); + FieldType.nullable(new ArrowType.FixedSizeList(2))).getVector(); IntVector innerVector = (IntVector) tuples.addOrGetVector(FieldType.nullable(MinorType.INT.getType())) - .getVector(); + .getVector(); vector.allocateNew(); for (int i = 0; i < 10; i++) { @@ -160,7 +160,7 @@ public void testTransferPair() { try (FixedSizeListVector from = new FixedSizeListVector("from", allocator, 2, null, null); FixedSizeListVector to = new FixedSizeListVector("to", allocator, 2, null, null)) { Float4Vector nested = (Float4Vector) from.addOrGetVector(FieldType.nullable(MinorType.FLOAT4.getType())) - .getVector(); + .getVector(); from.allocateNew(); for (int i = 0; i < 10; i++) { diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestListVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestListVector.java index a5552678d18..82c417086db 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestListVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestListVector.java @@ -515,7 +515,7 @@ public void testNestedListVector() throws Exception { assertEquals(2, resultSet.size()); /* 2 inner lists at index 0 */ assertEquals(3, resultSet.get(0).size()); /* size of first inner list */ - assertEquals(4, resultSet.get(1).size()); /* size of second inner list */ + assertEquals(4, resultSet.get(1).size()); /* size of second inner list */ list = resultSet.get(0); assertEquals(new Long(50), list.get(0)); @@ -528,13 +528,13 @@ public void testNestedListVector() throws Exception { assertEquals(new Long(150), list.get(2)); assertEquals(new Long(175), list.get(3)); - /* get listVector value at index 1 -- the value itself is a listvector */ + /* get listVector value at index 1 -- the value itself is a listvector */ result = listVector.getObject(1); resultSet = (ArrayList>) result; assertEquals(3, resultSet.size()); /* 3 inner lists at index 1 */ assertEquals(1, resultSet.get(0).size()); /* size of first inner list */ - assertEquals(2, resultSet.get(1).size()); /* size of second inner list */ + assertEquals(2, resultSet.get(1).size()); /* size of second inner list */ assertEquals(3, resultSet.get(2).size()); /* size of third inner list */ list = resultSet.get(0); @@ -649,7 +649,7 @@ public void testNestedListVector2() throws Exception { assertEquals(2, resultSet.size()); /* 2 inner lists at index 0 */ assertEquals(3, resultSet.get(0).size()); /* size of first inner list */ - assertEquals(2, resultSet.get(1).size()); /* size of second inner list */ + assertEquals(2, resultSet.get(1).size()); /* size of second inner list */ list = resultSet.get(0); assertEquals(new Long(50), list.get(0)); @@ -660,13 +660,13 @@ public void testNestedListVector2() throws Exception { assertEquals(new Long(75), list.get(0)); assertEquals(new Long(125), list.get(1)); - /* get listVector value at index 1 -- the value itself is a listvector */ + /* get listVector value at index 1 -- the value itself is a listvector */ result = listVector.getObject(1); resultSet = (ArrayList>) result; assertEquals(2, resultSet.size()); /* 3 inner lists at index 1 */ assertEquals(2, resultSet.get(0).size()); /* size of first inner list */ - assertEquals(3, resultSet.get(1).size()); /* size of second inner list */ + assertEquals(3, resultSet.get(1).size()); /* size of second inner list */ list = resultSet.get(0); assertEquals(new Long(15), list.get(0)); @@ -831,7 +831,7 @@ public void testSetInitialCapacity() { public void testClearAndReuse() { try (final ListVector vector = ListVector.empty("list", allocator)) { BigIntVector bigIntVector = - (BigIntVector) vector.addOrGetVector(FieldType.nullable(MinorType.BIGINT.getType())).getVector(); + (BigIntVector) vector.addOrGetVector(FieldType.nullable(MinorType.BIGINT.getType())).getVector(); vector.setInitialCapacity(10); vector.allocateNew(); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestSplitAndTransfer.java b/java/vector/src/test/java/org/apache/arrow/vector/TestSplitAndTransfer.java index 80d5fe19700..dc8abfa6058 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestSplitAndTransfer.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestSplitAndTransfer.java @@ -32,55 +32,54 @@ import org.junit.Test; public class TestSplitAndTransfer { + private BufferAllocator allocator; - private BufferAllocator allocator; - - @Before - public void init() { - allocator = new RootAllocator(Long.MAX_VALUE); - } - - @After - public void terminate() throws Exception { - allocator.close(); - } - - @Test /* VarCharVector */ - public void test() throws Exception { - try(final VarCharVector varCharVector = new VarCharVector("myvector", allocator)) { - varCharVector.allocateNew(10000, 1000); - - final int valueCount = 500; - final String[] compareArray = new String[valueCount]; - - for (int i = 0; i < valueCount; i += 3) { - final String s = String.format("%010d", i); - varCharVector.set(i, s.getBytes()); - compareArray[i] = s; - } - varCharVector.setValueCount(valueCount); - - final TransferPair tp = varCharVector.getTransferPair(allocator); - final VarCharVector newVarCharVector = (VarCharVector) tp.getTo(); - final int[][] startLengths = {{0, 201}, {201, 200}, {401, 99}}; - - for (final int[] startLength : startLengths) { - final int start = startLength[0]; - final int length = startLength[1]; - tp.splitAndTransfer(start, length); - newVarCharVector.setValueCount(length); - for (int i = 0; i < length; i++) { - final boolean expectedSet = ((start + i) % 3) == 0; - if (expectedSet) { - final byte[] expectedValue = compareArray[start + i].getBytes(); - assertFalse(newVarCharVector.isNull(i)); - assertArrayEquals(expectedValue, newVarCharVector.get(i)); - } else { - assertTrue(newVarCharVector.isNull(i)); - } - } - newVarCharVector.clear(); - } + @Before + public void init() { + allocator = new RootAllocator(Long.MAX_VALUE); + } + + @After + public void terminate() throws Exception { + allocator.close(); + } + + @Test /* VarCharVector */ + public void test() throws Exception { + try(final VarCharVector varCharVector = new VarCharVector("myvector", allocator)) { + varCharVector.allocateNew(10000, 1000); + + final int valueCount = 500; + final String[] compareArray = new String[valueCount]; + + for (int i = 0; i < valueCount; i += 3) { + final String s = String.format("%010d", i); + varCharVector.set(i, s.getBytes()); + compareArray[i] = s; + } + varCharVector.setValueCount(valueCount); + + final TransferPair tp = varCharVector.getTransferPair(allocator); + final VarCharVector newVarCharVector = (VarCharVector) tp.getTo(); + final int[][] startLengths = {{0, 201}, {201, 200}, {401, 99}}; + + for (final int[] startLength : startLengths) { + final int start = startLength[0]; + final int length = startLength[1]; + tp.splitAndTransfer(start, length); + newVarCharVector.setValueCount(length); + for (int i = 0; i < length; i++) { + final boolean expectedSet = ((start + i) % 3) == 0; + if (expectedSet) { + final byte[] expectedValue = compareArray[start + i].getBytes(); + assertFalse(newVarCharVector.isNull(i)); + assertArrayEquals(expectedValue, newVarCharVector.get(i)); + } else { + assertTrue(newVarCharVector.isNull(i)); + } } + newVarCharVector.clear(); + } } + } } \ No newline at end of file diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java index 37ad107dc6c..9550aa56959 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java @@ -565,7 +565,7 @@ public void testNullableFixedType1() { /* reset the vector */ vector.reset(); - /* capacity shouldn't change after reset */ + /* capacity shouldn't change after reset */ assertEquals(initialCapacity * 2, vector.getValueCapacity()); /* vector data should be zeroed out */ @@ -816,7 +816,7 @@ public void testNullableFixedType4() { vector.zeroVector(); for (int i = 0; i < vector.getValueCapacity(); i+=2) { - vector.set(i, baseValue + i); + vector.set(i, baseValue + i); } for (int i = 0; i < vector.getValueCapacity(); i++) { @@ -846,7 +846,7 @@ public void testNullableFixedType4() { /* reset the vector */ vector.reset(); - /* capacity shouldn't change after reset */ + /* capacity shouldn't change after reset */ assertEquals(valueCapacity * 4, vector.getValueCapacity()); /* vector data should be zeroed out */ diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java b/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java index fe6b17942fd..969f4205107 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java @@ -125,7 +125,7 @@ public void testStructTypeReset() { // NonNullableStructVector nonNullableStructVector.allocateNewSafe(); IntVector structChild = nonNullableStructVector - .addOrGet("child", FieldType.nullable(new Int(32, true)), IntVector.class); + .addOrGet("child", FieldType.nullable(new Int(32, true)), IntVector.class); structChild.setNull(0); nonNullableStructVector.setValueCount(1); resetVectorAndVerify(nonNullableStructVector, nonNullableStructVector.getBuffers(false)); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestPromotableWriter.java b/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestPromotableWriter.java index beb96f6f50f..992c937449c 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestPromotableWriter.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestPromotableWriter.java @@ -111,9 +111,9 @@ public void testPromoteToUnion() throws Exception { Field childField1 = container.getField().getChildren().get(0).getChildren().get(0); Field childField2 = container.getField().getChildren().get(0).getChildren().get(1); assertEquals("Child field should be union type: " + - childField1.getName(), ArrowTypeID.Union, childField1.getType().getTypeID()); + childField1.getName(), ArrowTypeID.Union, childField1.getType().getTypeID()); assertEquals("Child field should be decimal type: " + - childField2.getName(), ArrowTypeID.Decimal, childField2.getType().getTypeID()); + childField2.getName(), ArrowTypeID.Decimal, childField2.getType().getTypeID()); } } } 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 5689e7512fa..ce5acc644e7 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 @@ -117,7 +117,7 @@ public void transferPairSchemaChange() { private NonNullableStructVector populateStructVector(CallBack callBack) { NonNullableStructVector parent = - new NonNullableStructVector("parent", allocator, new FieldType(false, Struct.INSTANCE, null, null), callBack); + new NonNullableStructVector("parent", allocator, new FieldType(false, Struct.INSTANCE, null, null), callBack); ComplexWriter writer = new ComplexWriterImpl("root", parent); StructWriter rootWriter = writer.rootAsStruct(); IntWriter intWriter = rootWriter.integer("int"); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/ipc/BaseFileTest.java b/java/vector/src/test/java/org/apache/arrow/vector/ipc/BaseFileTest.java index 9c773126886..80da8e73314 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/ipc/BaseFileTest.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/ipc/BaseFileTest.java @@ -296,7 +296,7 @@ protected VectorSchemaRoot writeFlatDictionaryData( vector2.close(); // Done with this vector after encoding List fields = ImmutableList.of(encodedVector1A.getField(), encodedVector1B.getField(), - encodedVector2.getField()); + encodedVector2.getField()); List vectors = ImmutableList.of(encodedVector1A, encodedVector1B, encodedVector2); return new VectorSchemaRoot(fields, vectors, encodedVector1A.getValueCount()); @@ -448,7 +448,7 @@ protected VectorSchemaRoot writeDecimalData(BufferAllocator bufferAllocator) { decimalVector3.setValueCount(count); List fields = ImmutableList.of(decimalVector1.getField(), decimalVector2.getField(), - decimalVector3.getField()); + decimalVector3.getField()); List vectors = ImmutableList.of(decimalVector1, decimalVector2, decimalVector3); return new VectorSchemaRoot(fields, vectors, count); } diff --git a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowFile.java b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowFile.java index bd4f59f719d..ec4aadbdd89 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowFile.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowFile.java @@ -376,7 +376,7 @@ public void testWriteReadMetadata() throws IOException { List childFields = new ArrayList(); childFields.add(new Field("varchar-child", new FieldType(true, ArrowType.Utf8.INSTANCE, null, metadata(1)), null)); childFields.add(new Field("float-child", - new FieldType(true, new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE), null, metadata(2)), null)); + new FieldType(true, new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE), null, metadata(2)), null)); childFields.add(new Field("int-child", new FieldType(false, new ArrowType.Int(32, true), null, metadata(3)), null)); childFields.add(new Field("list-child", new FieldType(true, ArrowType.List.INSTANCE, null, metadata(4)), ImmutableList.of(new Field("l1", FieldType.nullable(new ArrowType.Int(16, true)), null)))); @@ -580,7 +580,7 @@ public void testWriteReadFixedSizeBinary() throws IOException { allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); StructVector parent = StructVector.empty("parent", originalVectorAllocator)) { FixedSizeBinaryVector fixedSizeBinaryVector = parent.addOrGet("fixed-binary", - FieldType.nullable(new FixedSizeBinary(typeWidth)), FixedSizeBinaryVector.class); + FieldType.nullable(new FixedSizeBinary(typeWidth)), FixedSizeBinaryVector.class); parent.allocateNew(); for (int i=0; iemptyList()) )); ArrowFooter footer = - new ArrowFooter(schema, Collections.emptyList(), Collections.emptyList()); + new ArrowFooter(schema, Collections.emptyList(), Collections.emptyList()); ArrowFooter newFooter = roundTrip(footer); assertEquals(footer, newFooter); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowReaderWriter.java b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowReaderWriter.java index 06a2d5c6777..d2dd503b901 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowReaderWriter.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowReaderWriter.java @@ -80,7 +80,7 @@ byte[] array(ArrowBuf buf) { @Test public void test() throws IOException { Schema schema = new Schema(asList(new Field("testField", FieldType.nullable(new ArrowType.Int(8, true)), - Collections.emptyList()))); + Collections.emptyList()))); ArrowType type = schema.getFields().get(0).getType(); FieldVector vector = TestUtils.newVector(FieldVector.class, "testField", type, allocator); vector.initializeChildrenFromFields(schema.getFields().get(0).getChildren()); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/pojo/TestConvert.java b/java/vector/src/test/java/org/apache/arrow/vector/pojo/TestConvert.java index 7f1062b609c..2c4cf369667 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/pojo/TestConvert.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/pojo/TestConvert.java @@ -99,7 +99,7 @@ public void list() throws Exception { Schema tempSchema = Schema.fromJSON(modifiedSchema); FlatBufferBuilder schemaBuilder = new FlatBufferBuilder(); org.apache.arrow.vector.types.pojo.Schema schema = - new org.apache.arrow.vector.types.pojo.Schema(tempSchema.getFields()); + new org.apache.arrow.vector.types.pojo.Schema(tempSchema.getFields()); schemaBuilder.finish(schema.getSchema(schemaBuilder)); Schema finalSchema = Schema.deserialize(ByteBuffer.wrap(schemaBuilder.sizedByteArray())); assertFalse(finalSchema.toString().contains("[DEFAULT]")); @@ -139,12 +139,12 @@ public void nestedSchema() { new Field("child4.1", FieldType.nullable(Utf8.INSTANCE), null) ))); childrenBuilder.add(new Field("child5", FieldType.nullable( - new Union(UnionMode.Sparse, new int[] {MinorType.TIMESTAMPMILLI.ordinal(), MinorType.FLOAT8.ordinal()})), - ImmutableList.of( - new Field("child5.1", FieldType.nullable(new Timestamp(TimeUnit.MILLISECOND, null)), null), - new Field("child5.2", FieldType.nullable(new FloatingPoint(DOUBLE)), ImmutableList.of()), - new Field("child5.3", true, new Timestamp(TimeUnit.MILLISECOND, "UTC"), null) - ))); + new Union(UnionMode.Sparse, new int[] {MinorType.TIMESTAMPMILLI.ordinal(), MinorType.FLOAT8.ordinal()})), + ImmutableList.of( + new Field("child5.1", FieldType.nullable(new Timestamp(TimeUnit.MILLISECOND, null)), null), + new Field("child5.2", FieldType.nullable(new FloatingPoint(DOUBLE)), ImmutableList.of()), + new Field("child5.3", true, new Timestamp(TimeUnit.MILLISECOND, "UTC"), null) + ))); Schema initialSchema = new Schema(childrenBuilder.build()); run(initialSchema); } @@ -161,7 +161,7 @@ private void run(Schema initialSchema) { FlatBufferBuilder builder = new FlatBufferBuilder(); builder.finish(initialSchema.getSchema(builder)); org.apache.arrow.flatbuf.Schema flatBufSchema = - org.apache.arrow.flatbuf.Schema.getRootAsSchema(builder.dataBuffer()); + org.apache.arrow.flatbuf.Schema.getRootAsSchema(builder.dataBuffer()); Schema finalSchema = Schema.convertSchema(flatBufSchema); assertEquals(initialSchema, finalSchema); } From d7277bddd4580cf121a96f84eeb328a6fde211b2 Mon Sep 17 00:00:00 2001 From: Bryan Cutler Date: Wed, 5 Sep 2018 16:09:09 -0700 Subject: [PATCH 08/10] fixed indentation for arrow-tools --- .../test/java/org/apache/arrow/tools/EchoServerTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/java/tools/src/test/java/org/apache/arrow/tools/EchoServerTest.java b/java/tools/src/test/java/org/apache/arrow/tools/EchoServerTest.java index 47b5541d17e..b62a9651fa3 100644 --- a/java/tools/src/test/java/org/apache/arrow/tools/EchoServerTest.java +++ b/java/tools/src/test/java/org/apache/arrow/tools/EchoServerTest.java @@ -186,8 +186,8 @@ public void testFlatDictionary() throws IOException { List vectors = ImmutableList.of((FieldVector) writeVector); VectorSchemaRoot root = new VectorSchemaRoot(fields, vectors, 6); - DictionaryProvider writeProvider = new MapDictionaryProvider(new Dictionary - (writeDictionaryVector, writeEncoding)); + DictionaryProvider writeProvider = new MapDictionaryProvider( + new Dictionary(writeDictionaryVector, writeEncoding)); try (Socket socket = new Socket("localhost", serverPort); ArrowStreamWriter writer = new ArrowStreamWriter(root, writeProvider, socket @@ -262,8 +262,8 @@ public void testNestedDictionary() throws IOException { List vectors = ImmutableList.of((FieldVector) writeVector); VectorSchemaRoot root = new VectorSchemaRoot(fields, vectors, 3); - DictionaryProvider writeProvider = new MapDictionaryProvider(new Dictionary - (writeDictionaryVector, writeEncoding)); + DictionaryProvider writeProvider = new MapDictionaryProvider( + new Dictionary(writeDictionaryVector, writeEncoding)); try (Socket socket = new Socket("localhost", serverPort); ArrowStreamWriter writer = new ArrowStreamWriter(root, writeProvider, socket From ada5b0f674d5a5993a8dd7cd1215937fa38f8473 Mon Sep 17 00:00:00 2001 From: Bryan Cutler Date: Wed, 5 Sep 2018 16:17:18 -0700 Subject: [PATCH 09/10] fixed indentation for arrow-jdbc --- .../arrow/adapter/jdbc/JdbcToArrowUtils.java | 6 +- .../jdbc/h2/JdbcToArrowCharSetTest.java | 22 +++--- .../jdbc/h2/JdbcToArrowDataTypesTest.java | 68 +++++++++---------- .../adapter/jdbc/h2/JdbcToArrowNullTest.java | 10 +-- .../adapter/jdbc/h2/JdbcToArrowTest.java | 8 +-- .../jdbc/h2/JdbcToArrowTimeZoneTest.java | 30 ++++---- 6 files changed, 72 insertions(+), 72 deletions(-) diff --git a/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrowUtils.java b/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrowUtils.java index 4cf1e54641d..4169ec5cfb2 100644 --- a/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrowUtils.java +++ b/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrowUtils.java @@ -180,7 +180,7 @@ public static Schema jdbcToArrowSchema(ResultSetMetaData rsmd, Calendar calendar break; case Types.TIMESTAMP: fields.add(new Field(columnName, FieldType.nullable(new ArrowType.Timestamp(TimeUnit.MILLISECOND, - calendar.getTimeZone().getID())), null)); + calendar.getTimeZone().getID())), null)); break; case Types.BINARY: case Types.VARBINARY: @@ -188,8 +188,8 @@ public static Schema jdbcToArrowSchema(ResultSetMetaData rsmd, Calendar calendar fields.add(new Field(columnName, FieldType.nullable(new ArrowType.Binary()), null)); break; case Types.ARRAY: -// TODO Need to handle this type -// fields.add(new Field("list", FieldType.nullable(new ArrowType.List()), null)); + // TODO Need to handle this type + // fields.add(new Field("list", FieldType.nullable(new ArrowType.List()), null)); break; case Types.CLOB: fields.add(new Field(columnName, FieldType.nullable(new ArrowType.Utf8()), null)); diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowCharSetTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowCharSetTest.java index 68dc5869e69..404daff7a1c 100644 --- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowCharSetTest.java +++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowCharSetTest.java @@ -52,10 +52,10 @@ public class JdbcToArrowCharSetTest extends AbstractJdbcToArrowTest { private static final String CLOB = "CLOB_FIELD15"; private static final String[] testFiles = { - "h2/test1_charset_h2.yml", - "h2/test1_charset_ch_h2.yml", - "h2/test1_charset_jp_h2.yml", - "h2/test1_charset_kr_h2.yml" + "h2/test1_charset_h2.yml", + "h2/test1_charset_ch_h2.yml", + "h2/test1_charset_jp_h2.yml", + "h2/test1_charset_kr_h2.yml" }; /** @@ -107,15 +107,15 @@ public static Collection getTestData() throws SQLException, ClassNotFo @Test public void testJdbcToArroValues() throws SQLException, IOException { testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE), - Calendar.getInstance())); + Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), - new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); + new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), - new RootAllocator(Integer.MAX_VALUE))); + new RootAllocator(Integer.MAX_VALUE))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), - Calendar.getInstance())); + Calendar.getInstance())); } /** @@ -125,12 +125,12 @@ public void testJdbcToArroValues() throws SQLException, IOException { */ public void testDataSets(VectorSchemaRoot root) { assertVarcharVectorValues((VarCharVector) root.getVector(CLOB), table.getRowCount(), - getCharArrayWithCharSet(table.getValues(), CLOB, StandardCharsets.UTF_8)); + getCharArrayWithCharSet(table.getValues(), CLOB, StandardCharsets.UTF_8)); assertVarcharVectorValues((VarCharVector) root.getVector(VARCHAR), table.getRowCount(), - getCharArrayWithCharSet(table.getValues(), VARCHAR, StandardCharsets.UTF_8)); + getCharArrayWithCharSet(table.getValues(), VARCHAR, StandardCharsets.UTF_8)); assertVarcharVectorValues((VarCharVector) root.getVector(CHAR), table.getRowCount(), - getCharArrayWithCharSet(table.getValues(), CHAR, StandardCharsets.UTF_8)); + getCharArrayWithCharSet(table.getValues(), CHAR, StandardCharsets.UTF_8)); } } diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowDataTypesTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowDataTypesTest.java index 218fc766318..9a54305848c 100644 --- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowDataTypesTest.java +++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowDataTypesTest.java @@ -87,23 +87,23 @@ public class JdbcToArrowDataTypesTest extends AbstractJdbcToArrowTest { private static final String VARCHAR = "varchar"; private static final String[] testFiles = { - "h2/test1_bigint_h2.yml", - "h2/test1_binary_h2.yml", - "h2/test1_bit_h2.yml", - "h2/test1_blob_h2.yml", - "h2/test1_bool_h2.yml", - "h2/test1_char_h2.yml", - "h2/test1_clob_h2.yml", - "h2/test1_date_h2.yml", - "h2/test1_decimal_h2.yml", - "h2/test1_double_h2.yml", - "h2/test1_int_h2.yml", - "h2/test1_real_h2.yml", - "h2/test1_smallint_h2.yml", - "h2/test1_time_h2.yml", - "h2/test1_timestamp_h2.yml", - "h2/test1_tinyint_h2.yml", - "h2/test1_varchar_h2.yml" + "h2/test1_bigint_h2.yml", + "h2/test1_binary_h2.yml", + "h2/test1_bit_h2.yml", + "h2/test1_blob_h2.yml", + "h2/test1_bool_h2.yml", + "h2/test1_char_h2.yml", + "h2/test1_clob_h2.yml", + "h2/test1_date_h2.yml", + "h2/test1_decimal_h2.yml", + "h2/test1_double_h2.yml", + "h2/test1_int_h2.yml", + "h2/test1_real_h2.yml", + "h2/test1_smallint_h2.yml", + "h2/test1_time_h2.yml", + "h2/test1_timestamp_h2.yml", + "h2/test1_tinyint_h2.yml", + "h2/test1_varchar_h2.yml" }; /** @@ -134,13 +134,13 @@ public static Collection getTestData() throws SQLException, ClassNotFo @Test public void testJdbcToArroValues() throws SQLException, IOException { testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE), - Calendar.getInstance())); + Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), - new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); + new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), - new RootAllocator(Integer.MAX_VALUE))); + new RootAllocator(Integer.MAX_VALUE))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), Calendar.getInstance())); } @@ -153,62 +153,62 @@ public void testDataSets(VectorSchemaRoot root) { switch (table.getType()) { case BIGINT: assertBigIntVectorValues((BigIntVector) root.getVector(table.getVector()), table.getValues().length, - table.getLongValues()); + table.getLongValues()); break; case BINARY: case BLOB: assertVarBinaryVectorValues((VarBinaryVector) root.getVector(table.getVector()), table.getValues().length, - table.getBinaryValues()); + table.getBinaryValues()); break; case BIT: assertBitVectorValues((BitVector) root.getVector(table.getVector()), table.getValues().length, - table.getIntValues()); + table.getIntValues()); break; case BOOL: assertBooleanVectorValues((BitVector) root.getVector(table.getVector()), table.getValues().length, - table.getBoolValues()); + table.getBoolValues()); break; case CHAR: case VARCHAR: case CLOB: assertVarcharVectorValues((VarCharVector) root.getVector(table.getVector()), table.getValues().length, - table.getCharValues()); + table.getCharValues()); break; case DATE: assertDateVectorValues((DateMilliVector) root.getVector(table.getVector()), table.getValues().length, - table.getLongValues()); + table.getLongValues()); break; case TIME: assertTimeVectorValues((TimeMilliVector) root.getVector(table.getVector()), table.getValues().length, - table.getLongValues()); + table.getLongValues()); break; case TIMESTAMP: assertTimeStampVectorValues((TimeStampVector) root.getVector(table.getVector()), table.getValues().length, - table.getLongValues()); + table.getLongValues()); break; case DECIMAL: assertDecimalVectorValues((DecimalVector) root.getVector(table.getVector()), table.getValues().length, - table.getBigDecimalValues()); + table.getBigDecimalValues()); break; case DOUBLE: assertFloat8VectorValues((Float8Vector) root.getVector(table.getVector()), table.getValues().length, - table.getDoubleValues()); + table.getDoubleValues()); break; case INT: assertIntVectorValues((IntVector) root.getVector(table.getVector()), table.getValues().length, - table.getIntValues()); + table.getIntValues()); break; case SMALLINT: assertSmallIntVectorValues((SmallIntVector) root.getVector(table.getVector()), table.getValues().length, - table.getIntValues()); + table.getIntValues()); break; case TINYINT: assertTinyIntVectorValues((TinyIntVector) root.getVector(table.getVector()), table.getValues().length, - table.getIntValues()); + table.getIntValues()); break; case REAL: assertFloat4VectorValues((Float4Vector) root.getVector(table.getVector()), table.getValues().length, - table.getFloatValues()); + table.getFloatValues()); break; } } diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowNullTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowNullTest.java index c640057fe6e..96939875a29 100644 --- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowNullTest.java +++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowNullTest.java @@ -59,8 +59,8 @@ public class JdbcToArrowNullTest extends AbstractJdbcToArrowTest { private static final String SELECTED_NULL_COLUMN = "selected_null_column"; private static final String[] testFiles = { - "h2/test1_all_datatypes_null_h2.yml", - "h2/test1_selected_datatypes_null_h2.yml" + "h2/test1_all_datatypes_null_h2.yml", + "h2/test1_selected_datatypes_null_h2.yml" }; /** @@ -91,13 +91,13 @@ public static Collection getTestData() throws SQLException, ClassNotFo @Test public void testJdbcToArroValues() throws SQLException, IOException { testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE), - Calendar.getInstance())); + Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), - new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); + new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), - new RootAllocator(Integer.MAX_VALUE))); + new RootAllocator(Integer.MAX_VALUE))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), Calendar.getInstance())); } diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTest.java index 83a2858227d..381ace46c32 100644 --- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTest.java +++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTest.java @@ -125,15 +125,15 @@ public static Collection getTestData() throws SQLException, ClassNotFo @Test public void testJdbcToArroValues() throws SQLException, IOException { testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE), - Calendar.getInstance())); + Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), - new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); + new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance())); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), - new RootAllocator(Integer.MAX_VALUE))); + new RootAllocator(Integer.MAX_VALUE))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), - Calendar.getInstance())); + Calendar.getInstance())); } /** diff --git a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTimeZoneTest.java b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTimeZoneTest.java index c2e2d3cef4b..559288ee1af 100644 --- a/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTimeZoneTest.java +++ b/java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/h2/JdbcToArrowTimeZoneTest.java @@ -60,15 +60,15 @@ public class JdbcToArrowTimeZoneTest extends AbstractJdbcToArrowTest { private static final String PST_TIMESTAMP = "pst_timestamp"; private static final String[] testFiles = { - "h2/test1_est_date_h2.yml", - "h2/test1_est_time_h2.yml", - "h2/test1_est_timestamp_h2.yml", - "h2/test1_gmt_date_h2.yml", - "h2/test1_gmt_time_h2.yml", - "h2/test1_gmt_timestamp_h2.yml", - "h2/test1_pst_date_h2.yml", - "h2/test1_pst_time_h2.yml", - "h2/test1_pst_timestamp_h2.yml" + "h2/test1_est_date_h2.yml", + "h2/test1_est_time_h2.yml", + "h2/test1_est_timestamp_h2.yml", + "h2/test1_gmt_date_h2.yml", + "h2/test1_gmt_time_h2.yml", + "h2/test1_gmt_timestamp_h2.yml", + "h2/test1_pst_date_h2.yml", + "h2/test1_pst_time_h2.yml", + "h2/test1_pst_timestamp_h2.yml" }; /** @@ -100,11 +100,11 @@ public static Collection getTestData() throws SQLException, ClassNotFo @Test public void testJdbcToArroValues() throws SQLException, IOException { testDataSets(JdbcToArrow.sqlToArrow(conn, table.getQuery(), new RootAllocator(Integer.MAX_VALUE), - Calendar.getInstance(TimeZone.getTimeZone(table.getTimezone())))); + Calendar.getInstance(TimeZone.getTimeZone(table.getTimezone())))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), - new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance(TimeZone.getTimeZone(table.getTimezone())))); + new RootAllocator(Integer.MAX_VALUE), Calendar.getInstance(TimeZone.getTimeZone(table.getTimezone())))); testDataSets(JdbcToArrow.sqlToArrow(conn.createStatement().executeQuery(table.getQuery()), - Calendar.getInstance(TimeZone.getTimeZone(table.getTimezone())))); + Calendar.getInstance(TimeZone.getTimeZone(table.getTimezone())))); } /** @@ -118,19 +118,19 @@ public void testDataSets(VectorSchemaRoot root) { case GMT_DATE: case PST_DATE: assertDateVectorValues((DateMilliVector) root.getVector(table.getVector()), table.getValues().length, - table.getLongValues()); + table.getLongValues()); break; case EST_TIME: case GMT_TIME: case PST_TIME: assertTimeVectorValues((TimeMilliVector) root.getVector(table.getVector()), table.getValues().length, - table.getLongValues()); + table.getLongValues()); break; case EST_TIMESTAMP: case GMT_TIMESTAMP: case PST_TIMESTAMP: assertTimeStampVectorValues((TimeStampVector) root.getVector(table.getVector()), table.getValues().length, - table.getLongValues()); + table.getLongValues()); break; } } From 59396db0d0e1e7847947800f7c23adac36286b59 Mon Sep 17 00:00:00 2001 From: Bryan Cutler Date: Wed, 5 Sep 2018 16:18:48 -0700 Subject: [PATCH 10/10] fixed indentation for arrow-plasma --- .../apache/arrow/plasma/PlasmaClientTest.java | 246 +++++++++--------- 1 file changed, 123 insertions(+), 123 deletions(-) diff --git a/java/plasma/src/test/java/org/apache/arrow/plasma/PlasmaClientTest.java b/java/plasma/src/test/java/org/apache/arrow/plasma/PlasmaClientTest.java index 6b67fc8c930..c6df5722675 100644 --- a/java/plasma/src/test/java/org/apache/arrow/plasma/PlasmaClientTest.java +++ b/java/plasma/src/test/java/org/apache/arrow/plasma/PlasmaClientTest.java @@ -26,148 +26,148 @@ public class PlasmaClientTest { - private String storeSuffix = "/tmp/store"; + private String storeSuffix = "/tmp/store"; - private Process storeProcess; + private Process storeProcess; - private int storePort; + private int storePort; - private ObjectStoreLink pLink; + private ObjectStoreLink pLink; - public PlasmaClientTest() throws Exception{ - try { - String plasmaStorePath = System.getenv("PLASMA_STORE"); - if(plasmaStorePath == null) { - throw new Exception("Please set plasma store path in env PLASMA_STORE"); - } - - this.startObjectStore(plasmaStorePath); - System.loadLibrary("plasma_java"); - pLink = new PlasmaClient(this.getStoreAddress(), "", 0); - } - catch (Throwable t) { - cleanup(); - throw t; - } + public PlasmaClientTest() throws Exception{ + try { + String plasmaStorePath = System.getenv("PLASMA_STORE"); + if(plasmaStorePath == null) { + throw new Exception("Please set plasma store path in env PLASMA_STORE"); + } + this.startObjectStore(plasmaStorePath); + System.loadLibrary("plasma_java"); + pLink = new PlasmaClient(this.getStoreAddress(), "", 0); } - - private Process startProcess(String[] cmd) { - ProcessBuilder builder; - List newCmd = Arrays.stream(cmd).filter(s -> s.length() > 0).collect(Collectors.toList()); - builder = new ProcessBuilder(newCmd); - Process p = null; - try { - p = builder.start(); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - System.out.println("Start process " + p.hashCode() + " OK, cmd = " + Arrays.toString(cmd).replace(',', ' ')); - return p; + catch (Throwable t) { + cleanup(); + throw t; } - private void startObjectStore(String plasmaStorePath) { - int occupiedMemoryMB = 10; - long memoryBytes = occupiedMemoryMB * 1000000; - int numRetries = 10; - Process p = null; - while (numRetries-- > 0) { - int currentPort = java.util.concurrent.ThreadLocalRandom.current().nextInt(0, 100000); - String name = storeSuffix + currentPort; - String cmd = plasmaStorePath + " -s " + name + " -m " + memoryBytes; - - p = startProcess(cmd.split(" ")); - - if (p != null && p.isAlive()) { - try { - TimeUnit.MILLISECONDS.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (p.isAlive()) { - storePort = currentPort; - break; - } - } - } - - - if (p == null || !p.isAlive()) { - throw new RuntimeException("Start object store failed ..."); - } else { - storeProcess = p; - System.out.println("Start object store success"); - } + } + + private Process startProcess(String[] cmd) { + ProcessBuilder builder; + List newCmd = Arrays.stream(cmd).filter(s -> s.length() > 0).collect(Collectors.toList()); + builder = new ProcessBuilder(newCmd); + Process p = null; + try { + p = builder.start(); + } catch (IOException e) { + e.printStackTrace(); + return null; } - - private void cleanup() { - if (storeProcess != null && killProcess(storeProcess)) { - System.out.println("Kill plasma store process forcely"); + System.out.println("Start process " + p.hashCode() + " OK, cmd = " + Arrays.toString(cmd).replace(',', ' ')); + return p; + } + + private void startObjectStore(String plasmaStorePath) { + int occupiedMemoryMB = 10; + long memoryBytes = occupiedMemoryMB * 1000000; + int numRetries = 10; + Process p = null; + while (numRetries-- > 0) { + int currentPort = java.util.concurrent.ThreadLocalRandom.current().nextInt(0, 100000); + String name = storeSuffix + currentPort; + String cmd = plasmaStorePath + " -s " + name + " -m " + memoryBytes; + + p = startProcess(cmd.split(" ")); + + if (p != null && p.isAlive()) { + try { + TimeUnit.MILLISECONDS.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); } - } - - private static boolean killProcess(Process p) { if (p.isAlive()) { - p.destroyForcibly(); - return true; - } else { - return false; + storePort = currentPort; + break; } + } } - public void doTest() { - System.out.println("Start test."); - int timeoutMs = 3000; - byte[] id1 = new byte[20]; - Arrays.fill(id1, (byte)1); - byte[] value1 = new byte[20]; - Arrays.fill(value1, (byte)11); - pLink.put(id1, value1, null); - - byte[] id2 = new byte[20]; - Arrays.fill(id2, (byte)2); - byte[] value2 = new byte[20]; - Arrays.fill(value2, (byte)12); - pLink.put(id2, value2, null); - System.out.println("Plasma java client put test success."); - byte[] getValue1 = pLink.get(id1, timeoutMs, false); - assert Arrays.equals(value1, getValue1); - - byte[] getValue2 = pLink.get(id2, timeoutMs, false); - assert Arrays.equals(value2, getValue2); - System.out.println("Plasma java client get single object test success."); - byte[][] ids = {id1, id2}; - List values = pLink.get(ids, timeoutMs, false); - assert Arrays.equals(values.get(0), value1); - assert Arrays.equals(values.get(1), value2); - System.out.println("Plasma java client get multi-object test success."); - pLink.put(id1, value1, null); - System.out.println("Plasma java client put same object twice exception test success."); - byte[] id1Hash = pLink.hash(id1); - assert id1Hash != null; - System.out.println("Plasma java client hash test success."); - boolean exsit = pLink.contains(id2); - assert exsit; - byte[] id3 = new byte[20]; - Arrays.fill(id3, (byte)3); - boolean notExsit = pLink.contains(id3); - assert !notExsit; - System.out.println("Plasma java client contains test success."); - cleanup(); - System.out.println("All test success."); + if (p == null || !p.isAlive()) { + throw new RuntimeException("Start object store failed ..."); + } else { + storeProcess = p; + System.out.println("Start object store success"); } + } - public String getStoreAddress() { - return storeSuffix+storePort; + private void cleanup() { + if (storeProcess != null && killProcess(storeProcess)) { + System.out.println("Kill plasma store process forcely"); } - public static void main(String[] args) throws Exception { - - PlasmaClientTest plasmaClientTest = new PlasmaClientTest(); - plasmaClientTest.doTest(); - + } + + private static boolean killProcess(Process p) { + if (p.isAlive()) { + p.destroyForcibly(); + return true; + } else { + return false; } + } + + public void doTest() { + System.out.println("Start test."); + int timeoutMs = 3000; + byte[] id1 = new byte[20]; + Arrays.fill(id1, (byte)1); + byte[] value1 = new byte[20]; + Arrays.fill(value1, (byte)11); + pLink.put(id1, value1, null); + + byte[] id2 = new byte[20]; + Arrays.fill(id2, (byte)2); + byte[] value2 = new byte[20]; + Arrays.fill(value2, (byte)12); + pLink.put(id2, value2, null); + System.out.println("Plasma java client put test success."); + byte[] getValue1 = pLink.get(id1, timeoutMs, false); + assert Arrays.equals(value1, getValue1); + + byte[] getValue2 = pLink.get(id2, timeoutMs, false); + assert Arrays.equals(value2, getValue2); + System.out.println("Plasma java client get single object test success."); + byte[][] ids = {id1, id2}; + List values = pLink.get(ids, timeoutMs, false); + assert Arrays.equals(values.get(0), value1); + assert Arrays.equals(values.get(1), value2); + System.out.println("Plasma java client get multi-object test success."); + pLink.put(id1, value1, null); + System.out.println("Plasma java client put same object twice exception test success."); + byte[] id1Hash = pLink.hash(id1); + assert id1Hash != null; + System.out.println("Plasma java client hash test success."); + boolean exsit = pLink.contains(id2); + assert exsit; + byte[] id3 = new byte[20]; + Arrays.fill(id3, (byte)3); + boolean notExsit = pLink.contains(id3); + assert !notExsit; + System.out.println("Plasma java client contains test success."); + cleanup(); + System.out.println("All test success."); + + } + + public String getStoreAddress() { + return storeSuffix+storePort; + } + public static void main(String[] args) throws Exception { + + PlasmaClientTest plasmaClientTest = new PlasmaClientTest(); + plasmaClientTest.doTest(); + + } }