From 3d114b410e001337e4ffb02d09e3506b3c902179 Mon Sep 17 00:00:00 2001 From: Christophe Le Saec Date: Tue, 25 Jul 2023 14:49:41 +0200 Subject: [PATCH 1/3] AVRO-2511: add case for sync --- .../java/org/apache/avro/file/DataFileWriter.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java index 05e5006acbf..3eece998f18 100644 --- a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java +++ b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java @@ -22,6 +22,7 @@ import java.io.BufferedOutputStream; import java.io.Closeable; import java.io.File; +import java.io.FileOutputStream; import java.io.FilterOutputStream; import java.io.Flushable; import java.io.IOException; @@ -51,7 +52,7 @@ * blocks. A synchronization marker is written between blocks, so that * files may be split. Blocks may be compressed. Extensible metadata is stored * at the end of the file. Files may be appended to. - * + * * @see DataFileReader */ public class DataFileWriter implements Closeable, Flushable { @@ -181,7 +182,7 @@ public DataFileWriter create(Schema schema, OutputStream outs, byte[] sync) t * sync marker is written. By default, the writer will flush the buffer each * time a sync marker is written (if the block size limit is reached or the * {@linkplain #sync()} is called. - * + * * @param flushOnEveryBlock - If set to false, this writer will not flush the * block to the stream until {@linkplain #flush()} is * explicitly called. @@ -211,7 +212,7 @@ public DataFileWriter appendTo(File file) throws IOException { /** * Open a writer appending to an existing file. Since 1.9.0 this method * does not close in. - * + * * @param in reading the existing file. * @param out positioned at the end of the existing file. */ @@ -304,7 +305,7 @@ public AppendWriteException(Exception e) { /** * Append a datum to the file. - * + * * @see AppendWriteException */ public void append(D datum) throws IOException { @@ -365,7 +366,7 @@ private void writeIfBlockFull() throws IOException { * at compression level 7. If recompress is false, blocks will be copied * without changing the compression level. If true, they will be converted to * the new compression level. - * + * * @param otherFile * @param recompress * @throws IOException @@ -450,6 +451,8 @@ public void fSync() throws IOException { flush(); if (underlyingStream instanceof Syncable) { ((Syncable) underlyingStream).sync(); + } else if (underlyingStream instanceof FileOutputStream) { + ((FileOutputStream) underlyingStream).getFD().sync(); } } From e336214fd5844a8d62db01d79dc5f966a9e85669 Mon Sep 17 00:00:00 2001 From: Christophe Le Saec Date: Wed, 20 Sep 2023 10:27:37 +0200 Subject: [PATCH 2/3] AVRO-2511: add javadoc --- .../avro/src/main/java/org/apache/avro/file/DataFileWriter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java index 3eece998f18..a08dca54f9a 100644 --- a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java +++ b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java @@ -440,7 +440,7 @@ public void flush() throws IOException { } /** - * If this writer was instantiated using a File or using an + * If this writer was instantiated using a {@linkplain File}, {@linkplain FileOutputStream} or * {@linkplain Syncable} instance, this method flushes all buffers for this * writer to disk. In other cases, this method behaves exactly like * {@linkplain #flush()}. From b547524a80f0becb63807d0c58524a5af27b4179 Mon Sep 17 00:00:00 2001 From: Christophe Le Saec Date: Wed, 20 Sep 2023 10:29:53 +0200 Subject: [PATCH 3/3] AVRO-2511: with spotless apply --- .../main/java/org/apache/avro/file/DataFileWriter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java index a08dca54f9a..65a305f34fc 100644 --- a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java +++ b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java @@ -440,10 +440,10 @@ public void flush() throws IOException { } /** - * If this writer was instantiated using a {@linkplain File}, {@linkplain FileOutputStream} or - * {@linkplain Syncable} instance, this method flushes all buffers for this - * writer to disk. In other cases, this method behaves exactly like - * {@linkplain #flush()}. + * If this writer was instantiated using a {@linkplain File}, + * {@linkplain FileOutputStream} or {@linkplain Syncable} instance, this method + * flushes all buffers for this writer to disk. In other cases, this method + * behaves exactly like {@linkplain #flush()}. * * @throws IOException */