Make sure to close keySectionOutput
keySectionOutput.writeBytes() can throw resulting in a memory leak.
@@ -289,11 +289,11 @@ public class RcFileWriter
}
// build key section
+ int valueLength = 0;
keySectionOutput = keySectionOutput.createRecycledCompressedSliceOutput();
+ try {
writeVInt(keySectionOutput, bufferedRows);
recordValidation(validation -> validation.addRowGroup(bufferedRows));
-
- int valueLength = 0;
for (ColumnEncoder columnEncoder : columnEncoders) {
valueLength += columnEncoder.getCompressedSize();
writeVInt(keySectionOutput, columnEncoder.getCompressedSize());
@@ -303,7 +303,10 @@ public class RcFileWriter
writeVInt(keySectionOutput, lengthData.length());
keySectionOutput.writeBytes(lengthData);
}
+ }
+ finally {
keySectionOutput.close();
+ }
// write the sum of the uncompressed key length and compressed value length
// this number is useless to the reader
