Example of how to use the flat-map
operator. In this example, the flat-map operator converts sentences into words.
- Checkout the dataflow.yaml.
- Make sure to Install SDF and start a Fluvio cluster.
With the dataflow.yaml
file in the current directory, run the following commands:
sdf run
The sample data file used to run this test ./sample-data/data.txt
has the following records:
This is a test
Produce the data to the sentences
topic:
fluvio produce sentences -f ./sample-data/data.txt
Checkout the data in sentences
topic:
fluvio consume sentences -Bd
Consume from words
to see them transformed:
fluvio consume words -Bd
This
is
a
test
Note: the sentence has been divided into a stream of words.
Display the stateful dataflow stats in the sdf
runtime >>
terminal:
show state flat-map-service/split-sentence/metrics
Key Window succeeded failed
stats * 1 0
Exit sdf
terminal and clean-up. The --force
flag removes the topics:
sdf clean --force