Skip to content

Commit

Permalink
impl equal to.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachelint committed Oct 8, 2024
1 parent ffcc1a2 commit ac96b5d
Showing 1 changed file with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ impl ByteGroupValueViewBuilder {
let value: &[u8] = arr.value(row).as_ref();

let value_len = value.len();
let view = if value_len > 12 {
let view = if value_len <= 12 {
make_view(value, 0, 0)
} else {
// Ensure big enough block to hold the value firstly
self.ensure_in_progress_big_enough(value_len);

Expand All @@ -455,8 +457,6 @@ impl ByteGroupValueViewBuilder {
self.in_progress.extend_from_slice(value);

make_view(value, block_id, offset)
} else {
make_view(value, 0, 0)
};

// Append view
Expand All @@ -477,6 +477,48 @@ impl ByteGroupValueViewBuilder {
self.completed.push(buffer);
}
}

fn equal_to_inner<B>(&self, lhs_row: usize, array: &ArrayRef, rhs_row: usize) -> bool
where
B: ByteViewType,
{
let array = array.as_byte_view::<B>();

// Check if nulls equal firstly
let exist_null = self.nulls.is_null(lhs_row);
let input_null = array.is_null(rhs_row);
if let Some(result) = nulls_equal_to(exist_null, input_null) {
return result;
}

// Otherwise, we need to check their values
let exist_view = self.views[lhs_row];
let exist_view_len = exist_view as u32;

let input_view = array.views()[rhs_row];
let input_view_len = exist_view as u32;

// The check logic
// - Check len equality
// - If non-inlined, check prefix and then check value in buffer
// when needed
// - If inlined, check inlined value
if exist_view_len != input_view_len {
return false;
}

if exist_view_len > 12 {
let exist_prefix = unsafe { GenericByteViewArray::<B>::inline_value(&exist_view, 4) };
let input_prefix = unsafe { GenericByteViewArray::<B>::inline_value(&input_view, 4) };

if exist_prefix != input_prefix {
return false;
}

let exist_full: &[u8] = unsafe { array.value_unchecked(lhs_row).as_ref() };
let input_full: &[u8] = unsafe { right.value_unchecked(right_idx).as_ref() };
}
}
}

/// Determines if the nullability of the existing and new input array can be used
Expand Down

0 comments on commit ac96b5d

Please sign in to comment.