Skip to content

Commit

Permalink
apacheGH-44011: [Java] Consider warnings as errors for C Module (apac…
Browse files Browse the repository at this point in the history
…he#44012)

### Rationale for this change

This PR configs the build such that warnings are considered as errors in the C module. And corresponding code changes have also been made.

### What changes are included in this PR?

Adding flags to consider warnings as errors in javac and fixing the corresponding errors.

### Are these changes tested?

Tested by existing test cases.

### Are there any user-facing changes?

N/A
* GitHub Issue: apache#44011

Authored-by: Vibhatha Lakmal Abeykoon <[email protected]>
Signed-off-by: David Li <[email protected]>
  • Loading branch information
vibhatha authored Sep 10, 2024
1 parent 23c4687 commit 09ed5e5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
11 changes: 11 additions & 0 deletions java/c/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,16 @@ under the License.
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration combine.children="append">
<compilerArgs>
<arg>-Werror</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</project>
2 changes: 1 addition & 1 deletion java/c/src/main/java/org/apache/arrow/c/ArrayExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void export(ArrowArray array, FieldVector vector, DictionaryProvider dictionaryP

data.buffers = new ArrayList<>(vector.getExportedCDataBufferCount());
data.buffers_ptrs =
allocator.buffer((long) (vector.getExportedCDataBufferCount()) * Long.BYTES);
allocator.buffer((long) vector.getExportedCDataBufferCount() * Long.BYTES);
vector.exportCDataBuffers(data.buffers, data.buffers_ptrs, NULL);

if (dictionaryEncoding != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public List<ArrowBuf> visit(ArrowType.Utf8 type) {
private List<ArrowBuf> visitVariableWidthView(ArrowType type) {
final int viewBufferIndex = 1;
final int variadicSizeBufferIndex = this.buffers.length - 1;
final long numOfVariadicBuffers = this.buffers.length - 3;
final long numOfVariadicBuffers = this.buffers.length - 3L;
final long variadicSizeBufferCapacity = numOfVariadicBuffers * Long.BYTES;
List<ArrowBuf> buffers = new ArrayList<>();

Expand Down
8 changes: 4 additions & 4 deletions java/c/src/test/java/org/apache/arrow/c/DictionaryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ private void createStructVector(StructVector vector) {

// Write the values to child 1
child1.allocateNew();
child1.set(0, "01234567890".getBytes());
child1.set(1, "012345678901234567".getBytes());
child1.set(0, "01234567890".getBytes(StandardCharsets.UTF_8));
child1.set(1, "012345678901234567".getBytes(StandardCharsets.UTF_8));
vector.setIndexDefined(0);

// Write the values to child 2
Expand All @@ -269,8 +269,8 @@ private void createStructVectorInline(StructVector vector) {

// Write the values to child 1
child1.allocateNew();
child1.set(0, "012345678".getBytes());
child1.set(1, "01234".getBytes());
child1.set(0, "012345678".getBytes(StandardCharsets.UTF_8));
child1.set(1, "01234".getBytes(StandardCharsets.UTF_8));
vector.setIndexDefined(0);

// Write the values to child 2
Expand Down
8 changes: 0 additions & 8 deletions java/c/src/test/java/org/apache/arrow/c/RoundtripTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,6 @@ public void testVarBinaryVector() {
}
}

private String generateString(String str, int repetition) {
StringBuilder aRepeated = new StringBuilder();
for (int i = 0; i < repetition; i++) {
aRepeated.append(str);
}
return aRepeated.toString();
}

@Test
public void testViewVector() {
// ViewVarCharVector with short strings
Expand Down

0 comments on commit 09ed5e5

Please sign in to comment.