use itertools::Itertools; use noir_compute::operator::source::IteratorSource; use utils::TestHelper; mod utils; #[test] fn unkey_keyed_stream() { TestHelper::local_remote_env(|env| { let source = IteratorSource::new(0..10u8); let res = env .stream(source) .shuffle() .key_by(|&n| n.to_string()) .unkey() .collect_vec(); env.execute_blocking(); if let Some(res) = res.get() { let res = res.into_iter().sorted().collect_vec(); let expected = (0..10u8).map(|n| (n.to_string(), n)).collect_vec(); assert_eq!(res, expected); } }); } #[test] fn drop_key_keyed_stream() { TestHelper::local_remote_env(|env| { let source = IteratorSource::new(0..10u8); let res = env .stream(source) .shuffle() .key_by(|&n| n % 2) .drop_key() .collect_vec(); env.execute_blocking(); if let Some(res) = res.get() { let res = res.into_iter().sorted().collect_vec(); assert_eq!(res, (0..10u8).collect_vec()); } }); }