MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / test_sort

Function test_sort

src/expr/src/row/collection.rs:436–462  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

434
435 #[mz_ore::test]
436 fn test_sort() {
437 let a = Row::pack_slice(&[Datum::False, Datum::String("hello world"), Datum::Int16(42)]);
438 let b = Row::pack_slice(&[Datum::MzTimestamp(mz_repr::Timestamp::new(10))]);
439 let c = Row::pack_slice(&[Datum::True, Datum::String("hello world"), Datum::Int16(42)]);
440 let d = Row::pack_slice(&[Datum::MzTimestamp(mz_repr::Timestamp::new(9))]);
441
442 let cols = {
443 let mut part = [&a, &b];
444 part.sort_by(|a, b| a.cmp(b));
445 let part1 = RowCollection::from(part);
446 let mut part = [&c, &d];
447 part.sort_by(|a, b| a.cmp(b));
448 let part2 = RowCollection::from(part);
449 vec![part1, part2]
450 };
451 let mut rows = [a, b, c, d];
452
453 let sorted_view = RowCollection::merge_sorted(&cols, &[]);
454 rows.sort_by(|a, b| a.cmp(b));
455
456 for i in 0..rows.len() {
457 let (row_x, _) = sorted_view.get(i).unwrap();
458 let row_y = rows.get(i).unwrap();
459
460 assert_eq!(row_x, row_y.borrow());
461 }
462 }
463
464 #[mz_ore::test]
465 fn test_sorted_iter() {

Callers

nothing calls this directly

Calls 6

StringClass · 0.85
unwrapMethod · 0.80
MzTimestampClass · 0.50
cmpMethod · 0.45
lenMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected