tledkov-gridgain commented on a change in pull request #8683: URL: https://github.com/apache/ignite/pull/8683#discussion_r586167884
########## File path: modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/SortAggregateNode.java ########## @@ -0,0 +1,305 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.query.calcite.exec.rel; + +import java.util.Comparator; +import java.util.List; +import java.util.function.Supplier; + +import org.apache.calcite.rel.type.RelDataType; +import org.apache.calcite.util.ImmutableBitSet; +import org.apache.ignite.internal.processors.query.calcite.exec.ExecutionContext; +import org.apache.ignite.internal.processors.query.calcite.exec.RowHandler; +import org.apache.ignite.internal.processors.query.calcite.exec.RowHandler.RowFactory; +import org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.Accumulator; +import org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.AccumulatorWrapper; +import org.apache.ignite.internal.processors.query.calcite.exec.exp.agg.AggregateType; +import org.apache.ignite.internal.processors.query.calcite.util.Commons; +import org.apache.ignite.internal.util.typedef.F; + +/** + * + */ +public class SortAggregateNode<Row> extends AbstractNode<Row> implements SingleNode<Row>, Downstream<Row> { + /** */ + private final AggregateType type; + + /** */ + private final Supplier<List<AccumulatorWrapper<Row>>> accFactory; + + /** */ + private final RowFactory<Row> rowFactory; + + /** */ + private final ImmutableBitSet grpSet; + + /** */ + private final Comparator<Row> comp; + + /** */ + private Row prevRow; + + /** */ + private Group grp; + + /** */ + private int requested; + + /** */ + private int waiting; + + /** */ + private int cmpRes; + + /** + * @param ctx Execution context. + */ + public SortAggregateNode( + ExecutionContext<Row> ctx, + RelDataType rowType, + AggregateType type, + ImmutableBitSet grpSet, + Supplier<List<AccumulatorWrapper<Row>>> accFactory, + RowFactory<Row> rowFactory, + Comparator<Row> comp + ) { + super(ctx, rowType); + + this.type = type; + this.accFactory = accFactory; + this.rowFactory = rowFactory; + this.grpSet = grpSet; + this.comp = comp; + } + + /** {@inheritDoc} */ + @Override public void request(int rowsCnt) { + assert !F.isEmpty(sources()) && sources().size() == 1; + assert rowsCnt > 0 && requested == 0; + assert waiting <= 0; + + try { + checkState(); + + requested = rowsCnt; + + if (waiting == 0) { + waiting = requested; + + source().request(requested); Review comment: In this case we have to use buffer in the node. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
