Skip to content

Commit c3c82fd

Browse files
committed
comments and safety
1 parent 710d916 commit c3c82fd

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

crates/polars-expr/src/expressions/apply.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,11 @@ impl ApplyExpr {
101101
fn eval_and_flatten(&self, inputs: &mut [Column]) -> PolarsResult<Column> {
102102
self.function.call_udf(inputs)
103103
}
104+
104105
fn apply_single_group_aware<'a>(
105106
&self,
106107
mut ac: AggregationContext<'a>,
107108
) -> PolarsResult<AggregationContext<'a>> {
108-
dbg!("start apply_single_group_aware"); //kdn
109-
dbg!(&self.expr);
110-
// dbg!(&ac);
111-
112109
let s = ac.get_values();
113110
let name = s.name().clone();
114111

@@ -137,7 +134,8 @@ impl ApplyExpr {
137134

138135
// In case of overlapping (rolling) groups, we build groups in a lazy manner to avoid
139136
// memory explosion.
140-
// kdn TODO: TBD - do we want to follow this path for *all* Slice groupstype?
137+
// TODO: add parallel iterator path, and use this path for up to all NotAggregated
138+
// states, pending benchmarking
141139
if matches!(ac.agg_state(), AggState::NotAggregated(_))
142140
&& let GroupsType::Slice { rolling: true, .. } = ac.groups.as_ref().as_ref()
143141
{
@@ -150,7 +148,7 @@ impl ApplyExpr {
150148
return self.finish_apply_groups(ac, ca.with_name(name));
151149
}
152150

153-
// At this point, calling aggregated will not lead to memory explosion.
151+
// At this point, calling aggregated() will not lead to memory explosion.
154152
let agg = ac.aggregated();
155153

156154
// Collection of empty list leads to a null dtype. See: #3687.

crates/polars-expr/src/expressions/group_iter.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl AggregationContext<'_> {
7474
}
7575

7676
impl AggregationContext<'_> {
77-
/// Iterate over groups without greedy aggregation into an AggList.
77+
/// Iterate over groups lazily, i.e., without greedy aggregation into an AggList.
7878
pub(super) fn iter_groups_lazy(
7979
&mut self,
8080
keep_names: bool,
@@ -83,16 +83,15 @@ impl AggregationContext<'_> {
8383
AggState::NotAggregated(_) => {
8484
let groups = self.groups();
8585
let len = groups.len();
86-
let c = self.get_values().rechunk(); //TODO - do we require rechunk?
86+
let c = self.get_values().rechunk();
8787
let name = if keep_names {
8888
c.name().clone()
8989
} else {
9090
PlSmallStr::EMPTY
9191
};
9292
let iter = self.groups().iter();
9393

94-
// Safety:
95-
// kdn TODO
94+
// SAFETY: dtype is correct
9695
unsafe {
9796
Box::new(NotAggLazyIter::new(
9897
c.as_materialized_series().array_ref(0).clone(),
@@ -235,7 +234,7 @@ struct NotAggLazyIter<'a, I: Iterator<Item = GroupsIndicator<'a>>> {
235234

236235
impl<'a, I: Iterator<Item = GroupsIndicator<'a>>> NotAggLazyIter<'a, I> {
237236
/// # Safety
238-
/// kdn TODO
237+
/// Caller must ensure the given `logical` dtype belongs to `array`.
239238
unsafe fn new(
240239
array: ArrayRef,
241240
iter: I,
@@ -266,7 +265,8 @@ impl<'a, I: Iterator<Item = GroupsIndicator<'a>>> Iterator for NotAggLazyIter<'a
266265
if let Some(g) = self.iter.next() {
267266
self.groups_idx += 1;
268267
match g {
269-
GroupsIndicator::Idx(_) => todo!(), //kdn TODO
268+
// TODO: Implement for Idx GroupsType
269+
GroupsIndicator::Idx(_) => todo!(),
270270
GroupsIndicator::Slice(s) => {
271271
let mut arr =
272272
unsafe { self.array.sliced_unchecked(s[0] as usize, s[1] as usize) };

0 commit comments

Comments
 (0)