K- key type
V- value type
KeyValuereturn type (both key and value type can be set arbitrarily)
public interface Transformer<K,V,R>
Transformerinterface is 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||Description|
Close this transformer and clean up any resources.
Initialize this transformer.
Transform the record with the given key and value.
void init(ProcessorContext context)
close()will be called on it; the framework may later re-use the transformer by calling
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, To) can be used.
If record should not 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