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

Test: inline everything and add row_unchecked #4539

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
34 changes: 23 additions & 11 deletions arrow-row/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ impl Rows {
self.offsets.push(self.buffer.len())
}

#[inline(always)]
pub fn row(&self, row: usize) -> Row<'_> {
let end = self.offsets[row + 1];
let start = self.offsets[row];
Expand All @@ -908,6 +909,17 @@ impl Rows {
}
}

/// Gets a Row, without bounds checking
#[inline(always)]
pub unsafe fn row_unchecked(&self, row: usize) -> Row<'_> {
let end = self.offsets.get_unchecked(row + 1);
let start = self.offsets.get_unchecked(row);
Row {
data: &self.buffer.get_unchecked(*start..*end),
config: &self.config,
}
}

pub fn num_rows(&self) -> usize {
self.offsets.len() - 1
}
Expand Down Expand Up @@ -1010,7 +1022,7 @@ impl<'a> Row<'a> {
// Manually derive these as don't wish to include `fields`

impl<'a> PartialEq for Row<'a> {
#[inline]
#[inline(always)]
fn eq(&self, other: &Self) -> bool {
self.data.eq(other.data)
}
Expand All @@ -1019,28 +1031,28 @@ impl<'a> PartialEq for Row<'a> {
impl<'a> Eq for Row<'a> {}

impl<'a> PartialOrd for Row<'a> {
#[inline]
#[inline(always)]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.data.partial_cmp(other.data)
}
}

impl<'a> Ord for Row<'a> {
#[inline]
#[inline(always)]
fn cmp(&self, other: &Self) -> Ordering {
self.data.cmp(other.data)
}
}

impl<'a> Hash for Row<'a> {
#[inline]
#[inline(always)]
fn hash<H: Hasher>(&self, state: &mut H) {
self.data.hash(state)
}
}

impl<'a> AsRef<[u8]> for Row<'a> {
#[inline]
#[inline(always)]
fn as_ref(&self) -> &[u8] {
self.data
}
Expand Down Expand Up @@ -1070,7 +1082,7 @@ impl OwnedRow {
// Manually derive these as don't wish to include `fields`. Also we just want to use the same `Row` implementations here.

impl PartialEq for OwnedRow {
#[inline]
#[inline(always)]
fn eq(&self, other: &Self) -> bool {
self.row().eq(&other.row())
}
Expand All @@ -1079,35 +1091,35 @@ impl PartialEq for OwnedRow {
impl Eq for OwnedRow {}

impl PartialOrd for OwnedRow {
#[inline]
#[inline(always)]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.row().partial_cmp(&other.row())
}
}

impl Ord for OwnedRow {
#[inline]
#[inline(always)]
fn cmp(&self, other: &Self) -> Ordering {
self.row().cmp(&other.row())
}
}

impl Hash for OwnedRow {
#[inline]
#[inline(always)]
fn hash<H: Hasher>(&self, state: &mut H) {
self.row().hash(state)
}
}

impl AsRef<[u8]> for OwnedRow {
#[inline]
#[inline(always)]
fn as_ref(&self) -> &[u8] {
&self.data
}
}

/// Returns the null sentinel, negated if `invert` is true
#[inline]
#[inline(always)]
fn null_sentinel(options: SortOptions) -> u8 {
match options.nulls_first {
true => 0,
Expand Down
Loading