This is an automated email from the ASF dual-hosted git repository.

akurmustafa pushed a commit to branch feature/slice
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git

commit e04a305e0c58191bfd320d0fe24019e1fa98eeee
Author: Mustafa Akur <[email protected]>
AuthorDate: Fri Jul 5 14:40:28 2024 +0300

    Add slice support
---
 arrow-row/src/lib.rs | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/arrow-row/src/lib.rs b/arrow-row/src/lib.rs
index a6fd03b5bc..65fa9a1b5f 100644
--- a/arrow-row/src/lib.rs
+++ b/arrow-row/src/lib.rs
@@ -868,6 +868,21 @@ impl Rows {
             + self.buffer.len()
             + self.offsets.len() * std::mem::size_of::<usize>()
     }
+
+    pub fn slice(&self, offset: usize, n: usize) -> Rows{
+        let mut buffer_values = vec![];
+        let mut offsets = vec![0];
+        for idx in 0..n{
+            let res = 
self.buffer[self.offsets[idx]..self.offsets[idx+1]].to_vec();
+            buffer_values.extend(res);
+            offsets.push(buffer_values.len());
+        }
+        Rows{
+            buffer: buffer_values,
+            offsets: offsets,
+            config: self.config.clone(),
+        }
+    }
 }
 
 impl<'a> IntoIterator for &'a Rows {

Reply via email to