neilconway commented on code in PR #11408:
URL: https://github.com/apache/arrow-rs/pull/11408#discussion_r4231413063


##########
parquet/src/arrow/record_reader/definition_levels.rs:
##########
@@ -257,10 +257,16 @@ impl DefinitionLevelDecoder for 
DefinitionLevelBufferDecoder {
                 let start = levels.len();
                 let (values_read, levels_read) = 
decoder.read_def_levels(levels, num_levels)?;
 
-                // Safety: slice iterator has a trusted length
-                unsafe {
-                    nulls
-                        .extend_trusted_len(levels[start..].iter().map(|level| 
level == max_level));
+                if values_read == levels_read {
+                    // Every level is at `max_level`
+                    nulls.append_n(levels_read, true);
+                } else {
+                    // Safety: slice iterator has a trusted length
+                    unsafe {
+                        nulls.extend_trusted_len(
+                            levels[start..].iter().map(|level| level == 
max_level),
+                        );
+                    }

Review Comment:
   Good idea! Added to the PR, thanks!



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to