adriangb commented on code in PR #6999:
URL: https://github.com/apache/arrow-rs/pull/6999#discussion_r1922875367


##########
parquet/src/file/metadata/reader.rs:
##########
@@ -409,10 +409,21 @@ impl ParquetMetaDataReader {
             None => return Ok(()),
         };
 
-        let bytes = match &remainder {
-            Some((remainder_start, remainder)) if *remainder_start <= 
range.start => {
-                let offset = range.start - *remainder_start;
-                remainder.slice(offset..range.end - *remainder_start + offset)
+        let bytes = match &fetched {
+            Some((fetched_start, fetched)) if *fetched_start <= range.start => 
{
+                // `fetched`` is an amount of data spanning from fetched_start 
to the end of the file
+                // We want to slice out the range we need from that data, but 
need to adjust the
+                // range we are looking for to be relative to fetched_start.
+                let fetched_start = *fetched_start;
+                let range = range.start - fetched_start..range.end - 
fetched_start;
+                // santity check: `fetched` should always go until the end of 
the file
+                // so if our range is beyond that, something is wrong!
+                assert!(
+                    range.end <= fetched_start + fetched.len(),
+                    "range: {range:?}, fetched: {}, fetched_start: 
{fetched_start}",
+                    fetched.len()
+                );
+                fetched.slice(range)

Review Comment:
   done 😄 



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