K- key type
V- value type
KeyValuereturn type (both key and value type can be set arbitrarily)
@InterfaceStability.Unstable public interface Transformer<K,V,R>
Transformerinterface for stateful mapping of an input record to zero, one, or multiple new output records (both key and value type can be altered arbitrarily). This is a stateful record-by-record operation, i.e,
transform(Object, Object)is invoked individually for each record of a stream and can access and modify a state that is available beyond a single call of
KeyValueMapperfor stateless record transformation). Additionally, the interface can be called in regular intervals based on the processing progress (cf.
TransformerSupplier to provide new instances of
Transformer to Kafka Stream's runtime.
If only a record's value should be modified
ValueTransformer can be used.
void init(ProcessorContext context)
context- the context
attachedto this operator can be accessed and modified arbitrarily (cf.
If more than one output record should be forwarded downstream
ProcessorContext.forward(Object, Object, int), and
ProcessorContext.forward(Object, Object, String) can be used.
If not record should be forwarded downstream,
transform can return
key- the key for the record
value- the value for the record
nullno key-value pair will be forwarded to down stream
R punctuate(long timestamp)
KeyValuepairs if this processor
schedules itselfwith the context during
punctuate is called based on
and not based on wall-clock time.
timestamp- the stream time when
punctuateis being called
exceptionwill be thrown