Skip to content

Commit

Permalink
[core] should not get file-size by file-io repeatly
Browse files Browse the repository at this point in the history
  • Loading branch information
leaves12138 committed Mar 15, 2024
1 parent 66ea443 commit 40f75c6
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ private class AvroReader implements RecordReader<InternalRow> {

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) {
Expand Down

0 comments on commit 40f75c6

Please sign in to comment.