You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@parquet.apache.org by "gszadovszky (via GitHub)" <gi...@apache.org> on 2023/06/27 13:28:08 UTC

[GitHub] [parquet-mr] gszadovszky opened a new pull request, #1117: PARQUET-2318: Implement a tool to list page headers

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

   Implemented a new tool to retrieve the original Thrift page headers (in json format). It is attached to the existing command "pages" with the options "--raw".
   Additional changes:
   - Added default Hadoop configuration to support reading INT96 values
   - Added the profile "local" to parquet-cli so a standalone jar can be generated which does not need a Hadoop environment to be used
   
   Make sure you have checked _all_ steps below.
   
   ### Jira
   
   - [ ] 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
   
   - [ ] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
   
   ### Commits
   
   - [ ] 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
   
   - [ ] 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


[GitHub] [parquet-mr] gszadovszky commented on pull request #1117: PARQUET-2318: Implement a tool to list page headers

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

   Thanks for the review, @shangxinli!


-- 
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


[GitHub] [parquet-mr] shangxinli commented on a diff in pull request #1117: PARQUET-2318: Implement a tool to list page headers

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


##########
parquet-cli/src/main/java/org/apache/parquet/cli/util/RawUtils.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.parquet.cli.util;
+
+import static org.apache.parquet.bytes.BytesUtils.readIntLittleEndian;
+import static org.apache.parquet.hadoop.ParquetFileWriter.EFMAGIC;
+import static org.apache.parquet.hadoop.ParquetFileWriter.MAGIC;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+
+import org.apache.parquet.bytes.ByteBufferInputStream;
+import org.apache.parquet.format.FileMetaData;
+import org.apache.parquet.format.Util;
+import org.apache.parquet.io.SeekableInputStream;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+
+public class RawUtils {
+
+  private static final ObjectMapper MAPPER = createObjectMapper();
+
+  public static FileMetaData readFooter(SeekableInputStream is, long fileLen) throws IOException {

Review Comment:
   the 'is' name is a little not clear. use 'inputStream'? 



-- 
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


[GitHub] [parquet-mr] shangxinli commented on pull request #1117: PARQUET-2318: Implement a tool to list page headers

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

   LGTM


-- 
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


[GitHub] [parquet-mr] gszadovszky commented on a diff in pull request #1117: PARQUET-2318: Implement a tool to list page headers

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


##########
parquet-cli/src/main/java/org/apache/parquet/cli/rawpages/RawPagesReader.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.parquet.cli.rawpages;
+
+import static org.apache.parquet.hadoop.ParquetFileWriter.MAGIC;
+
+import java.io.IOException;
+
+import org.apache.parquet.cli.util.RawUtils;
+import org.apache.parquet.format.CliUtils;
+import org.apache.parquet.format.ColumnChunk;
+import org.apache.parquet.format.ColumnMetaData;
+import org.apache.parquet.format.FileMetaData;
+import org.apache.parquet.format.PageHeader;
+import org.apache.parquet.format.RowGroup;
+import org.apache.parquet.format.Util;
+import org.apache.parquet.io.InputFile;
+import org.apache.parquet.io.SeekableInputStream;
+import org.slf4j.Logger;
+
+public class RawPagesReader implements AutoCloseable {
+
+  private final SeekableInputStream input;
+  private final FileMetaData footer;
+
+  public RawPagesReader(InputFile file) throws IOException {
+    long fileLen = file.getLength();
+
+    if (fileLen < MAGIC.length + 4 + MAGIC.length) {
+      throw new RuntimeException("Not a Parquet file (length is too low: " + fileLen + ")");
+    }
+
+    input = file.newStream();
+    footer = RawUtils.readFooter(input, fileLen);
+  }
+
+  public void listPages(Logger console) throws IOException {
+    for (int i = 0, n = footer.getRow_groupsSize(); i < n; ++i) {

Review Comment:
   That's a method name generated by Thrift. That's the size of the field `row_groups` which is a `List`.



-- 
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


[GitHub] [parquet-mr] shangxinli commented on a diff in pull request #1117: PARQUET-2318: Implement a tool to list page headers

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


##########
parquet-cli/src/main/java/org/apache/parquet/cli/rawpages/RawPagesReader.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.parquet.cli.rawpages;
+
+import static org.apache.parquet.hadoop.ParquetFileWriter.MAGIC;
+
+import java.io.IOException;
+
+import org.apache.parquet.cli.util.RawUtils;
+import org.apache.parquet.format.CliUtils;
+import org.apache.parquet.format.ColumnChunk;
+import org.apache.parquet.format.ColumnMetaData;
+import org.apache.parquet.format.FileMetaData;
+import org.apache.parquet.format.PageHeader;
+import org.apache.parquet.format.RowGroup;
+import org.apache.parquet.format.Util;
+import org.apache.parquet.io.InputFile;
+import org.apache.parquet.io.SeekableInputStream;
+import org.slf4j.Logger;
+
+public class RawPagesReader implements AutoCloseable {
+
+  private final SeekableInputStream input;
+  private final FileMetaData footer;
+
+  public RawPagesReader(InputFile file) throws IOException {
+    long fileLen = file.getLength();
+
+    if (fileLen < MAGIC.length + 4 + MAGIC.length) {
+      throw new RuntimeException("Not a Parquet file (length is too low: " + fileLen + ")");
+    }
+
+    input = file.newStream();
+    footer = RawUtils.readFooter(input, fileLen);
+  }
+
+  public void listPages(Logger console) throws IOException {
+    for (int i = 0, n = footer.getRow_groupsSize(); i < n; ++i) {

Review Comment:
   getRow_GroupSize()? 



-- 
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


[GitHub] [parquet-mr] shangxinli commented on a diff in pull request #1117: PARQUET-2318: Implement a tool to list page headers

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


##########
parquet-cli/src/main/java/org/apache/parquet/cli/rawpages/RawPagesReader.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.parquet.cli.rawpages;
+
+import static org.apache.parquet.hadoop.ParquetFileWriter.MAGIC;
+
+import java.io.IOException;
+
+import org.apache.parquet.cli.util.RawUtils;
+import org.apache.parquet.format.CliUtils;
+import org.apache.parquet.format.ColumnChunk;
+import org.apache.parquet.format.ColumnMetaData;
+import org.apache.parquet.format.FileMetaData;
+import org.apache.parquet.format.PageHeader;
+import org.apache.parquet.format.RowGroup;
+import org.apache.parquet.format.Util;
+import org.apache.parquet.io.InputFile;
+import org.apache.parquet.io.SeekableInputStream;
+import org.slf4j.Logger;
+
+public class RawPagesReader implements AutoCloseable {
+
+  private final SeekableInputStream input;
+  private final FileMetaData footer;
+
+  public RawPagesReader(InputFile file) throws IOException {
+    long fileLen = file.getLength();
+
+    if (fileLen < MAGIC.length + 4 + MAGIC.length) {
+      throw new RuntimeException("Not a Parquet file (length is too low: " + fileLen + ")");
+    }
+
+    input = file.newStream();
+    footer = RawUtils.readFooter(input, fileLen);
+  }
+
+  public void listPages(Logger console) throws IOException {
+    for (int i = 0, n = footer.getRow_groupsSize(); i < n; ++i) {

Review Comment:
   Got it. 



-- 
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


[GitHub] [parquet-mr] gszadovszky merged pull request #1117: PARQUET-2318: Implement a tool to list page headers

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


-- 
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