Search in sources :

Example 1 with SliceSharedAssigner

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);
}
Also used : NamedWindowProperty(org.apache.flink.table.runtime.groupwindow.NamedWindowProperty) WindowProperty(org.apache.flink.table.runtime.groupwindow.WindowProperty) NamedWindowProperty(org.apache.flink.table.runtime.groupwindow.NamedWindowProperty) CodeGeneratorContext(org.apache.flink.table.planner.codegen.CodeGeneratorContext) AggsHandlerCodeGenerator(org.apache.flink.table.planner.codegen.agg.AggsHandlerCodeGenerator) SliceSharedAssigner(org.apache.flink.table.runtime.operators.window.slicing.SliceSharedAssigner)

Example 2 with SliceSharedAssigner

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);
}
Also used : SliceUnsharedAssigner(org.apache.flink.table.runtime.operators.window.slicing.SliceUnsharedAssigner) SliceSharedWindowAggProcessor(org.apache.flink.table.runtime.operators.aggregate.window.processors.SliceSharedWindowAggProcessor) AggCombiner(org.apache.flink.table.runtime.operators.aggregate.window.combines.AggCombiner) GlobalAggCombiner(org.apache.flink.table.runtime.operators.aggregate.window.combines.GlobalAggCombiner) RecordsCombiner(org.apache.flink.table.runtime.operators.window.combines.RecordsCombiner) WindowBuffer(org.apache.flink.table.runtime.operators.aggregate.window.buffers.WindowBuffer) RecordsWindowBuffer(org.apache.flink.table.runtime.operators.aggregate.window.buffers.RecordsWindowBuffer) SliceSharedAssigner(org.apache.flink.table.runtime.operators.window.slicing.SliceSharedAssigner) GlobalAggCombiner(org.apache.flink.table.runtime.operators.aggregate.window.combines.GlobalAggCombiner) SliceUnsharedWindowAggProcessor(org.apache.flink.table.runtime.operators.aggregate.window.processors.SliceUnsharedWindowAggProcessor) SlicingWindowOperator(org.apache.flink.table.runtime.operators.window.slicing.SlicingWindowOperator)

Aggregations

SliceSharedAssigner (org.apache.flink.table.runtime.operators.window.slicing.SliceSharedAssigner)2 CodeGeneratorContext (org.apache.flink.table.planner.codegen.CodeGeneratorContext)1 AggsHandlerCodeGenerator (org.apache.flink.table.planner.codegen.agg.AggsHandlerCodeGenerator)1 NamedWindowProperty (org.apache.flink.table.runtime.groupwindow.NamedWindowProperty)1 WindowProperty (org.apache.flink.table.runtime.groupwindow.WindowProperty)1 RecordsWindowBuffer (org.apache.flink.table.runtime.operators.aggregate.window.buffers.RecordsWindowBuffer)1 WindowBuffer (org.apache.flink.table.runtime.operators.aggregate.window.buffers.WindowBuffer)1 AggCombiner (org.apache.flink.table.runtime.operators.aggregate.window.combines.AggCombiner)1 GlobalAggCombiner (org.apache.flink.table.runtime.operators.aggregate.window.combines.GlobalAggCombiner)1 SliceSharedWindowAggProcessor (org.apache.flink.table.runtime.operators.aggregate.window.processors.SliceSharedWindowAggProcessor)1 SliceUnsharedWindowAggProcessor (org.apache.flink.table.runtime.operators.aggregate.window.processors.SliceUnsharedWindowAggProcessor)1 RecordsCombiner (org.apache.flink.table.runtime.operators.window.combines.RecordsCombiner)1 SliceUnsharedAssigner (org.apache.flink.table.runtime.operators.window.slicing.SliceUnsharedAssigner)1 SlicingWindowOperator (org.apache.flink.table.runtime.operators.window.slicing.SlicingWindowOperator)1