Skip to content

Commit 97254f2

Browse files
committed
Remove redundant argumentChannels from OrderedWindowAccumulator
1 parent 03d71f0 commit 97254f2

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

core/trino-main/src/main/java/io/trino/operator/aggregation/OrderedWindowAccumulator.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public class OrderedWindowAccumulator
3838
private final PagesIndex pagesIndex;
3939
private final PagesIndexOrdering pagesIndexOrdering;
4040
private final List<Type> argumentTypes;
41-
private final List<Integer> argumentChannels;
4241

4342
private WindowAccumulator delegate;
4443
private final WindowAccumulator initialDelegate;
@@ -50,7 +49,6 @@ public OrderedWindowAccumulator(
5049
PagesIndex.Factory pagesIndexFactory,
5150
WindowAccumulator delegate,
5251
List<Type> argumentTypes,
53-
List<Integer> argumentChannels,
5452
List<Integer> sortKeysArguments,
5553
List<SortOrder> sortOrders)
5654
{
@@ -59,31 +57,25 @@ public OrderedWindowAccumulator(
5957
createPagesIndexWithOrdering(
6058
pagesIndexFactory,
6159
argumentTypes,
62-
requireNonNull(argumentChannels, "argumentChannels is null").size(),
6360
sortKeysArguments,
6461
sortOrders),
6562
delegate,
66-
argumentTypes,
67-
argumentChannels);
63+
argumentTypes);
6864
}
6965

7066
private OrderedWindowAccumulator(
7167
PagesIndex.Factory pagesIndexFactory,
7268
PagesIndexWithOrdering pagesIndexWithOrdering,
7369
WindowAccumulator delegate,
74-
List<Type> argumentTypes,
75-
List<Integer> argumentChannels)
70+
List<Type> argumentTypes)
7671
{
7772
this.pagesIndexFactory = requireNonNull(pagesIndexFactory, "pagesIndexFactory is null");
7873
requireNonNull(pagesIndexWithOrdering, "pagesIndexWithOrdering is null");
7974
this.pagesIndex = pagesIndexWithOrdering.pagesIndex;
8075
this.pagesIndexOrdering = pagesIndexWithOrdering.pagesIndexOrdering;
8176

8277
requireNonNull(argumentTypes, "argumentTypes is null");
83-
requireNonNull(argumentChannels, "argumentChannels is null");
84-
checkArgument(argumentTypes.size() == argumentChannels.size(), "argumentTypes and argumentChannels must have the same size");
8578
this.argumentTypes = ImmutableList.copyOf(argumentTypes);
86-
this.argumentChannels = ImmutableList.copyOf(argumentChannels);
8779

8880
this.delegate = requireNonNull(delegate, "delegate is null");
8981
this.initialDelegate = delegate.copy();
@@ -102,7 +94,7 @@ public WindowAccumulator copy()
10294
{
10395
PagesIndex pagesIndexCopy = pagesIndexFactory.newPagesIndex(argumentTypes, pagesIndex.getPositionCount());
10496
pagesIndex.getPages().forEachRemaining(pagesIndexCopy::addPage);
105-
return new OrderedWindowAccumulator(pagesIndexFactory, new PagesIndexWithOrdering(pagesIndexCopy, pagesIndexOrdering), delegate.copy(), argumentTypes, argumentChannels);
97+
return new OrderedWindowAccumulator(pagesIndexFactory, new PagesIndexWithOrdering(pagesIndexCopy, pagesIndexOrdering), delegate.copy(), argumentTypes);
10698
}
10799

108100
@Override
@@ -114,12 +106,12 @@ public void addInput(WindowIndex index, int startPosition, int endPosition)
114106
// nicer would be to add reset() method to WindowAccumulator but it requires reset method in each AccumulatorState class
115107
delegate = initialDelegate.copy();
116108
}
117-
// index is remapped so just go from 0 to argumentChannels.size()
109+
// index is remapped so just go from 0 to argumentTypes.size()
118110
for (int position = startPosition; position <= endPosition; position++) {
119111
if (pageBuilder.isFull()) {
120112
indexCurrentPage();
121113
}
122-
for (int channel = 0; channel < argumentChannels.size(); channel++) {
114+
for (int channel = 0; channel < argumentTypes.size(); channel++) {
123115
ValueBlock value = index.getSingleValueBlock(channel, position).getSingleValueBlock(0);
124116
pageBuilder.getBlockBuilder(channel).append(value, 0);
125117
}
@@ -158,18 +150,18 @@ public void output(BlockBuilder blockBuilder)
158150
private static PagesIndexWithOrdering createPagesIndexWithOrdering(
159151
PagesIndex.Factory pagesIndexFactory,
160152
List<Type> argumentTypes,
161-
int argumentChannelCount,
162153
List<Integer> sortKeysArguments,
163154
List<SortOrder> sortOrders)
164155
{
165156
requireNonNull(pagesIndexFactory, "pagesIndexFactory is null");
157+
requireNonNull(argumentTypes, "argumentTypes is null");
166158
requireNonNull(sortOrders, "sortOrders is null");
167159
requireNonNull(sortKeysArguments, "sortChannels is null");
168160
checkArgument(sortOrders.size() == sortKeysArguments.size(), "sortOrders and sortChannels must have the same size");
169161
sortKeysArguments.forEach(argument -> {
170162
checkArgument(
171-
argument < argumentChannelCount,
172-
"invalid argument %s referenced; total number of arguments is %s", argument, argumentChannelCount);
163+
argument < argumentTypes.size(),
164+
"invalid argument %s referenced; total number of arguments is %s", argument, argumentTypes.size());
173165
});
174166
PagesIndex pagesIndex = pagesIndexFactory.newPagesIndex(argumentTypes, 10_000);
175167
PagesIndexOrdering pagesIndexOrdering = pagesIndex.createPagesIndexComparator(sortKeysArguments, sortOrders);

core/trino-main/src/main/java/io/trino/sql/planner/LocalExecutionPlanner.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,6 @@ public PhysicalOperation visitWindow(WindowNode node, LocalExecutionPlanContext
12101210
pagesIndexFactory,
12111211
finalAccumulatorSupplier.apply(lambdaProviders),
12121212
argumentTypes,
1213-
argumentChannels,
12141213
sortKeysArguments,
12151214
sortOrders);
12161215
}

0 commit comments

Comments
 (0)