本文簡要介紹 python 語言中 pyflink.datastream.WindowedStream.reduce
的用法。
用法:
reduce(reduce_function: Union[Callable, pyflink.datastream.functions.ReduceFunction], window_function: Union[pyflink.datastream.functions.WindowFunction, pyflink.datastream.functions.ProcessWindowFunction] = None, output_type: pyflink.common.typeinfo.TypeInformation = None) → pyflink.datastream.data_stream.DataStream
將reduce函數應用於窗口。每次對每個鍵的窗口進行評估時,都會調用窗口函數。 reduce 函數的輸出被解釋為常規的非窗口流。
此窗口將嘗試在窗口策略允許的範圍內逐步聚合數據。例如,翻滾時間窗口可以聚合數據,這意味著每個鍵隻存儲一個元素。滑動時間窗口將聚合滑動間隔的粒度,因此每個鍵存儲幾個元素(每個滑動間隔一個)。自定義窗口可能無法增量聚合,或者可能需要在聚合樹中存儲額外的值。
例子:
>>> ds.key_by(lambda x: x[1]) \ ... .window(TumblingEventTimeWindows.of(Time.seconds(5))) \ ... .reduce(lambda a, b: a[0] + b[0], b[1])
參數:
reduce_function- 減少函數。
window_function- 窗口函數。
output_type- 窗口函數的結果類型的類型信息。
返回:
將reduce函數應用於窗口的結果的數據流。
版本 1.16.0 中的新函數。
相關用法
- Python pyflink WindowedStream.side_output_late_data用法及代碼示例
- Python pyflink WindowedStream.aggregate用法及代碼示例
- Python pyflink WindowGroupedTable.aggregate用法及代碼示例
- Python pyflink WindowGroupedTable.select用法及代碼示例
- Python pyflink WatermarkStrategy.with_timestamp_assigner用法及代碼示例
- Python pyflink Table.intersect_all用法及代碼示例
- Python pyflink GroupedTable.select用法及代碼示例
- Python pyflink StreamTableEnvironment.from_data_stream用法及代碼示例
- Python pyflink Expression.to_date用法及代碼示例
- Python pyflink Table.fetch用法及代碼示例
- Python pyflink PulsarSourceBuilder用法及代碼示例
- Python pyflink TableEnvironment.create_temporary_function用法及代碼示例
- Python pyflink Table.right_outer_join用法及代碼示例
- Python pyflink Expression.json_value用法及代碼示例
- Python pyflink Table.distinct用法及代碼示例
- Python pyflink TableEnvironment.register_table_source用法及代碼示例
- Python pyflink Table.where用法及代碼示例
- Python pyflink Expression.end用法及代碼示例
- Python pyflink lit用法及代碼示例
- Python pyflink TableEnvironment.create_java_temporary_function用法及代碼示例
- Python pyflink Row.as_dict用法及代碼示例
- Python pyflink StreamTableEnvironment.create用法及代碼示例
- Python pyflink Table.drop_columns用法及代碼示例
- Python pyflink Expression.over用法及代碼示例
- Python pyflink Table.execute用法及代碼示例
注:本文由純淨天空篩選整理自apache.org大神的英文原創作品 pyflink.datastream.WindowedStream.reduce。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。