Skip to content

Commit 9a1ad7c

Browse files
Rich-T-kidclaude
andauthored
refactor: widen GroupColumn::vectorized_equal_to to &mut self (apache#25238)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> - works towards apache#25219. ## Rationale for this change Mechanical signature change across the trait and all 8 impls as the first step toward letting `DictionaryGroupValuesColumn` reuse its cached `val_to_inner` map in `vectorized_equal_to` instead of rebuilding it per batch (apache#25219). <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. Please explain the problem you are trying to solve in terms of the user-visible behavior, rather than the implementation. For example, "The code in `foo.rs` doesn't handle nulls" is a symptom of the implementation. "COUNT(DISTINCT) returns wrong results when the column contains nulls" is the user-visible problem. --> ## What changes are included in this PR? `&self` -> `&mut self` <!-- There is no need to duplicate the description in the issue here, but it is sometimes worth providing a summary of the individual changes in this PR. --> ## What is the testing strategy for this PR? n/a <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code Briefly describe how this PR is tested, and point to the specific tests you added. For example: 'This new feature is covered by the `sqllogictest` cases added in `foo.slt`'. If this PR does not add tests, explain why. For example, if the change is already covered by existing tests, please mention it. You should also check the `codecov` bot reply on this PR to confirm the changed code is exercised. --> ## Are there any user-facing changes? no <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. If there are any breaking changes to public APIs, please add the `api change` label. --> Co-authored-by: Claude Sonnet 4.6 <[email protected]>
1 parent 5313ae9 commit 9a1ad7c

9 files changed

Lines changed: 38 additions & 38 deletions

File tree

‎datafusion/physical-plan/src/aggregates/group_values/multi_group_by/boolean.rs‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<const NULLABLE: bool> GroupColumn for BooleanGroupValueBuilder<NULLABLE> {
7979
}
8080

8181
fn vectorized_equal_to(
82-
&self,
82+
&mut self,
8383
lhs_rows: &[usize],
8484
array: &ArrayRef,
8585
rhs_rows: &[usize],
@@ -235,7 +235,7 @@ mod tests {
235235
};
236236

237237
let equal_to =
238-
|builder: &BooleanGroupValueBuilder<true>,
238+
|builder: &mut BooleanGroupValueBuilder<true>,
239239
lhs_rows: &[usize],
240240
input_array: &ArrayRef,
241241
rhs_rows: &[usize],
@@ -261,7 +261,7 @@ mod tests {
261261
};
262262

263263
let equal_to =
264-
|builder: &BooleanGroupValueBuilder<true>,
264+
|builder: &mut BooleanGroupValueBuilder<true>,
265265
lhs_rows: &[usize],
266266
input_array: &ArrayRef,
267267
rhs_rows: &[usize],
@@ -281,7 +281,7 @@ mod tests {
281281
where
282282
A: FnMut(&mut BooleanGroupValueBuilder<true>, &ArrayRef, &[usize]),
283283
E: FnMut(
284-
&BooleanGroupValueBuilder<true>,
284+
&mut BooleanGroupValueBuilder<true>,
285285
&[usize],
286286
&ArrayRef,
287287
&[usize],
@@ -332,7 +332,7 @@ mod tests {
332332
// Check
333333
let mut equal_to_results = make_true_buffer(builder.len());
334334
equal_to(
335-
&builder,
335+
&mut builder,
336336
&[0, 1, 2, 3, 4, 5],
337337
&input_array,
338338
&[0, 1, 2, 3, 4, 5],
@@ -359,7 +359,7 @@ mod tests {
359359
};
360360

361361
let equal_to =
362-
|builder: &BooleanGroupValueBuilder<false>,
362+
|builder: &mut BooleanGroupValueBuilder<false>,
363363
lhs_rows: &[usize],
364364
input_array: &ArrayRef,
365365
rhs_rows: &[usize],
@@ -385,7 +385,7 @@ mod tests {
385385
};
386386

387387
let equal_to =
388-
|builder: &BooleanGroupValueBuilder<false>,
388+
|builder: &mut BooleanGroupValueBuilder<false>,
389389
lhs_rows: &[usize],
390390
input_array: &ArrayRef,
391391
rhs_rows: &[usize],
@@ -405,7 +405,7 @@ mod tests {
405405
where
406406
A: FnMut(&mut BooleanGroupValueBuilder<false>, &ArrayRef, &[usize]),
407407
E: FnMut(
408-
&BooleanGroupValueBuilder<false>,
408+
&mut BooleanGroupValueBuilder<false>,
409409
&[usize],
410410
&ArrayRef,
411411
&[usize],
@@ -437,7 +437,7 @@ mod tests {
437437
// Check
438438
let mut equal_to_results = make_true_buffer(builder.len());
439439
equal_to(
440-
&builder,
440+
&mut builder,
441441
&[0, 1, 2, 3],
442442
&input_array,
443443
&[0, 1, 2, 3],

‎datafusion/physical-plan/src/aggregates/group_values/multi_group_by/bytes.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ where
280280
}
281281

282282
fn vectorized_equal_to(
283-
&self,
283+
&mut self,
284284
lhs_rows: &[usize],
285285
array: &ArrayRef,
286286
rhs_rows: &[usize],
@@ -581,7 +581,7 @@ mod tests {
581581
};
582582

583583
let equal_to =
584-
|builder: &ByteGroupValueBuilder<i32>,
584+
|builder: &mut ByteGroupValueBuilder<i32>,
585585
lhs_rows: &[usize],
586586
input_array: &ArrayRef,
587587
rhs_rows: &[usize],
@@ -607,7 +607,7 @@ mod tests {
607607
};
608608

609609
let equal_to =
610-
|builder: &ByteGroupValueBuilder<i32>,
610+
|builder: &mut ByteGroupValueBuilder<i32>,
611611
lhs_rows: &[usize],
612612
input_array: &ArrayRef,
613613
rhs_rows: &[usize],
@@ -689,7 +689,7 @@ mod tests {
689689
where
690690
A: FnMut(&mut ByteGroupValueBuilder<i32>, &ArrayRef, &[usize]),
691691
E: FnMut(
692-
&ByteGroupValueBuilder<i32>,
692+
&mut ByteGroupValueBuilder<i32>,
693693
&[usize],
694694
&ArrayRef,
695695
&[usize],
@@ -741,7 +741,7 @@ mod tests {
741741
// Check
742742
let mut equal_to_results = make_true_buffer(builder.len());
743743
equal_to(
744-
&builder,
744+
&mut builder,
745745
&[0, 1, 2, 3, 4, 5],
746746
&input_array,
747747
&[0, 1, 2, 3, 4, 5],

‎datafusion/physical-plan/src/aggregates/group_values/multi_group_by/bytes_view.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ impl<B: ByteViewType> GroupColumn for ByteViewGroupValueBuilder<B> {
584584
}
585585

586586
fn vectorized_equal_to(
587-
&self,
587+
&mut self,
588588
group_indices: &[usize],
589589
array: &ArrayRef,
590590
rows: &[usize],
@@ -714,7 +714,7 @@ mod tests {
714714
};
715715

716716
let equal_to =
717-
|builder: &ByteViewGroupValueBuilder<StringViewType>,
717+
|builder: &mut ByteViewGroupValueBuilder<StringViewType>,
718718
lhs_rows: &[usize],
719719
input_array: &ArrayRef,
720720
rhs_rows: &[usize],
@@ -740,7 +740,7 @@ mod tests {
740740
};
741741

742742
let equal_to =
743-
|builder: &ByteViewGroupValueBuilder<StringViewType>,
743+
|builder: &mut ByteViewGroupValueBuilder<StringViewType>,
744744
lhs_rows: &[usize],
745745
input_array: &ArrayRef,
746746
rhs_rows: &[usize],
@@ -823,7 +823,7 @@ mod tests {
823823
where
824824
A: FnMut(&mut ByteViewGroupValueBuilder<StringViewType>, &ArrayRef, &[usize]),
825825
E: FnMut(
826-
&ByteViewGroupValueBuilder<StringViewType>,
826+
&mut ByteViewGroupValueBuilder<StringViewType>,
827827
&[usize],
828828
&ArrayRef,
829829
&[usize],
@@ -908,7 +908,7 @@ mod tests {
908908
// Check
909909
let mut equal_to_results = make_true_buffer(input_array.len());
910910
equal_to(
911-
&builder,
911+
&mut builder,
912912
&[0, 1, 2, 3, 4, 5, 6, 7, 7, 7, 8, 8],
913913
&input_array,
914914
&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],

‎datafusion/physical-plan/src/aggregates/group_values/multi_group_by/dictionary.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl<K: ArrowDictionaryKeyType + Send + Sync> GroupColumn
328328
}
329329

330330
fn vectorized_equal_to(
331-
&self,
331+
&mut self,
332332
lhs_rows: &[usize],
333333
array: &ArrayRef,
334334
rhs_rows: &[usize],

‎datafusion/physical-plan/src/aggregates/group_values/multi_group_by/fixed_size_binary.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl GroupColumn for FixedSizeBinaryGroupValueBuilder {
140140
}
141141

142142
fn vectorized_equal_to(
143-
&self,
143+
&mut self,
144144
lhs_rows: &[usize],
145145
array: &ArrayRef,
146146
rhs_rows: &[usize],
@@ -295,7 +295,7 @@ mod tests {
295295
};
296296

297297
let equal_to =
298-
|builder: &FixedSizeBinaryGroupValueBuilder,
298+
|builder: &mut FixedSizeBinaryGroupValueBuilder,
299299
lhs_rows: &[usize],
300300
input_array: &ArrayRef,
301301
rhs_rows: &[usize],
@@ -321,7 +321,7 @@ mod tests {
321321
};
322322

323323
let equal_to =
324-
|builder: &FixedSizeBinaryGroupValueBuilder,
324+
|builder: &mut FixedSizeBinaryGroupValueBuilder,
325325
lhs_rows: &[usize],
326326
input_array: &ArrayRef,
327327
rhs_rows: &[usize],
@@ -341,7 +341,7 @@ mod tests {
341341
where
342342
A: FnMut(&mut FixedSizeBinaryGroupValueBuilder, &ArrayRef, &[usize]),
343343
E: FnMut(
344-
&FixedSizeBinaryGroupValueBuilder,
344+
&mut FixedSizeBinaryGroupValueBuilder,
345345
&[usize],
346346
&ArrayRef,
347347
&[usize],
@@ -388,7 +388,7 @@ mod tests {
388388
// Check
389389
let mut equal_to_results = make_true_buffer(builder.len());
390390
equal_to(
391-
&builder,
391+
&mut builder,
392392
&[0, 1, 2, 3, 4, 5],
393393
&input_array,
394394
&[0, 1, 2, 3, 4, 5],

‎datafusion/physical-plan/src/aggregates/group_values/multi_group_by/list.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl<O: OffsetSizeTrait> GroupColumn for ListGroupValueBuilder<O> {
152152
}
153153

154154
fn vectorized_equal_to(
155-
&self,
155+
&mut self,
156156
lhs_rows: &[usize],
157157
array: &ArrayRef,
158158
rhs_rows: &[usize],

‎datafusion/physical-plan/src/aggregates/group_values/multi_group_by/mod.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub trait GroupColumn: Send + Sync {
8787
/// And if found nth result in `equal_to_results` is already
8888
/// `false`, the check for nth row will be skipped.
8989
fn vectorized_equal_to(
90-
&self,
90+
&mut self,
9191
lhs_rows: &[usize],
9292
array: &ArrayRef,
9393
rhs_rows: &[usize],
@@ -664,7 +664,7 @@ impl<const STREAMING: bool> GroupValuesColumn<STREAMING> {
664664
equal_to_results.truncate(0);
665665
equal_to_results.append_n(n, true);
666666

667-
for (col_idx, group_col) in self.group_values.iter().enumerate() {
667+
for (col_idx, group_col) in self.group_values.iter_mut().enumerate() {
668668
group_col.vectorized_equal_to(
669669
&self.vectorized_operation_buffers.equal_to_group_indices,
670670
&cols[col_idx],

‎datafusion/physical-plan/src/aggregates/group_values/multi_group_by/primitive.rs‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ where
187187
}
188188

189189
fn vectorized_equal_to(
190-
&self,
190+
&mut self,
191191
lhs_rows: &[usize],
192192
array: &ArrayRef,
193193
rhs_rows: &[usize],
@@ -341,7 +341,7 @@ mod tests {
341341
};
342342

343343
let equal_to =
344-
|builder: &PrimitiveGroupValueBuilder<Float32Type, true>,
344+
|builder: &mut PrimitiveGroupValueBuilder<Float32Type, true>,
345345
lhs_rows: &[usize],
346346
input_array: &ArrayRef,
347347
rhs_rows: &[usize],
@@ -367,7 +367,7 @@ mod tests {
367367
};
368368

369369
let equal_to =
370-
|builder: &PrimitiveGroupValueBuilder<Float32Type, true>,
370+
|builder: &mut PrimitiveGroupValueBuilder<Float32Type, true>,
371371
lhs_rows: &[usize],
372372
input_array: &ArrayRef,
373373
rhs_rows: &[usize],
@@ -387,7 +387,7 @@ mod tests {
387387
where
388388
A: FnMut(&mut PrimitiveGroupValueBuilder<Float32Type, true>, &ArrayRef, &[usize]),
389389
E: FnMut(
390-
&PrimitiveGroupValueBuilder<Float32Type, true>,
390+
&mut PrimitiveGroupValueBuilder<Float32Type, true>,
391391
&[usize],
392392
&ArrayRef,
393393
&[usize],
@@ -442,7 +442,7 @@ mod tests {
442442
// Check
443443
let mut equal_to_results = make_true_buffer(builder.len());
444444
equal_to(
445-
&builder,
445+
&mut builder,
446446
&[0, 1, 2, 3, 4, 5, 6],
447447
&input_array,
448448
&[0, 1, 2, 3, 4, 5, 6],
@@ -470,7 +470,7 @@ mod tests {
470470
};
471471

472472
let equal_to =
473-
|builder: &PrimitiveGroupValueBuilder<Int64Type, false>,
473+
|builder: &mut PrimitiveGroupValueBuilder<Int64Type, false>,
474474
lhs_rows: &[usize],
475475
input_array: &ArrayRef,
476476
rhs_rows: &[usize],
@@ -496,7 +496,7 @@ mod tests {
496496
};
497497

498498
let equal_to =
499-
|builder: &PrimitiveGroupValueBuilder<Int64Type, false>,
499+
|builder: &mut PrimitiveGroupValueBuilder<Int64Type, false>,
500500
lhs_rows: &[usize],
501501
input_array: &ArrayRef,
502502
rhs_rows: &[usize],
@@ -516,7 +516,7 @@ mod tests {
516516
where
517517
A: FnMut(&mut PrimitiveGroupValueBuilder<Int64Type, false>, &ArrayRef, &[usize]),
518518
E: FnMut(
519-
&PrimitiveGroupValueBuilder<Int64Type, false>,
519+
&mut PrimitiveGroupValueBuilder<Int64Type, false>,
520520
&[usize],
521521
&ArrayRef,
522522
&[usize],
@@ -540,7 +540,7 @@ mod tests {
540540
// Check
541541
let mut equal_to_results = make_true_buffer(builder.len());
542542
equal_to(
543-
&builder,
543+
&mut builder,
544544
&[0, 1],
545545
&input_array,
546546
&[0, 1],

‎datafusion/physical-plan/src/aggregates/group_values/multi_group_by/row_backed.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl GroupColumn for RowsGroupColumn {
251251
}
252252

253253
fn vectorized_equal_to(
254-
&self,
254+
&mut self,
255255
lhs_rows: &[usize],
256256
array: &ArrayRef,
257257
rhs_rows: &[usize],

0 commit comments

Comments
 (0)