You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@parquet.apache.org by bl...@apache.org on 2015/07/02 02:18:46 UTC

parquet-mr git commit: PARQUET-289: Allow ParquetReader.Builder subclasses.

Repository: parquet-mr
Updated Branches:
  refs/heads/master a747456bf -> 2f2c8b1cc


PARQUET-289: Allow ParquetReader.Builder subclasses.

This adds a protected constructor for subclasses, a getReadSupport
method for subclasses to override, and exposes the configuration for
subclasses to modify inside of getReadSupport.

Author: Ryan Blue <bl...@apache.org>

Closes #203 from rdblue/PARQUET-289-extend-reader-builder and squashes the following commits:

692f159 [Ryan Blue] PARQUET-289: Allow ParquetReader.Builder subclasses.


Project: http://git-wip-us.apache.org/repos/asf/parquet-mr/repo
Commit: http://git-wip-us.apache.org/repos/asf/parquet-mr/commit/2f2c8b1c
Tree: http://git-wip-us.apache.org/repos/asf/parquet-mr/tree/2f2c8b1c
Diff: http://git-wip-us.apache.org/repos/asf/parquet-mr/diff/2f2c8b1c

Branch: refs/heads/master
Commit: 2f2c8b1cc6e6e731f7bc52b0988ea8316f475004
Parents: a747456
Author: Ryan Blue <bl...@apache.org>
Authored: Wed Jul 1 17:18:41 2015 -0700
Committer: Ryan Blue <bl...@apache.org>
Committed: Wed Jul 1 17:18:41 2015 -0700

----------------------------------------------------------------------
 .../org/apache/parquet/hadoop/ParquetReader.java | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/2f2c8b1c/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetReader.java
----------------------------------------------------------------------
diff --git a/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetReader.java b/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetReader.java
index b23273a..7cbb04a 100644
--- a/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetReader.java
+++ b/parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetReader.java
@@ -31,6 +31,7 @@ import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 
+import org.apache.parquet.Preconditions;
 import org.apache.parquet.filter.UnboundRecordFilter;
 import org.apache.parquet.filter2.compat.FilterCompat;
 import org.apache.parquet.filter2.compat.FilterCompat.Filter;
@@ -168,8 +169,8 @@ public class ParquetReader<T> implements Closeable {
   public static class Builder<T> {
     private final ReadSupport<T> readSupport;
     private final Path file;
-    private Configuration conf;
     private Filter filter;
+    protected Configuration conf;
 
     private Builder(ReadSupport<T> readSupport, Path path) {
       this.readSupport = checkNotNull(readSupport, "readSupport");
@@ -178,6 +179,13 @@ public class ParquetReader<T> implements Closeable {
       this.filter = FilterCompat.NOOP;
     }
 
+    protected Builder(Path path) {
+      this.readSupport = null;
+      this.file = checkNotNull(path, "path");
+      this.conf = new Configuration();
+      this.filter = FilterCompat.NOOP;
+    }
+
     public Builder<T> withConf(Configuration conf) {
       this.conf = checkNotNull(conf, "conf");
       return this;
@@ -188,8 +196,15 @@ public class ParquetReader<T> implements Closeable {
       return this;
     }
 
+    protected ReadSupport<T> getReadSupport() {
+      // if readSupport is null, the protected constructor must have been used
+      Preconditions.checkArgument(readSupport != null,
+          "[BUG] Classes that extend Builder should override getReadSupport()");
+      return readSupport;
+    }
+
     public ParquetReader<T> build() throws IOException {
-      return new ParquetReader<T>(conf, file, readSupport, filter);
+      return new ParquetReader<T>(conf, file, getReadSupport(), filter);
     }
   }
 }