use of org.apache.flink.table.runtime.generated.AggsHandleFunction in project flink by apache.
the class NonBufferOverWindowOperator method open.
@Override
public void open() throws Exception {
super.open();
ClassLoader cl = getUserCodeClassloader();
serializer = (AbstractRowDataSerializer) getOperatorConfig().getTypeSerializerIn1(cl);
partitionComparator = genComparator.newInstance(cl);
genComparator = null;
collector = new StreamRecordCollector<>(output);
processors = new AggsHandleFunction[aggsHandlers.length];
joinedRows = new JoinedRowData[aggsHandlers.length];
for (int i = 0; i < aggsHandlers.length; i++) {
AggsHandleFunction func = aggsHandlers[i].newInstance(cl);
func.open(new PerKeyStateDataViewStore(getRuntimeContext()));
processors[i] = func;
joinedRows[i] = new JoinedRowData();
}
aggsHandlers = null;
}
use of org.apache.flink.table.runtime.generated.AggsHandleFunction in project flink by apache.
the class NonBufferOverWindowOperator method processElement.
@Override
public void processElement(StreamRecord<RowData> element) throws Exception {
RowData input = element.getValue();
boolean changePartition = lastInput == null || partitionComparator.compare(lastInput, input) != 0;
// calculate the ACC
RowData output = input;
for (int i = 0; i < processors.length; i++) {
AggsHandleFunction processor = processors[i];
if (changePartition || resetAccumulators[i]) {
processor.setAccumulators(processor.createAccumulators());
}
// TODO Reform AggsHandleFunction.getValue instead of use JoinedRowData. Multilayer
// JoinedRowData is slow.
processor.accumulate(input);
RowData value = processor.getValue();
output = joinedRows[i].replace(output, value);
}
collector.collect(output);
if (changePartition) {
lastInput = serializer.copy(input);
}
}
Aggregations