tustvold commented on code in PR #5222:
URL: https://github.com/apache/arrow-rs/pull/5222#discussion_r1441983232


##########
object_store/src/memory.rs:
##########
@@ -225,23 +216,8 @@ impl ObjectStore for InMemory {
 
         let (range, data) = match options.range {
             Some(range) => {
-                let len = entry.data.len();
-                match range {
-                    Bounded(r) => {
-                        ensure!(r.end <= len, OutOfRangeSnafu { range: r, len 
});
-                        ensure!(r.start <= r.end, BadRangeSnafu { range: r });
-                        (r.clone(), entry.data.slice(r))
-                    }
-                    Offset(o) => {
-                        ensure!(o < len, OutOfRangeSnafu { range: o..len, len 
});
-                        (o..len, entry.data.slice(o..len))
-                    }
-                    Suffix(n) => {
-                        ensure!(n < len, BadSuffixSnafu { nbytes: n });
-                        let start = len - n;
-                        (start..len, entry.data.slice(start..len))
-                    }
-                }
+                let r = range.as_range(entry.data.len()).context(RangeSnafu)?;

Review Comment:
   It seemed simpler to just have this logic in one place, as opposed to 
duplicating 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: [email protected]

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

Reply via email to