use of org.apache.flink.table.runtime.operators.window.slicing.SliceSharedAssigner in project flink by apache.
the class StreamExecWindowAggregate method createAggsHandler.
private GeneratedNamespaceAggsHandleFunction<Long> createAggsHandler(SliceAssigner sliceAssigner, AggregateInfoList aggInfoList, ExecNodeConfig config, RelBuilder relBuilder, List<LogicalType> fieldTypes, ZoneId shiftTimeZone) {
final AggsHandlerCodeGenerator generator = new AggsHandlerCodeGenerator(new CodeGeneratorContext(config.getTableConfig()), relBuilder, JavaScalaConversionUtil.toScala(fieldTypes), // copyInputField
false).needAccumulate();
if (sliceAssigner instanceof SliceSharedAssigner) {
generator.needMerge(0, false, null);
}
final List<WindowProperty> windowProperties = Arrays.asList(Arrays.stream(namedWindowProperties).map(NamedWindowProperty::getProperty).toArray(WindowProperty[]::new));
return generator.generateNamespaceAggsHandler("WindowAggsHandler", aggInfoList, JavaScalaConversionUtil.toScala(windowProperties), sliceAssigner, shiftTimeZone);
}
use of org.apache.flink.table.runtime.operators.window.slicing.SliceSharedAssigner in project flink by apache.
the class SlicingWindowAggOperatorBuilder method build.
public SlicingWindowOperator<RowData, ?> build() {
checkNotNull(assigner);
checkNotNull(inputSerializer);
checkNotNull(keySerializer);
checkNotNull(accSerializer);
checkNotNull(generatedAggregateFunction);
boolean isGlobalAgg = localGeneratedAggregateFunction != null && globalGeneratedAggregateFunction != null;
RecordsCombiner.Factory combinerFactory;
if (isGlobalAgg) {
combinerFactory = new GlobalAggCombiner.Factory(localGeneratedAggregateFunction, globalGeneratedAggregateFunction);
} else {
combinerFactory = new AggCombiner.Factory(generatedAggregateFunction);
}
final WindowBuffer.Factory bufferFactory = new RecordsWindowBuffer.Factory(keySerializer, inputSerializer, combinerFactory);
final SlicingWindowProcessor<Long> windowProcessor;
if (assigner instanceof SliceSharedAssigner) {
windowProcessor = new SliceSharedWindowAggProcessor(generatedAggregateFunction, bufferFactory, (SliceSharedAssigner) assigner, accSerializer, indexOfCountStart, shiftTimeZone);
} else if (assigner instanceof SliceUnsharedAssigner) {
windowProcessor = new SliceUnsharedWindowAggProcessor(generatedAggregateFunction, bufferFactory, (SliceUnsharedAssigner) assigner, accSerializer, shiftTimeZone);
} else {
throw new IllegalArgumentException("assigner must be instance of SliceUnsharedAssigner or SliceSharedAssigner.");
}
return new SlicingWindowOperator<>(windowProcessor);
}
Aggregations