K- key type
V- value type
KeyValuereturn type (both key and value type can be set arbitrarily)
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, this
schedulea method to be
called periodicallywith the provided context.
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.
|Modifier and Type||Method and Description|
Close this processor and clean up any resources.
Initialize this transformer.
Transform the record with the given key and value.
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
@Deprecated R punctuate(long timestamp)
Punctuatorfunctional interface instead.
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
KeyValuepair to be forwarded to down stream—if
nullwill not be forwarded