Skip to content

Commit f22ca3c

Browse files
committed
fix
1 parent 374b8be commit f22ca3c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

datafusion/physical-plan/src/sorts/cursor.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ impl CursorValues for StringViewArray {
293293
self.views().len()
294294
}
295295

296+
#[inline(always)]
296297
fn eq(l: &Self, l_idx: usize, r: &Self, r_idx: usize) -> bool {
297298
// SAFETY: Both l_idx and r_idx are guaranteed to be within bounds,
298299
// and any null-checks are handled in the outer layers.
@@ -313,6 +314,7 @@ impl CursorValues for StringViewArray {
313314
unsafe { GenericByteViewArray::compare_unchecked(l, l_idx, r, r_idx).is_eq() }
314315
}
315316

317+
#[inline(always)]
316318
fn eq_to_previous(cursor: &Self, idx: usize) -> bool {
317319
// SAFETY: The caller guarantees that idx > 0 and the indices are valid.
318320
// Already checked it in is_eq_to_prev_one function
@@ -335,14 +337,19 @@ impl CursorValues for StringViewArray {
335337
}
336338
}
337339

340+
#[inline(always)]
338341
fn compare(l: &Self, l_idx: usize, r: &Self, r_idx: usize) -> Ordering {
339342
// SAFETY: Prior assertions guarantee that l_idx and r_idx are valid indices.
340343
// Null-checks are assumed to have been handled in the wrapper (e.g., ArrayValues).
341344
// And the bound is checked in is_finished, it is safe to call get_unchecked
342345
if l.data_buffers().is_empty() && r.data_buffers().is_empty() {
343346
let l_view = unsafe { l.views().get_unchecked(l_idx) };
344347
let r_view = unsafe { r.views().get_unchecked(r_idx) };
345-
return l_view.cmp(r_view);
348+
let l_len = *l_view as u32;
349+
let r_len = *r_view as u32;
350+
let l_data = unsafe { StringViewArray::inline_value(l_view, l_len as usize) };
351+
let r_data = unsafe { StringViewArray::inline_value(r_view, r_len as usize) };
352+
return l_data.cmp(r_data);
346353
}
347354

348355
unsafe { GenericByteViewArray::compare_unchecked(l, l_idx, r, r_idx) }

0 commit comments

Comments
 (0)