Skip to content

Commit

Permalink
ARROW-17962: [Java] Remove unused schema creation from try with resou…
Browse files Browse the repository at this point in the history
…rces (#14346)

Authored-by: Larry White <lwhite1@users.noreply.github.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
  • Loading branch information
lwhite1 committed Oct 10, 2022
1 parent 21dbf4a commit 5120e1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion java/c/src/main/java/org/apache/arrow/c/Data.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ public static void exportTable(BufferAllocator allocator, Table table,
*/
public static void exportTable(BufferAllocator allocator, Table table,
DictionaryProvider provider, ArrowArray out, ArrowSchema outSchema) {
exportVectorSchemaRoot(allocator, table.toVectorSchemaRoot(), provider, out, outSchema);
try (VectorSchemaRoot root = table.toVectorSchemaRoot()) {
exportVectorSchemaRoot(allocator, root, provider, out, outSchema);
}
}

/**
Expand Down
5 changes: 2 additions & 3 deletions java/c/src/test/java/org/apache/arrow/c/RoundtripTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -670,13 +670,12 @@ public void testTable() {
ArrowArray consumerArrowArray = ArrowArray.allocateNew(allocator)) {
try (
VectorSchemaRoot vsr = createTestVSR();
Table table = new Table(vsr);
) {
Table table = new Table(vsr)) {
// Producer creates structures from existing memory pointers
try (ArrowSchema arrowSchema = ArrowSchema.wrap(consumerArrowSchema.memoryAddress());
ArrowArray arrowArray = ArrowArray.wrap(consumerArrowArray.memoryAddress())) {
// Producer exports vector into the C Data Interface structures
Data.exportTable(allocator, table, arrowArray);
Data.exportTable(allocator, table, null, arrowArray, arrowSchema);
}
}
// Consumer imports vector
Expand Down

0 comments on commit 5120e1a

Please sign in to comment.