Close ColumnWriters in OrcWriter when IOException is thrown
@@ -328,6 +328,8 @@ public class OrcWriter
outputData.add(createDataOutput(MAGIC));
stripeStartOffset += MAGIC.length();
}
+
+ try {
// add stripe data
outputData.addAll(bufferStripeData(stripeStartOffset, flushReason));
// if the file is being closed, add the file footer
@@ -337,7 +339,8 @@ public class OrcWriter
// write all data
orcDataSink.write(outputData);
-
+ }
+ finally {
// open next stripe
columnWriters.forEach(ColumnWriter::reset);
dictionaryCompressionOptimizer.reset();
@@ -345,6 +348,7 @@ public class OrcWriter
stripeRowCount = 0;
bufferedBytes = toIntExact(columnWriters.stream().mapToLong(ColumnWriter::getBufferedBytes).sum());
}
+ }
/**
* Collect the data for for the stripe. This is not the actual data, but
