You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by om...@apache.org on 2019/03/11 14:56:07 UTC
[orc] branch branch-1.5 updated: ORC-475: ORC reader should lazily
get filesystem.
This is an automated email from the ASF dual-hosted git repository.
omalley pushed a commit to branch branch-1.5
in repository https://gitbox.apache.org/repos/asf/orc.git
The following commit(s) were added to refs/heads/branch-1.5 by this push:
new 94a682c ORC-475: ORC reader should lazily get filesystem.
94a682c is described below
commit 94a682c46ba6839f0c49a04731abf0569d24dd49
Author: Prasanth Jayachandran <pr...@apache.org>
AuthorDate: Wed Mar 6 15:14:08 2019 -0800
ORC-475: ORC reader should lazily get filesystem.
Fixes #371
Signed-off-by: Owen O'Malley <om...@apache.org>
---
.../src/java/org/apache/orc/impl/ReaderImpl.java | 20 +++++++++++++-------
.../java/org/apache/orc/impl/RecordReaderImpl.java | 2 +-
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/java/core/src/java/org/apache/orc/impl/ReaderImpl.java b/java/core/src/java/org/apache/orc/impl/ReaderImpl.java
index bba580f..d086421 100644
--- a/java/core/src/java/org/apache/orc/impl/ReaderImpl.java
+++ b/java/core/src/java/org/apache/orc/impl/ReaderImpl.java
@@ -59,9 +59,10 @@ public class ReaderImpl implements Reader {
private static final int DIRECTORY_SIZE_GUESS = 16 * 1024;
- protected final FileSystem fileSystem;
+ protected FileSystem fileSystem;
private final long maxLength;
protected final Path path;
+ protected final OrcFile.ReaderOptions options;
protected final org.apache.orc.CompressionKind compressionKind;
protected int bufferSize;
protected OrcProto.Metadata metadata;
@@ -337,12 +338,8 @@ public class ReaderImpl implements Reader {
* @param options options for reading
*/
public ReaderImpl(Path path, OrcFile.ReaderOptions options) throws IOException {
- FileSystem fs = options.getFilesystem();
- if (fs == null) {
- fs = path.getFileSystem(options.getConfiguration());
- }
- this.fileSystem = fs;
this.path = path;
+ this.options = options;
this.conf = options.getConfiguration();
this.maxLength = options.getMaxLength();
this.useUTCTimestamp = options.getUseUTCTimestamp();
@@ -367,7 +364,7 @@ public class ReaderImpl implements Reader {
} else {
OrcTail orcTail = options.getOrcTail();
if (orcTail == null) {
- tail = extractFileTail(fs, path, options.getMaxLength());
+ tail = extractFileTail(getFileSystem(), path, options.getMaxLength());
options.orcTail(tail);
} else {
checkOrcVersion(path, orcTail.getPostScript());
@@ -391,6 +388,15 @@ public class ReaderImpl implements Reader {
this.schema = OrcUtils.convertTypeFromProtobuf(this.types, 0);
}
+ protected FileSystem getFileSystem() throws IOException {
+ this.fileSystem = options.getFilesystem();
+ if (this.fileSystem == null) {
+ this.fileSystem = path.getFileSystem(options.getConfiguration());
+ options.filesystem(fileSystem);
+ }
+ return this.fileSystem;
+ }
+
/**
* Get the WriterVersion based on the ORC file postscript.
* @param writerVersion the integer writer version
diff --git a/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java b/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java
index dbf7e91..3ee1b62 100644
--- a/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java
+++ b/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java
@@ -244,7 +244,7 @@ public class RecordReaderImpl implements RecordReader {
DataReaderProperties.builder()
.withBufferSize(bufferSize)
.withCompression(fileReader.compressionKind)
- .withFileSystem(fileReader.fileSystem)
+ .withFileSystem(fileReader.getFileSystem())
.withPath(fileReader.path)
.withTypeCount(types.size())
.withZeroCopy(zeroCopy)