You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@parquet.apache.org by "amousavigourabi (via GitHub)" <gi...@apache.org> on 2023/11/15 20:03:30 UTC

[PR] PARQUET-2380: Decouple rewriter from Hadoop [parquet-mr]

amousavigourabi opened a new pull request, #1195:
URL: https://github.com/apache/parquet-mr/pull/1195

   Make sure you have checked _all_ steps below.
   
   ### Jira
   
   - [x] My PR addresses the following [Parquet Jira](https://issues.apache.org/jira/browse/PARQUET/) issues and references them in the PR title. For example, "PARQUET-1234: My Parquet PR"
     - https://issues.apache.org/jira/browse/PARQUET-XXX
     - In case you are adding a dependency, check if the license complies with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   
   ### Tests
   
   - [x] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
   - Parameterized testing within ParquetRewriterTest using the new unhadooped methods.
   
   ### Commits
   
   - [x] My commits all reference Jira issues in their subject lines. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [x] In case of new functionality, my PR adds documentation that describes how to use it.
     - All the public functions and the classes in the PR contain Javadoc that explain what it does
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PARQUET-2380: Decouple rewriter from Hadoop [parquet-mr]

Posted by "amousavigourabi (via GitHub)" <gi...@apache.org>.
amousavigourabi commented on code in PR #1195:
URL: https://github.com/apache/parquet-mr/pull/1195#discussion_r1397467309


##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/util/HadoopOutputFile.java:
##########
@@ -54,11 +54,19 @@ private static boolean supportsBlockSize(FileSystem fs) {
   private final Configuration conf;
 
   public static HadoopOutputFile fromPath(Path path, Configuration conf)
-      throws IOException {
+    throws IOException {
     FileSystem fs = path.getFileSystem(conf);
     return new HadoopOutputFile(fs, fs.makeQualified(path), conf);
   }
 
+  public static HadoopOutputFile fromPathUnchecked(Path path, Configuration conf) {

Review Comment:
   As we cannot yet get rid of some methods without(!) throws using Hadoop's Path where we do want to transition to the InputFile/OutputFile interfaces in the background, this is a DRYer way to avoid try catching `IOExceptions` and converting them to `RuntimeExceptions` (to avoid adding incompatible throws clauses) all the time. As an added bonus, this also allows for concisely converting collections of Paths to HadoopOutputFiles/HadoopInputFiles using Java Stream HOFs such as map.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PARQUET-2380: Decouple rewriter from Hadoop [parquet-mr]

Posted by "ConeyLiu (via GitHub)" <gi...@apache.org>.
ConeyLiu commented on code in PR #1195:
URL: https://github.com/apache/parquet-mr/pull/1195#discussion_r1396740241


##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/rewrite/RewriteOptions.java:
##########
@@ -64,15 +72,53 @@ private RewriteOptions(Configuration conf,
     this.indexCacheStrategy = indexCacheStrategy;
   }
 
+  /**
+   * Gets the {@link Configuration} part of the rewrite options.
+   *
+   * @return the associated {@link Configuration}
+   */
   public Configuration getConf() {
+    return ConfigurationUtil.createHadoopConfiguration(conf);
+  }
+
+  /**
+   * Gets the {@link ParquetConfiguration} part of the rewrite options.
+   *
+   * @return the associated {@link ParquetConfiguration}
+   */
+  public ParquetConfiguration getParquetConfiguration() {
     return conf;
   }
 
-  public List<Path> getInputFiles() {

Review Comment:
   I think we should not remove a public method directly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PARQUET-2380: Decouple rewriter from Hadoop [parquet-mr]

Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on PR #1195:
URL: https://github.com/apache/parquet-mr/pull/1195#issuecomment-1814783385

   cc @ConeyLiu 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PARQUET-2380: Decouple rewriter from Hadoop [parquet-mr]

Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac merged PR #1195:
URL: https://github.com/apache/parquet-mr/pull/1195


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PARQUET-2380: Decouple rewriter from Hadoop [parquet-mr]

Posted by "ConeyLiu (via GitHub)" <gi...@apache.org>.
ConeyLiu commented on code in PR #1195:
URL: https://github.com/apache/parquet-mr/pull/1195#discussion_r1396744262


##########
parquet-hadoop/src/test/java/org/apache/parquet/hadoop/rewrite/ParquetRewriterTest.java:
##########
@@ -99,28 +103,47 @@ public class ParquetRewriterTest {
 
   private final int numRecord = 100000;
   private final Configuration conf = new Configuration();
+  private final ParquetConfiguration parquetConf = new PlainParquetConfiguration();
   private final ParquetProperties.WriterVersion writerVersion;
   private final IndexCache.CacheStrategy indexCacheStrategy;
+  private final boolean usingHadoop;
 
   private List<EncryptionTestFile> inputFiles = null;
   private String outputFile = null;
   private ParquetRewriter rewriter = null;
 
-  @Parameterized.Parameters(name = "WriterVersion = {0}, IndexCacheStrategy = {1}")
+  @Parameterized.Parameters(name = "WriterVersion = {0}, IndexCacheStrategy = {1}, UsingHadoop = {2}")
   public static Object[][] parameters() {
-    return new Object[][] {{"v1", "NONE"}, {"v1", "PREFETCH_BLOCK"}, {"v2", "NONE"}, {"v2", "PREFETCH_BLOCK"}};
-  }
-
-  public ParquetRewriterTest(String writerVersion, String indexCacheStrategy) {
+    return new Object[][] {
+      {"v1", "NONE", true},
+      {"v1", "PREFETCH_BLOCK", true},
+      {"v2", "NONE", true},
+      {"v2", "PREFETCH_BLOCK", true},
+      {"v1", "NONE", false},
+      {"v1", "PREFETCH_BLOCK", false},
+      {"v2", "NONE", false},
+      {"v2", "PREFETCH_BLOCK", false}
+    };
+  }
+
+  public ParquetRewriterTest(String writerVersion, String indexCacheStrategy, boolean usingHadoop) {
     this.writerVersion = ParquetProperties.WriterVersion.fromString(writerVersion);
     this.indexCacheStrategy = IndexCache.CacheStrategy.valueOf(indexCacheStrategy);
+    this.usingHadoop = usingHadoop;
   }
 
   private void testPruneSingleColumnTranslateCodec(List<Path> inputPaths) throws Exception {
-    Path outputPath = new Path(outputFile);
-    List<String> pruneColumns = Arrays.asList("Gender");
+    RewriteOptions.Builder builder;

Review Comment:
   The code should be wrapped into a private method to reuse since it appears in multiple places.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PARQUET-2380: Decouple rewriter from Hadoop [parquet-mr]

Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #1195:
URL: https://github.com/apache/parquet-mr/pull/1195#discussion_r1397444146


##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/util/HadoopOutputFile.java:
##########
@@ -54,11 +54,19 @@ private static boolean supportsBlockSize(FileSystem fs) {
   private final Configuration conf;
 
   public static HadoopOutputFile fromPath(Path path, Configuration conf)
-      throws IOException {
+    throws IOException {
     FileSystem fs = path.getFileSystem(conf);
     return new HadoopOutputFile(fs, fs.makeQualified(path), conf);
   }
 
+  public static HadoopOutputFile fromPathUnchecked(Path path, Configuration conf) {

Review Comment:
   Why do we need this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PARQUET-2380: Decouple rewriter from Hadoop [parquet-mr]

Posted by "amousavigourabi (via GitHub)" <gi...@apache.org>.
amousavigourabi commented on code in PR #1195:
URL: https://github.com/apache/parquet-mr/pull/1195#discussion_r1397394681


##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/rewrite/RewriteOptions.java:
##########
@@ -64,15 +72,53 @@ private RewriteOptions(Configuration conf,
     this.indexCacheStrategy = indexCacheStrategy;
   }
 
+  /**
+   * Gets the {@link Configuration} part of the rewrite options.
+   *
+   * @return the associated {@link Configuration}
+   */
   public Configuration getConf() {
+    return ConfigurationUtil.createHadoopConfiguration(conf);
+  }
+
+  /**
+   * Gets the {@link ParquetConfiguration} part of the rewrite options.
+   *
+   * @return the associated {@link ParquetConfiguration}
+   */
+  public ParquetConfiguration getParquetConfiguration() {
     return conf;
   }
 
-  public List<Path> getInputFiles() {

Review Comment:
   It seems japicmp didn't pick it up as the erasure is the same as in `List<InputFile> getInputFiles()`. I'll restore the method.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PARQUET-2380: Decouple rewriter from Hadoop [parquet-mr]

Posted by "ConeyLiu (via GitHub)" <gi...@apache.org>.
ConeyLiu commented on PR #1195:
URL: https://github.com/apache/parquet-mr/pull/1195#issuecomment-1815809399

   Thanks @amousavigourabi for this contribution, and thanks @wgtmac for pinging me. Just two minor comments.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org