You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@paimon.apache.org by lz...@apache.org on 2024/03/15 07:49:50 UTC

(incubator-paimon) branch master updated: [core] AvroBulkFormat should not get file-size by file-io repeatly (#3019)

This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 7c8e42b10 [core] AvroBulkFormat should not get file-size by file-io repeatly (#3019)
7c8e42b10 is described below

commit 7c8e42b10d2749d04b7994a1c1e270c16135d2d9
Author: YeJunHao <41...@users.noreply.github.com>
AuthorDate: Fri Mar 15 15:49:45 2024 +0800

    [core] AvroBulkFormat should not get file-size by file-io repeatly (#3019)
---
 .../java/org/apache/paimon/format/avro/AvroBulkFormat.java     | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/paimon-format/src/main/java/org/apache/paimon/format/avro/AvroBulkFormat.java b/paimon-format/src/main/java/org/apache/paimon/format/avro/AvroBulkFormat.java
index 1c1cfddf1..da60eedda 100644
--- a/paimon-format/src/main/java/org/apache/paimon/format/avro/AvroBulkFormat.java
+++ b/paimon-format/src/main/java/org/apache/paimon/format/avro/AvroBulkFormat.java
@@ -69,18 +69,18 @@ public class AvroBulkFormat implements FormatReaderFactory {
 
         private AvroReader(FileIO fileIO, Path path) throws IOException {
             this.fileIO = fileIO;
-            this.reader = createReaderFromPath(path);
-            this.reader.sync(0);
             this.end = fileIO.getFileSize(path);
+            this.reader = createReaderFromPath(path, end);
+            this.reader.sync(0);
             this.pool = new Pool<>(1);
             this.pool.add(new Object());
         }
 
-        private DataFileReader<InternalRow> createReaderFromPath(Path path) throws IOException {
+        private DataFileReader<InternalRow> createReaderFromPath(Path path, long fileSize)
+                throws IOException {
             DatumReader<InternalRow> datumReader = new AvroRowDatumReader(projectedRowType);
             SeekableInput in =
-                    new SeekableInputStreamWrapper(
-                            fileIO.newInputStream(path), fileIO.getFileSize(path));
+                    new SeekableInputStreamWrapper(fileIO.newInputStream(path), fileSize);
             try {
                 return (DataFileReader<InternalRow>) DataFileReader.openReader(in, datumReader);
             } catch (Throwable e) {