Class FastTop1Function
- java.lang.Object
-
- org.apache.flink.api.common.functions.AbstractRichFunction
-
- 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>
-
- org.apache.flink.table.runtime.operators.rank.AbstractTopNFunction
-
- org.apache.flink.table.runtime.operators.rank.FastTop1Function
-
- All Implemented Interfaces:
Serializable,org.apache.flink.api.common.functions.Function,org.apache.flink.api.common.functions.RichFunction,org.apache.flink.streaming.api.checkpoint.CheckpointedFunction
public class FastTop1Function extends AbstractTopNFunction implements org.apache.flink.streaming.api.checkpoint.CheckpointedFunction
A more concise implementation forAppendOnlyTopNFunctionandUpdatableTopNFunctionwhen only Top-1 is desired. This function can handle updating stream because the RankProcessStrategy is inferred as UpdateFastStrategy, i.e., 1) the upsert key of input steam contains partition key; 2) the sort field is updated monotonely under the upsert key.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.flink.table.runtime.operators.rank.AbstractTopNFunction
hitCount, inputRowType, keyContext, outputRankNumber, rankEnd, requestCount, sortKeyComparator, sortKeySelector, ttlConfig
-
-
Constructor Summary
Constructors Constructor Description FastTop1Function(org.apache.flink.api.common.state.StateTtlConfig ttlConfig, InternalTypeInfo<org.apache.flink.table.data.RowData> inputRowType, GeneratedRecordComparator generatedSortKeyComparator, RowDataKeySelector sortKeySelector, RankType rankType, RankRange rankRange, boolean generateUpdateBefore, boolean outputRankNumber, long cacheSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidinitializeState(org.apache.flink.runtime.state.FunctionInitializationContext context)voidopen(org.apache.flink.configuration.Configuration parameters)voidprocessElement(org.apache.flink.table.data.RowData input, org.apache.flink.streaming.api.functions.KeyedProcessFunction.Context ctx, org.apache.flink.util.Collector<org.apache.flink.table.data.RowData> out)voidsnapshotState(org.apache.flink.runtime.state.FunctionSnapshotContext context)-
Methods inherited from class org.apache.flink.table.runtime.operators.rank.AbstractTopNFunction
checkSortKeyInBufferRange, collectDelete, collectDelete, collectInsert, collectInsert, collectUpdateAfter, collectUpdateAfter, collectUpdateBefore, collectUpdateBefore, getDefaultTopNSize, hasOffset, initRankEnd, isInRankEnd, isInRankRange, registerMetric, setKeyContext
-
-
-
-
Constructor Detail
-
FastTop1Function
public FastTop1Function(org.apache.flink.api.common.state.StateTtlConfig ttlConfig, InternalTypeInfo<org.apache.flink.table.data.RowData> inputRowType, GeneratedRecordComparator generatedSortKeyComparator, RowDataKeySelector sortKeySelector, RankType rankType, RankRange rankRange, boolean generateUpdateBefore, boolean outputRankNumber, long cacheSize)
-
-
Method Detail
-
open
public void open(org.apache.flink.configuration.Configuration parameters) throws Exception- Specified by:
openin interfaceorg.apache.flink.api.common.functions.RichFunction- Overrides:
openin classAbstractTopNFunction- Throws:
Exception
-
processElement
public void processElement(org.apache.flink.table.data.RowData input, org.apache.flink.streaming.api.functions.KeyedProcessFunction.Context ctx, org.apache.flink.util.Collector<org.apache.flink.table.data.RowData> out) throws Exception- Specified by:
processElementin classorg.apache.flink.streaming.api.functions.KeyedProcessFunction<org.apache.flink.table.data.RowData,org.apache.flink.table.data.RowData,org.apache.flink.table.data.RowData>- Throws:
Exception
-
snapshotState
public void snapshotState(org.apache.flink.runtime.state.FunctionSnapshotContext context) throws Exception- Specified by:
snapshotStatein interfaceorg.apache.flink.streaming.api.checkpoint.CheckpointedFunction- Throws:
Exception
-
-