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
3. input stream could not contain delete record or retract recordhitCount, inputRowType, keyContext, outputRankNumber, rankEnd, requestCount, sortKeyComparator, sortKeySelectorstateCleaningEnabled| Constructor and Description |
|---|
UpdatableTopNFunction(long minRetentionTime,
long maxRetentionTime,
BaseRowTypeInfo inputRowType,
BaseRowKeySelector rowKeySelector,
GeneratedRecordComparator generatedRecordComparator,
BaseRowKeySelector sortKeySelector,
RankType rankType,
RankRange rankRange,
boolean generateRetraction,
boolean outputRankNumber,
long cacheSize) |
| Modifier and Type | Method and Description |
|---|---|
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<BaseRow> out) |
void |
open(org.apache.flink.configuration.Configuration parameters) |
void |
processElement(BaseRow input,
org.apache.flink.streaming.api.functions.KeyedProcessFunction.Context context,
org.apache.flink.util.Collector<BaseRow> out) |
void |
snapshotState(org.apache.flink.runtime.state.FunctionSnapshotContext context) |
checkSortKeyInBufferRange, collect, collect, delete, delete, getDefaultTopNSize, hasOffset, initRankEnd, isInRankEnd, isInRankRange, registerMetric, retract, setKeyContextcleanupState, initCleanupTimeState, isProcessingTimeTimer, needToCleanupState, registerProcessingCleanupTimerclose, getIterationRuntimeContext, getRuntimeContext, setRuntimeContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitregisterProcessingCleanupTimerpublic UpdatableTopNFunction(long minRetentionTime,
long maxRetentionTime,
BaseRowTypeInfo inputRowType,
BaseRowKeySelector rowKeySelector,
GeneratedRecordComparator generatedRecordComparator,
BaseRowKeySelector sortKeySelector,
RankType rankType,
RankRange rankRange,
boolean generateRetraction,
boolean outputRankNumber,
long cacheSize)
public void open(org.apache.flink.configuration.Configuration parameters)
throws Exception
open in interface org.apache.flink.api.common.functions.RichFunctionopen in class AbstractTopNFunctionExceptionpublic void onTimer(long timestamp,
org.apache.flink.streaming.api.functions.KeyedProcessFunction.OnTimerContext ctx,
org.apache.flink.util.Collector<BaseRow> out)
throws Exception
public void initializeState(org.apache.flink.runtime.state.FunctionInitializationContext context)
throws Exception
initializeState in interface org.apache.flink.streaming.api.checkpoint.CheckpointedFunctionExceptionpublic void processElement(BaseRow input, org.apache.flink.streaming.api.functions.KeyedProcessFunction.Context context, org.apache.flink.util.Collector<BaseRow> out) throws Exception
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.