Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FixedWidthRows for the arrow-row #4524

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add row_data() for IRows
  • Loading branch information
kyotoYaho committed Jul 17, 2023
commit 5b2ae319d2464ae2ec0bc55f199494ee0f5f5316
23 changes: 16 additions & 7 deletions arrow-row/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,8 @@ pub trait IRows: Debug + Send {
/// Get a [`Row`]
fn row(&self, row: usize) -> Row<'_>;

fn row_data(&self, row: usize) -> &[u8];

fn num_rows(&self) -> usize;

fn iter(&self) -> RowsIter<'_>;
Expand Down Expand Up @@ -1017,14 +1019,18 @@ impl IRows for Rows {
}

fn row(&self, row: usize) -> Row<'_> {
let end = self.offsets[row + 1];
let start = self.offsets[row];
Row {
data: &self.buffer[start..end],
data: self.row_data(row),
config: &self.config,
}
}

fn row_data(&self, row: usize) -> &[u8] {
let end = self.offsets[row + 1];
let start = self.offsets[row];
&self.buffer[start..end]
}

fn num_rows(&self) -> usize {
self.offsets.len() - 1
}
Expand Down Expand Up @@ -1075,15 +1081,18 @@ impl IRows for FixedWidthRows {
}

fn row(&self, row: usize) -> Row<'_> {
let start = self.width * row;
let end = start + self.width;

Row {
data: &self.buffer[start..end],
data: self.row_data(row),
config: &self.config,
}
}

fn row_data(&self, row: usize) -> &[u8] {
let start = self.width * row;
let end = start + self.width;
&self.buffer[start..end]
}

fn num_rows(&self) -> usize {
self.length
}
Expand Down
Loading