Transformer
is the contract that allows for a stateful transformation of every record in the input stream into zero or more output records (both key and value type can be altered arbitrarily).
In order to emit (produce) no record, transform should simply return null
.
In order to use a state, a state store has to be registered beforehand (using addStateStore
or addGlobalStore
) before they can be connected to the Transformer
.
You can access a state store using the ProcessorContext that is given when a transformer is initialized.
Tip
|
You could emit more output records for a single record using the ProcessorContext and its forward method.
|
// FIXME: Demo
Transformer
is created (supplied) using a corresponding TransformerSupplier.
Property | Description |
---|---|
|
void close() Closes the transformer Used exclusively when |
|
void init(final ProcessorContext context) Initializes the transformer in the given ProcessorContext Used exclusively when |
|
R transform(final K key, final V value) Transforms a single record (into a In order to emit (produce) no record, Used exclusively when |
Transformer
is used to create a KStreamTransformProcessor.