Skip to content

Commit 42f22da

Browse files
committed
clear vectors in close
1 parent 5b91da7 commit 42f22da

12 files changed

+46
-15
lines changed

java/adapter/avro/src/main/java/org/apache/arrow/consumers/AvroBooleanConsumer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,9 @@ public FieldVector getVector() {
6363
return this.vector;
6464
}
6565

66+
@Override
67+
public void close() throws Exception {
68+
writer.close();
69+
}
70+
6671
}

java/adapter/avro/src/main/java/org/apache/arrow/consumers/AvroBytesConsumer.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ public FieldVector getVector() {
8181
}
8282

8383
@Override
84-
public void close() {
85-
if (cacheBuffer != null) {
86-
cacheBuffer.clear();
87-
}
84+
public void close() throws Exception {
85+
writer.close();
8886
}
8987
}

java/adapter/avro/src/main/java/org/apache/arrow/consumers/AvroDoubleConsumer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,9 @@ public void setPosition(int index) {
6262
public FieldVector getVector() {
6363
return vector;
6464
}
65+
66+
@Override
67+
public void close() throws Exception {
68+
writer.close();
69+
}
6570
}

java/adapter/avro/src/main/java/org/apache/arrow/consumers/AvroFloatConsumer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,9 @@ public void setPosition(int index) {
6262
public FieldVector getVector() {
6363
return this.vector;
6464
}
65+
66+
@Override
67+
public void close() throws Exception {
68+
writer.close();
69+
}
6570
}

java/adapter/avro/src/main/java/org/apache/arrow/consumers/AvroIntConsumer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,9 @@ public void setPosition(int index) {
6262
public FieldVector getVector() {
6363
return this.vector;
6464
}
65+
66+
@Override
67+
public void close() throws Exception {
68+
writer.close();
69+
}
6570
}

java/adapter/avro/src/main/java/org/apache/arrow/consumers/AvroLongConsumer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,9 @@ public void setPosition(int index) {
6262
public FieldVector getVector() {
6363
return this.vector;
6464
}
65+
66+
@Override
67+
public void close() throws Exception {
68+
writer.close();
69+
}
6570
}

java/adapter/avro/src/main/java/org/apache/arrow/consumers/AvroNullConsumer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,9 @@ public void setPosition(int index) {}
4848
public FieldVector getVector() {
4949
return this.vector;
5050
}
51+
52+
@Override
53+
public void close() {
54+
vector.close();
55+
}
5156
}

java/adapter/avro/src/main/java/org/apache/arrow/consumers/AvroStringConsumer.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ public FieldVector getVector() {
8282
}
8383

8484
@Override
85-
public void close() {
86-
if (cacheBuffer != null) {
87-
cacheBuffer.clear();
88-
}
85+
public void close() throws Exception {
86+
writer.close();
8987
}
9088
}

java/adapter/avro/src/main/java/org/apache/arrow/consumers/AvroUnionsConsumer.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ public FieldVector getVector() {
8282
}
8383

8484
@Override
85-
public void close() {
86-
for (Consumer consumer : delegates) {
87-
consumer.close();
85+
public void close() throws Exception {
86+
writer.close();
87+
for (Consumer delegate: delegates) {
88+
delegate.close();
8889
}
8990
}
9091
}

java/adapter/avro/src/main/java/org/apache/arrow/consumers/CompositeAvroConsumer.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ public void consume(Decoder decoder, VectorSchemaRoot root) throws IOException {
5959
public void close() {
6060
// clean up
6161
for (Consumer consumer : consumers) {
62-
consumer.close();
62+
try {
63+
consumer.close();
64+
} catch (Exception e) {
65+
throw new RuntimeException("Error occurs in close.", e);
66+
}
6367
}
6468
}
6569
}

0 commit comments

Comments
 (0)