Class SideOutputExample.Tokenizer
- java.lang.Object
-
- org.apache.flink.api.common.functions.AbstractRichFunction
-
- org.apache.flink.streaming.api.functions.ProcessFunction<String,Tuple2<String,Integer>>
-
- org.apache.flink.streaming.examples.sideoutput.SideOutputExample.Tokenizer
-
- All Implemented Interfaces:
Serializable
,Function
,RichFunction
- Enclosing class:
- SideOutputExample
public static final class SideOutputExample.Tokenizer extends ProcessFunction<String,Tuple2<String,Integer>>
Implements the string tokenizer that splits sentences into words as a user-defined FlatMapFunction. The function takes a line (String) and splits it into multiple pairs in the form of "(word,1)" (Tuple2<String, Integer>
).This rejects words that are longer than 5 characters long.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.flink.streaming.api.functions.ProcessFunction
ProcessFunction.Context, ProcessFunction.OnTimerContext
-
-
Constructor Summary
Constructors Constructor Description Tokenizer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
processElement(String value, ProcessFunction.Context ctx, Collector<Tuple2<String,Integer>> out)
Process one element from the input stream.-
Methods inherited from class org.apache.flink.streaming.api.functions.ProcessFunction
onTimer
-
Methods inherited from class org.apache.flink.api.common.functions.AbstractRichFunction
close, getIterationRuntimeContext, getRuntimeContext, open, setRuntimeContext
-
-
-
-
Method Detail
-
processElement
public void processElement(String value, ProcessFunction.Context ctx, Collector<Tuple2<String,Integer>> out) throws Exception
Description copied from class:ProcessFunction
Process one element from the input stream.This function can output zero or more elements using the
Collector
parameter and also update internal state or set timers using theProcessFunction.Context
parameter.- Specified by:
processElement
in classProcessFunction<String,Tuple2<String,Integer>>
- Parameters:
value
- The input value.ctx
- AProcessFunction.Context
that allows querying the timestamp of the element and getting aTimerService
for registering timers and querying the time. The context is only valid during the invocation of this method, do not store it.out
- The collector for returning result values.- Throws:
Exception
- This method may throw exceptions. Throwing an exception will cause the operation to fail and may trigger recovery.
-
-