public class UpdatableTopNFunction extends AbstractTopNFunction implements org.apache.flink.streaming.api.checkpoint.CheckpointedFunction
RetractableTopNFunction
which only hold top n data in state, and keep sorted map in heap.
However, the function only works in some special scenarios:
1. sort field collation is ascending and its mono is decreasing, or sort field collation is descending and its mono
is increasing
2. input data has unique keys and unique key must contain partition key
3. input stream could not contain DELETE record or UPDATE_BEFORE recordhitCount, inputRowType, keyContext, outputRankNumber, rankEnd, requestCount, sortKeyComparator, sortKeySelectorstateCleaningEnabled| 构造器和说明 |
|---|
UpdatableTopNFunction(long minRetentionTime,
long maxRetentionTime,
RowDataTypeInfo inputRowType,
RowDataKeySelector rowKeySelector,
GeneratedRecordComparator generatedRecordComparator,
RowDataKeySelector sortKeySelector,
RankType rankType,
RankRange rankRange,
boolean generateUpdateBefore,
boolean outputRankNumber,
long cacheSize) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
initializeState(org.apache.flink.runtime.state.FunctionInitializationContext context) |
void |
onTimer(long timestamp,
org.apache.flink.streaming.api.functions.KeyedProcessFunction.OnTimerContext ctx,
org.apache.flink.util.Collector<org.apache.flink.table.data.RowData> out) |
void |
open(org.apache.flink.configuration.Configuration parameters) |
void |
processElement(org.apache.flink.table.data.RowData input,
org.apache.flink.streaming.api.functions.KeyedProcessFunction.Context context,
org.apache.flink.util.Collector<org.apache.flink.table.data.RowData> out) |
void |
snapshotState(org.apache.flink.runtime.state.FunctionSnapshotContext context) |
checkSortKeyInBufferRange, collectDelete, collectDelete, collectInsert, collectInsert, collectUpdateAfter, collectUpdateAfter, collectUpdateBefore, collectUpdateBefore, getDefaultTopNSize, hasOffset, initRankEnd, isInRankEnd, isInRankRange, registerMetric, setKeyContextcleanupState, initCleanupTimeState, isProcessingTimeTimer, needToCleanupState, registerProcessingCleanupTimerclose, getIterationRuntimeContext, getRuntimeContext, setRuntimeContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitregisterProcessingCleanupTimerpublic UpdatableTopNFunction(long minRetentionTime,
long maxRetentionTime,
RowDataTypeInfo inputRowType,
RowDataKeySelector rowKeySelector,
GeneratedRecordComparator generatedRecordComparator,
RowDataKeySelector sortKeySelector,
RankType rankType,
RankRange rankRange,
boolean generateUpdateBefore,
boolean outputRankNumber,
long cacheSize)
public void open(org.apache.flink.configuration.Configuration parameters)
throws Exception
open 在接口中 org.apache.flink.api.common.functions.RichFunctionopen 在类中 AbstractTopNFunctionExceptionpublic void onTimer(long timestamp,
org.apache.flink.streaming.api.functions.KeyedProcessFunction.OnTimerContext ctx,
org.apache.flink.util.Collector<org.apache.flink.table.data.RowData> out)
throws Exception
onTimer 在类中 org.apache.flink.streaming.api.functions.KeyedProcessFunction<org.apache.flink.table.data.RowData,org.apache.flink.table.data.RowData,org.apache.flink.table.data.RowData>Exceptionpublic void initializeState(org.apache.flink.runtime.state.FunctionInitializationContext context)
throws Exception
initializeState 在接口中 org.apache.flink.streaming.api.checkpoint.CheckpointedFunctionExceptionpublic void processElement(org.apache.flink.table.data.RowData input,
org.apache.flink.streaming.api.functions.KeyedProcessFunction.Context context,
org.apache.flink.util.Collector<org.apache.flink.table.data.RowData> out)
throws Exception
processElement 在类中 org.apache.flink.streaming.api.functions.KeyedProcessFunction<org.apache.flink.table.data.RowData,org.apache.flink.table.data.RowData,org.apache.flink.table.data.RowData>ExceptionCopyright © 2014–2020 The Apache Software Foundation. All rights reserved.