Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
timoninmaxim committed Dec 28, 2024
1 parent 113d914 commit 5a3a43d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.util.ImmutableBitSet;
Expand Down Expand Up @@ -251,6 +252,9 @@ private class Grouping {
/** */
private final BiFunction<GroupKey, List<AccumulatorWrapper<Row>>, List<AccumulatorWrapper<Row>>> getOrCreateGroup;

/** */
private final Function<GroupKey, List<AccumulatorWrapper<Row>>> createGroup;

/** */
private Grouping(byte grpId, ImmutableBitSet grpFields) {
this.grpId = grpId;
Expand All @@ -259,6 +263,8 @@ private Grouping(byte grpId, ImmutableBitSet grpFields) {
grpKeyBld = GroupKey.builder(grpFields.cardinality());
handler = context().rowHandler();

createGroup = (k) -> create();

getOrCreateGroup = (k, v) -> {
if (v == null) {
grpKeyBld = GroupKey.builder(grpFields.cardinality());
Expand Down Expand Up @@ -332,7 +338,7 @@ private void addOnReducer(Row row) {

GroupKey grpKey = (GroupKey)handler.get(1, row);

List<AccumulatorWrapper<Row>> wrappers = groups.get(grpKey);
List<AccumulatorWrapper<Row>> wrappers = groups.computeIfAbsent(grpKey, createGroup);
Accumulator<Row>[] accums = hasAccumulators() ? (Accumulator<Row>[])handler.get(2, row) : null;

for (int i = 0; i < F.size(wrappers); i++) {
Expand Down

0 comments on commit 5a3a43d

Please sign in to comment.