nevi-me commented on a change in pull request #490:
URL: https://github.com/apache/arrow-rs/pull/490#discussion_r656390969
##########
File path: arrow/src/record_batch.rs
##########
@@ -244,6 +244,18 @@ impl RecordBatch {
&self.columns[..]
}
+ /// Return a new RecordBatch where each column is sliced
+ /// according to `offset` and `length`
+ pub fn slice(&self, offset: usize, length: usize) -> Result<RecordBatch> {
+ let schema = self.schema();
+ let num_columns = self.num_columns();
+ let new_columns = (0..num_columns)
Review comment:
My local version is
```rust
/// Slice all the arrays in the record batch.
pub fn slice(&self, offset: usize, len: usize) -> Self {
let columns = self
.columns()
.iter()
.map(|array| array.slice(offset, len))
.collect();
Self {
schema: self.schema.clone(),
columns,
}
}
```
Does it make sense to go through `RecordBatch::try_new()`? It incurs some
overhead checking that the schema and arrays match, when they already should
match
--
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]