wgtmac commented on code in PR #3269:
URL: https://github.com/apache/parquet-java/pull/3269#discussion_r2296537675
##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileWriter.java:
##########
@@ -1804,14 +1804,27 @@ private static void copy(SeekableInputStream from,
PositionOutputStream to, long
* @throws IOException if there is an error while writing
*/
public void end(Map<String, String> extraMetaData) throws IOException {
+ final long footerStart = out.getPos();
+
+ // Build the footer metadata) in memory using the helper stream
+ InMemoryPositionOutputStream buffer = new
InMemoryPositionOutputStream(footerStart);
+
+ serializeColumnIndexes(columnIndexes, blocks, buffer, fileEncryptor);
+ serializeOffsetIndexes(offsetIndexes, blocks, buffer, fileEncryptor);
+ serializeBloomFilters(bloomFilters, blocks, buffer, fileEncryptor);
+
+ ParquetMetadata localFooter =
+ new ParquetMetadata(new FileMetaData(schema, extraMetaData,
Version.FULL_VERSION), blocks);
+ serializeFooter(localFooter, buffer, fileEncryptor, metadataConverter);
+
+ byte[] footerBytes = buffer.toByteArray();
+
try {
+ out.write(footerBytes);
+ out.flush();
Review Comment:
Changing the state after flushing may make the case even worse. For example
if the 1st call to end has flushed some data to the underlying storage and
exception happens in the halfway. Then a retry issues the 2nd call which may
succeed eventually so dirty data may have been written to the file.
IMHO, the behavior before this change is much safer though the exception
message is a little bit confusing. It seems to be the issue from the Iceberg
parquet writer (or any other writer impl on top of the ParquetFileWriter) which
tries to retry from endRowGroup after a failed end call. It should actually
call close if anything wrong happens.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]