You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "tustvold (via GitHub)" <gi...@apache.org> on 2023/05/31 17:53:55 UTC

[GitHub] [arrow-rs] tustvold opened a new pull request, #4326: Add separate row_count and level_count to PageMetadata (#4321)

tustvold opened a new pull request, #4326:
URL: https://github.com/apache/arrow-rs/pull/4326

   _Draft as builds on #4319_ 
   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #4321
   
   # Rationale for this change
    
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking change` label.
   -->
   


-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] alamb commented on a diff in pull request #4326: Add separate row_count and level_count to PageMetadata (#4321)

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #4326:
URL: https://github.com/apache/arrow-rs/pull/4326#discussion_r1213083225


##########
parquet/src/column/page.rs:
##########
@@ -265,9 +265,10 @@ impl PageWriteSpec {
 /// Contains metadata for a page
 #[derive(Clone)]
 pub struct PageMetadata {
-    /// The number of rows in this page
-    pub num_rows: usize,
-
+    /// The number of rows within the page if known
+    pub num_rows: Option<usize>,
+    /// The number of levels within the page if known
+    pub num_levels: Option<usize>,

Review Comment:
   
   
   I double checked the spec. This PR seems consistent to me ✅ 
   
   https://github.com/apache/parquet-format/blob/c766945d90935ebcd4e03fee13aad2b6efcadce3/src/main/thrift/parquet.thrift#L563
   
   



-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] tustvold commented on a diff in pull request #4326: Add separate row_count and level_count to PageMetadata (#4321)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #4326:
URL: https://github.com/apache/arrow-rs/pull/4326#discussion_r1213093077


##########
parquet/src/column/page.rs:
##########
@@ -277,18 +278,27 @@ impl TryFrom<&PageHeader> for PageMetadata {
 
     fn try_from(value: &PageHeader) -> std::result::Result<Self, Self::Error> {
         match value.type_ {
-            crate::format::PageType::DATA_PAGE => Ok(PageMetadata {
-                num_rows: value.data_page_header.as_ref().unwrap().num_values as usize,
-                is_dict: false,
-            }),
+            crate::format::PageType::DATA_PAGE => {
+                let header = value.data_page_header.as_ref().unwrap();
+                Ok(PageMetadata {
+                    num_rows: None,
+                    num_levels: Some(header.num_values as _),

Review Comment:
   Yeah, this logic is encoded in https://github.com/apache/arrow-rs/pull/4326/files/549124a6cfebe946710595230d5bc4e4126954fb#diff-0cda716759f051812703723d2134741edaec0252f46895392e9917cdf4209c50R317
   
   We actually only care that the max_rep_level == 0, although a max_def_level == 0 would imply 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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] mapleFU commented on a diff in pull request #4326: Add separate row_count and level_count to PageMetadata (#4321)

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #4326:
URL: https://github.com/apache/arrow-rs/pull/4326#discussion_r1213087653


##########
parquet/src/column/page.rs:
##########
@@ -277,18 +278,27 @@ impl TryFrom<&PageHeader> for PageMetadata {
 
     fn try_from(value: &PageHeader) -> std::result::Result<Self, Self::Error> {
         match value.type_ {
-            crate::format::PageType::DATA_PAGE => Ok(PageMetadata {
-                num_rows: value.data_page_header.as_ref().unwrap().num_values as usize,
-                is_dict: false,
-            }),
+            crate::format::PageType::DATA_PAGE => {
+                let header = value.data_page_header.as_ref().unwrap();
+                Ok(PageMetadata {
+                    num_rows: None,
+                    num_levels: Some(header.num_values as _),

Review Comment:
   I guess when page `max_def_level == 0`, `num_values` doesn't means `num_levels`? 



-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] tustvold merged pull request #4326: Add separate row_count and level_count to PageMetadata (#4321)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold merged PR #4326:
URL: https://github.com/apache/arrow-rs/pull/4326


-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] tustvold commented on a diff in pull request #4326: Add separate row_count and level_count to PageMetadata (#4321)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #4326:
URL: https://github.com/apache/arrow-rs/pull/4326#discussion_r1213073769


##########
parquet/src/column/reader.rs:
##########
@@ -533,12 +542,7 @@ where
         if self.num_buffered_values == 0
             || self.num_buffered_values == self.num_decoded_values
         {
-            // TODO: should we return false if read_new_page() = true and
-            // num_buffered_values = 0?
-            match self.page_reader.peek_next_page()? {
-                Some(next_page) => Ok(next_page.num_rows != 0),
-                None => Ok(false),
-            }
+            Ok(self.page_reader.peek_next_page()?.is_some())

Review Comment:
   This makes the behaviour more consistent, it will return true if there is a page remaining, regardless of its contents



-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] tustvold commented on a diff in pull request #4326: Add separate row_count and level_count to PageMetadata (#4321)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #4326:
URL: https://github.com/apache/arrow-rs/pull/4326#discussion_r1213169853


##########
parquet/src/column/page.rs:
##########
@@ -277,18 +278,27 @@ impl TryFrom<&PageHeader> for PageMetadata {
 
     fn try_from(value: &PageHeader) -> std::result::Result<Self, Self::Error> {
         match value.type_ {
-            crate::format::PageType::DATA_PAGE => Ok(PageMetadata {
-                num_rows: value.data_page_header.as_ref().unwrap().num_values as usize,
-                is_dict: false,
-            }),
+            crate::format::PageType::DATA_PAGE => {
+                let header = value.data_page_header.as_ref().unwrap();
+                Ok(PageMetadata {
+                    num_rows: None,
+                    num_levels: Some(header.num_values as _),

Review Comment:
   Yeah, I don't really have a good solution to this. In parquet-rs we use `levels` instead of `values` to avoid ambiguity over whether nulls are included, however, this does result in some friction at the edges where there is interaction with the parquet definitions.



-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] tustvold commented on a diff in pull request #4326: Add separate row_count and level_count to PageMetadata (#4321)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #4326:
URL: https://github.com/apache/arrow-rs/pull/4326#discussion_r1212093830


##########
parquet/src/column/page.rs:
##########
@@ -265,9 +265,10 @@ impl PageWriteSpec {
 /// Contains metadata for a page
 #[derive(Clone)]
 pub struct PageMetadata {
-    /// The number of rows in this page
-    pub num_rows: usize,
-
+    /// The number of rows within the page if known
+    pub num_rows: Option<usize>,
+    /// The number of levels within the page if known
+    pub num_levels: Option<usize>,

Review Comment:
   We use `levels` in the parquet crate instead of the overloaded `values` to avoid confusion over whether nulls are included (they are)



-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] tustvold commented on a diff in pull request #4326: Add separate row_count and level_count to PageMetadata (#4321)

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #4326:
URL: https://github.com/apache/arrow-rs/pull/4326#discussion_r1213093077


##########
parquet/src/column/page.rs:
##########
@@ -277,18 +278,27 @@ impl TryFrom<&PageHeader> for PageMetadata {
 
     fn try_from(value: &PageHeader) -> std::result::Result<Self, Self::Error> {
         match value.type_ {
-            crate::format::PageType::DATA_PAGE => Ok(PageMetadata {
-                num_rows: value.data_page_header.as_ref().unwrap().num_values as usize,
-                is_dict: false,
-            }),
+            crate::format::PageType::DATA_PAGE => {
+                let header = value.data_page_header.as_ref().unwrap();
+                Ok(PageMetadata {
+                    num_rows: None,
+                    num_levels: Some(header.num_values as _),

Review Comment:
   Yeah, this logic is encoded in https://github.com/apache/arrow-rs/pull/4326/files/549124a6cfebe946710595230d5bc4e4126954fb#diff-0cda716759f051812703723d2134741edaec0252f46895392e9917cdf4209c50R317



-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] mapleFU commented on a diff in pull request #4326: Add separate row_count and level_count to PageMetadata (#4321)

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #4326:
URL: https://github.com/apache/arrow-rs/pull/4326#discussion_r1213132724


##########
parquet/src/column/page.rs:
##########
@@ -277,18 +278,27 @@ impl TryFrom<&PageHeader> for PageMetadata {
 
     fn try_from(value: &PageHeader) -> std::result::Result<Self, Self::Error> {
         match value.type_ {
-            crate::format::PageType::DATA_PAGE => Ok(PageMetadata {
-                num_rows: value.data_page_header.as_ref().unwrap().num_values as usize,
-                is_dict: false,
-            }),
+            crate::format::PageType::DATA_PAGE => {
+                let header = value.data_page_header.as_ref().unwrap();
+                Ok(PageMetadata {
+                    num_rows: None,
+                    num_levels: Some(header.num_values as _),

Review Comment:
   I agree the logic handle that case, but using `num_level = header.num_values` might be confusing here



-- 
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: github-unsubscribe@arrow.apache.org

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