Hi Mengqi,
I did not completely understand your use case.
If you would like to use a composite key (a key with multiple fields) there
are two alternatives:
- use a tuple as key type. This only works if all records have the same
number of key fields. Tuple serialization and comparisons are very
efficient.
- implement your own type (like you did) but override the compare() method.
Here you can also deal with different number of key fields. A custom type
will be serialized with Kryo. You can make it more efficient if you
register the type in the ExecutionConfig.
If you want to use multiple keys for a record, you need to emit the record
multiple times in a FlatMapFunction and assign each time a different key.
Hope this helps,
Fabian
2016-03-14 10:43 GMT+01:00 Mengqi Yang <melody2014...@gmail.com>:
> Hi all,
>
> Now I am building a POJO class for key selectors. Here is the class:
>
> public class Ids implements Comparable, Serializable{
>
> private static final long serialVersionUID = 1L;
>
> private ArrayList ids = new ArrayList();
>
> Ids() {}
>
> Ids(ArrayList inputIds) {
> this.ids = inputIds;
> }
>
> }
>
> And the question is, how could I use each element in the array list as a
> field for further key selection? I saw the typeinfo of Flink takes the
> field
> of arraylist as 1. Or maybe I didn't understand it correctly.
>
> Thanks,
> Mengqi
>
>
>
> --
> View this message in context:
> http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/Using-a-POJO-class-wrapping-an-ArrayList-tp5483.html
> Sent from the Apache Flink User Mailing List archive. mailing list archive
> at Nabble.com.
>