diff --git a/java/vector/src/main/java/org/apache/arrow/vector/compare/TypeEqualsVisitor.java b/java/vector/src/main/java/org/apache/arrow/vector/compare/TypeEqualsVisitor.java index ce9cb117ed81f..ae49e5380bea3 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/compare/TypeEqualsVisitor.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/compare/TypeEqualsVisitor.java @@ -62,15 +62,8 @@ public TypeEqualsVisitor(ValueVector right, boolean checkName, boolean checkMeta } /** Check type equals without passing IN param in VectorVisitor. */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof ValueVector)) { - return false; - } - ValueVector left = (ValueVector) obj; + @SuppressWarnings("NonOverridingEquals") + public boolean equals(ValueVector left) { return left.accept(this, null); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/util/VectorAppender.java b/java/vector/src/main/java/org/apache/arrow/vector/util/VectorAppender.java index 9dcf95d8a8147..f97310ac736cf 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/util/VectorAppender.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/util/VectorAppender.java @@ -252,7 +252,6 @@ public ValueVector visit(BaseVariableWidthViewVector left, Void value) { } @Override - @SuppressWarnings("EqualsIncompatibleType") public ValueVector visit(ListVector deltaVector, Void value) { Preconditions.checkArgument( typeVisitor.equals(deltaVector), @@ -322,7 +321,6 @@ public ValueVector visit(ListVector deltaVector, Void value) { } @Override - @SuppressWarnings("EqualsIncompatibleType") public ValueVector visit(LargeListVector deltaVector, Void value) { Preconditions.checkArgument( typeVisitor.equals(deltaVector), @@ -394,7 +392,6 @@ public ValueVector visit(LargeListVector deltaVector, Void value) { } @Override - @SuppressWarnings("EqualsIncompatibleType") public ValueVector visit(FixedSizeListVector deltaVector, Void value) { Preconditions.checkArgument( typeVisitor.equals(deltaVector), @@ -441,7 +438,6 @@ public ValueVector visit(FixedSizeListVector deltaVector, Void value) { } @Override - @SuppressWarnings("EqualsIncompatibleType") public ValueVector visit(NonNullableStructVector deltaVector, Void value) { Preconditions.checkArgument( typeVisitor.equals(deltaVector), diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestPeriodDuration.java b/java/vector/src/test/java/org/apache/arrow/vector/TestPeriodDuration.java index 37f59f82cbd2f..6b1d8324f9200 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestPeriodDuration.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestPeriodDuration.java @@ -54,19 +54,19 @@ public void testToISO8601IntervalString() { new PeriodDuration(Period.ZERO, Duration.ofNanos(123)).toISO8601IntervalString()); assertEquals( "PT1.000000123S", - new PeriodDuration(Period.ZERO, Duration.ofSeconds(1).withNanos(123)) + new PeriodDuration(Period.ZERO, Duration.ofSeconds(Duration.ofSeconds(1).getSeconds(), 123)) .toISO8601IntervalString()); assertEquals( "PT1H1.000000123S", - new PeriodDuration(Period.ZERO, Duration.ofSeconds(3601).withNanos(123)) + new PeriodDuration(Period.ZERO, Duration.ofSeconds(Duration.ofSeconds(3601).getSeconds(), 123)) .toISO8601IntervalString()); assertEquals( "PT24H1M1.000000123S", - new PeriodDuration(Period.ZERO, Duration.ofSeconds(86461).withNanos(123)) + new PeriodDuration(Period.ZERO, Duration.ofSeconds(Duration.ofSeconds(86461).getSeconds(), 123)) .toISO8601IntervalString()); assertEquals( "P1Y2M3DT24H1M1.000000123S", - new PeriodDuration(Period.of(1, 2, 3), Duration.ofSeconds(86461).withNanos(123)) + new PeriodDuration(Period.of(1, 2, 3), Duration.ofSeconds(Duration.ofSeconds(86461).getSeconds(), 123)) .toISO8601IntervalString()); assertEquals( @@ -77,11 +77,11 @@ public void testToISO8601IntervalString() { new PeriodDuration(Period.ZERO, Duration.ofNanos(-123)).toISO8601IntervalString()); assertEquals( "PT-24H-1M-0.999999877S", - new PeriodDuration(Period.ZERO, Duration.ofSeconds(-86461).withNanos(123)) + new PeriodDuration(Period.ZERO, Duration.ofSeconds(Duration.ofSeconds(-86461).getSeconds(), 123)) .toISO8601IntervalString()); assertEquals( "P-1Y-2M-3DT-0.999999877S", - new PeriodDuration(Period.of(-1, -2, -3), Duration.ofSeconds(-1).withNanos(123)) + new PeriodDuration(Period.of(-1, -2, -3), Duration.ofSeconds(Duration.ofSeconds(-1).getSeconds(), 123)) .toISO8601IntervalString()); } @@ -95,8 +95,7 @@ public void testTemporalAccessor() { PeriodDuration pd2 = new PeriodDuration(Period.ZERO, Duration.ofMinutes(1)); assertEquals(LocalDateTime.of(2024, 1, 2, 3, 3), pd2.subtractFrom(dateTime)); - PeriodDuration pd3 = - new PeriodDuration(Period.of(1, 2, 3), Duration.ofSeconds(86461).withNanos(123)); + PeriodDuration pd3 = new PeriodDuration(Period.of(1, 2, 3), Duration.ofSeconds(Duration.ofSeconds(86461).getSeconds(), 123)); assertEquals(pd3.get(ChronoUnit.YEARS), 1); assertEquals(pd3.get(ChronoUnit.MONTHS), 2); assertEquals(pd3.get(ChronoUnit.DAYS), 3); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestTypeLayout.java b/java/vector/src/test/java/org/apache/arrow/vector/TestTypeLayout.java index 75c6df1d6a496..d56487d8763b2 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestTypeLayout.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestTypeLayout.java @@ -18,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; +import java.nio.charset.StandardCharsets; import java.util.Random; import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.RootAllocator; @@ -175,12 +176,12 @@ public void testTypeBufferCountInVectorsWithVariadicBuffers() { try (ViewVarCharVector viewVarCharVector = new ViewVarCharVector("myvector", allocator)) { viewVarCharVector.allocateNew(32, 6); - viewVarCharVector.setSafe(0, generateRandomString(8).getBytes()); - viewVarCharVector.setSafe(1, generateRandomString(12).getBytes()); - viewVarCharVector.setSafe(2, generateRandomString(14).getBytes()); - viewVarCharVector.setSafe(3, generateRandomString(18).getBytes()); - viewVarCharVector.setSafe(4, generateRandomString(22).getBytes()); - viewVarCharVector.setSafe(5, generateRandomString(24).getBytes()); + viewVarCharVector.setSafe(0, generateRandomString(8).getBytes(StandardCharsets.UTF_8)); + viewVarCharVector.setSafe(1, generateRandomString(12).getBytes(StandardCharsets.UTF_8)); + viewVarCharVector.setSafe(2, generateRandomString(14).getBytes(StandardCharsets.UTF_8)); + viewVarCharVector.setSafe(3, generateRandomString(18).getBytes(StandardCharsets.UTF_8)); + viewVarCharVector.setSafe(4, generateRandomString(22).getBytes(StandardCharsets.UTF_8)); + viewVarCharVector.setSafe(5, generateRandomString(24).getBytes(StandardCharsets.UTF_8)); viewVarCharVector.setValueCount(6); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestUnionVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestUnionVector.java index 6c05073c16844..972c2c62cba94 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestUnionVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestUnionVector.java @@ -381,6 +381,7 @@ public void testSplitAndTransferWithMixedVectors() throws Exception { } @Test + @SuppressWarnings("EnumOrdinal") public void testGetFieldTypeInfo() throws Exception { Map metadata = new HashMap<>(); metadata.put("key1", "value1"); 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 83e470ae2581d..9220e4c6c911c 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 @@ -1908,7 +1908,7 @@ public void testSetSafeWithArrowBufNoExcessAllocs() { } fromVector.setValueCount(numValues); ArrowBuf fromDataBuffer = fromVector.getDataBuffer(); - assertTrue(numValues * valueBytesLength <= fromDataBuffer.capacity()); + assertTrue((long) numValues * valueBytesLength <= fromDataBuffer.capacity()); /* * Copy the entries one-by-one from 'fromVector' to 'toVector', but use the setSafe with @@ -2398,11 +2398,11 @@ public void testMultipleClose() { */ public static void setBytes(int index, byte[] bytes, VarCharVector vector) { final int currentOffset = - vector.offsetBuffer.getInt(index * BaseVariableWidthVector.OFFSET_WIDTH); + vector.offsetBuffer.getInt((long) index * BaseVariableWidthVector.OFFSET_WIDTH); BitVectorHelper.setBit(vector.validityBuffer, index); vector.offsetBuffer.setInt( - (index + 1) * BaseVariableWidthVector.OFFSET_WIDTH, currentOffset + bytes.length); + (long) (index + 1) * BaseVariableWidthVector.OFFSET_WIDTH, currentOffset + bytes.length); vector.valueBuffer.setBytes(currentOffset, bytes, 0, bytes.length); } @@ -2669,8 +2669,8 @@ public void testGetPointerVariableWidth() { try (VarCharVector vec1 = new VarCharVector("vec1", allocator); VarCharVector vec2 = new VarCharVector("vec2", allocator)) { - vec1.allocateNew(sampleData.length * 10, sampleData.length); - vec2.allocateNew(sampleData.length * 10, sampleData.length); + vec1.allocateNew(sampleData.length * 10L, sampleData.length); + vec2.allocateNew(sampleData.length * 10L, sampleData.length); for (int i = 0; i < sampleData.length; i++) { String str = sampleData[i]; diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestValueVectorIterable.java b/java/vector/src/test/java/org/apache/arrow/vector/TestValueVectorIterable.java index e6b79e89b9942..3d75b56640b71 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestValueVectorIterable.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestValueVectorIterable.java @@ -172,7 +172,7 @@ public void testDurationVectorIterable() { durationVector.setSafe(2, 555); durationVector.setValueCount(3); - final Duration value1 = Duration.ofMillis(30000); + final Duration value1 = Duration.ofSeconds(30); final Duration value3 = Duration.ofMillis(555); assertThat( durationVector.getValueIterable(), diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestVarCharViewVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestVarCharViewVector.java index 308431fdeb9cf..d418fa92ca9e9 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestVarCharViewVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestVarCharViewVector.java @@ -544,7 +544,7 @@ public void testSetSafeWithArrowBufNoExcessAllocs() { } fromVector.setValueCount(numValues); ArrowBuf fromDataBuffer = fromVector.getDataBuffer(); - assertTrue(numValues * valueBytesLength <= fromDataBuffer.capacity()); + assertTrue((long) numValues * valueBytesLength <= fromDataBuffer.capacity()); /* * Copy the entries one-by-one from 'fromVector' to 'toVector', but use the setSafe with @@ -1668,20 +1668,20 @@ static Stream vectorCreatorProvider() { return Stream.of( Arguments.of( (Function) - (allocator -> + allocator -> newVector( ViewVarBinaryVector.class, EMPTY_SCHEMA_PATH, Types.MinorType.VIEWVARBINARY, - allocator))), + allocator)), Arguments.of( (Function) - (allocator -> + allocator -> newVector( ViewVarCharVector.class, EMPTY_SCHEMA_PATH, Types.MinorType.VIEWVARCHAR, - allocator)))); + allocator))); } @ParameterizedTest 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 6121fb67fefb7..4638c9fb7a974 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 @@ -216,7 +216,7 @@ public void testLoadValidityBuffer() throws IOException { ArrowBuf[] values = new ArrowBuf[4]; for (int i = 0; i < 4; i += 2) { ArrowBuf buf1 = allocator.buffer(BitVectorHelper.getValidityBufferSize(count)); - ArrowBuf buf2 = allocator.buffer(count * 4); // integers + ArrowBuf buf2 = allocator.buffer(count * 4L); // integers buf1.setZero(0, buf1.capacity()); buf2.setZero(0, buf2.capacity()); values[i] = buf1; @@ -228,10 +228,10 @@ public void testLoadValidityBuffer() throws IOException { BitVectorHelper.setBit(buf1, j); } - buf2.setInt(j * 4, j); + buf2.setInt(j * 4L, j); } - buf1.writerIndex((int) Math.ceil(count / 8)); - buf2.writerIndex(count * 4); + buf1.writerIndex((int) Math.ceil(count / 8.0)); + buf2.writerIndex(count * 4L); } /*