yordan-pavlov commented on a change in pull request #384:
URL: https://github.com/apache/arrow-rs/pull/384#discussion_r642402579
##########
File path: parquet/src/util/memory.rs
##########
@@ -292,19 +292,28 @@ impl<T> BufferPtr<T> {
}
/// Returns slice of data in this buffer.
+ #[inline]
pub fn data(&self) -> &[T] {
&self.data[self.start..self.start + self.len]
}
/// Updates this buffer with new `start` position and length `len`.
///
/// Range should be within current start position and length.
+ #[inline]
pub fn with_range(mut self, start: usize, len: usize) -> Self {
- assert!(start <= self.len);
- assert!(start + len <= self.len);
+ self.set_range(start, len);
+ self
+ }
+
+ /// Updates this buffer with new `start` position and length `len`.
+ ///
+ /// Range should be within current start position and length.
+ #[inline]
+ pub fn set_range(&mut self, start: usize, len: usize) {
+ assert!(self.start <= start && start + len <= self.start + self.len);
Review comment:
`start + len <= self.start + self.len` covers more cases, more
specifically that start + len should stay within the existing range, so that
it's not possible to change from e.g. (start: 0, len: 100) to (start: 1000,
len: 100), which would be an invalid range because the new start value of 1000
would be outside of the original range (but would be allowed if the assert was
`self.start <= start && len <= self.len`).
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]