Why don't you calculate the hashCode for each field, combine them and use that as the key? You won't get around calculating /something /for each field and combining the result.

On 15.11.2018 11:02, Gaurav Luthra wrote:
Hi Chesnay,

My End user will be aware about the fields of "input records"
(GenericRecord). In configuration my end user only will tell me the name and
number of the fields, based on these fields of GenericRecord I will have to
partition the DataStream and make Keyed Stream.

Currently, I have implemented my solution using KeySelector() function. And
I have converted all the fields mentioned by user into strings, concatenated
these strings (for all the fields for which user want keyBy() means user
wants partitioning) and returned single string from KeySelector() function.
And partitioning will be happening based on this concatenated string.
See the example below.

                 dataStream.keyBy(record ->
                 {
                     return
record.get("area").toString()+record.get("age").toString();
                 });


But, I am looking for better solution. As I do not want to convert every
field to string.




--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/


Reply via email to