Flink allows us to perform physical partitioning of the stream data. You have an option to provide custom partitioning. Let us have a look at the different types of partitioning.
As mentioned earlier, you can provide custom implementation of a partitioner.
In Java:
inputStream.partitionCustom(partitioner, "someKey"); inputStream.partitionCustom(partitioner, 0);
In Scala:
inputStream.partitionCustom(partitioner, "someKey") inputStream.partitionCustom(partitioner, 0)
While writing a custom partitioner you need make sure you implement an efficient hash function.
Random partitioning randomly partitions data streams in an evenly manner.
In Java:
inputStream.shuffle();
In Scala:
inputStream.shuffle()