Broadcasting distributes all records to each partition. This helps to distribute each and every element to all partitions:
In Java:
inputStream.broadcast();
In Scala:
inputStream.broadcast()Data Sinks
Once data transformations are complete, you must save the results. The following are some Flink options to save results:
- writeAsText(): Writes records one line at a time as strings.
- writeAsCsV(): Writes tuples as comma-separated value files. Row and field delimiters can also be configured.
- print()/printErr(): Writes records to the standard output. You can also choose to write to the standard error.
- writeUsingOutputFormat(): You can also provide a custom output format. While defining the custom format, extend OutputFormat, which takes care of serialization and deserialization.
- writeToSocket(): Flink supports writing data to a specific socket as well. Define SerializationSchema for proper serialization and formatting.