Skip to content

Remove ordinal grouping operator #131133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ static void selfTest() {
try {
for (String groups : ValuesAggregatorBenchmark.class.getField("groups").getAnnotationsByType(Param.class)[0].value()) {
for (String dataType : ValuesAggregatorBenchmark.class.getField("dataType").getAnnotationsByType(Param.class)[0].value()) {
run(Integer.parseInt(groups), dataType, 10, 0);
run(Integer.parseInt(groups), dataType, 10, 1);
run(Integer.parseInt(groups), dataType, 10);
}
}
} catch (NoSuchFieldException e) {
Expand All @@ -114,10 +113,7 @@ static void selfTest() {
@Param({ BYTES_REF, INT, LONG })
public String dataType;

@Param({ "0", "1" })
public int numOrdinalMerges;

private static Operator operator(DriverContext driverContext, int groups, String dataType, int numOrdinalMerges) {
private static Operator operator(DriverContext driverContext, int groups, String dataType) {
if (groups == 1) {
return new AggregationOperator(
List.of(supplier(dataType).aggregatorFactory(AggregatorMode.SINGLE, List.of(0)).apply(driverContext)),
Expand All @@ -132,20 +128,8 @@ private static Operator operator(DriverContext driverContext, int groups, String
) {
@Override
public Page getOutput() {
mergeOrdinal();
return super.getOutput();
}

// simulate OrdinalsGroupingOperator
void mergeOrdinal() {
var merged = supplier(dataType).groupingAggregatorFactory(AggregatorMode.SINGLE, List.of(1)).apply(driverContext);
for (int i = 0; i < numOrdinalMerges; i++) {
for (int p = 0; p < groups; p++) {
merged.addIntermediateRow(p, aggregators.getFirst(), p);
}
}
aggregators.set(0, merged);
}
};
}

Expand Down Expand Up @@ -352,12 +336,12 @@ private static Block groupingBlock(int groups) {

@Benchmark
public void run() {
run(groups, dataType, OP_COUNT, numOrdinalMerges);
run(groups, dataType, OP_COUNT);
}

private static void run(int groups, String dataType, int opCount, int numOrdinalMerges) {
private static void run(int groups, String dataType, int opCount) {
DriverContext driverContext = driverContext();
try (Operator operator = operator(driverContext, groups, dataType, numOrdinalMerges)) {
try (Operator operator = operator(driverContext, groups, dataType)) {
Page page = page(groups, dataType);
for (int i = 0; i < opCount; i++) {
operator.addInput(page.shallowCopy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ public void close() {}
}
}

/**
* Add the position-th row from the intermediate output of the given aggregator to this aggregator at the groupId position
*/
public void addIntermediateRow(int groupId, GroupingAggregator input, int position) {
aggregatorFunction.addIntermediateRowInput(groupId, input.aggregatorFunction, position);
}

/**
* Build the results for this aggregation.
* @param selected the groupIds that have been selected to be included in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ default void add(int positionOffset, IntBlock groupIds) {

/**
* Add the position-th row from the intermediate output of the given aggregator function to the groupId
* TODO: Remove this method as the grouping operator has been removed
Copy link
Member Author

@dnhatn dnhatn Jul 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove this method in a follow-up.

*/
void addIntermediateRowInput(int groupId, GroupingAggregatorFunction input, int position);

Expand Down
Loading