Skip to content
Open
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
16 changes: 16 additions & 0 deletions native-engine/datafusion-ext-plans/src/sort_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,7 @@ mod test {
prelude::SessionContext,
};

use super::common_prefix_len;
use crate::sort_exec::SortExec;

fn build_table_i32(
Expand Down Expand Up @@ -1453,6 +1454,21 @@ mod test {
Arc::new(TestMemoryExec::try_new(&[vec![batch]], schema, None).unwrap())
}

// Verify that `common_prefix_len` correctly computes prefixes of small fixed
// sizes. This ensures compiler optimizations do not incorrectly transform
// the function for small lengths.
#[test]
fn has_common_prefix_len_been_optimized_into_bogusness() {
let cpl = common_prefix_len(&[0; 8], &[0; 8]);
assert_eq!(cpl, 8);
let cpl = common_prefix_len(&[0; 4], &[0; 4]);
assert_eq!(cpl, 4);
let cpl = common_prefix_len(&[0; 2], &[0; 2]);
assert_eq!(cpl, 2);
let cpl = common_prefix_len(&[0; 1], &[0; 1]);
assert_eq!(cpl, 1);
}

#[tokio::test]
async fn test_sort_i32() -> Result<()> {
MemManager::init(100);
Expand Down
Loading