-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
unique.rs
29 lines (26 loc) · 869 Bytes
/
unique.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use super::*;
pub(crate) struct UniqueExec {
pub(crate) input: Box<dyn Executor>,
pub(crate) options: DistinctOptions,
}
impl Executor for UniqueExec {
fn execute(&mut self, state: &mut ExecutionState) -> PolarsResult<DataFrame> {
state.should_stop()?;
#[cfg(debug_assertions)]
{
if state.verbose() {
eprintln!("run UniqueExec")
}
}
let df = self.input.execute(state)?;
let subset = self.options.subset.as_ref().map(|v| &***v);
let keep = self.options.keep_strategy;
state.record(
|| match self.options.maintain_order {
true => df.unique_stable(subset, keep, self.options.slice),
false => df.unique(subset, keep, self.options.slice),
},
Cow::Borrowed("unique()"),
)
}
}