Sounds very reasonable to me. +1
Though the default comparator should be implemented very carefully as we had issues with comparison of binary objects in 2.x Best Regards, Igor On Thu, Sep 9, 2021 at 4:04 PM Pavel Tupitsyn <ptupit...@apache.org> wrote: > Igniters, > > Tuple in Ignite 3.x is a replacement for BinaryObject in Ignite 2.x. > Let's discuss equality and sorting. > > - We have multiple Tuple implementations, and our API allows custom, > user-defined Tuples as well (which can be useful for performance when > bridging Ignite with another system or importing the data from somewhere). > - We don't have equals()/hashCode() overrides, so it is not possible to > compare tuples or put them into a Map. > > Proposal: > - Add public TupleComparator implements Comparator<Tuple>, based on the > tuple contents (column names and values) > - Implement common TupleComparator#hashCode(Tuple t) method that combines > hash codes of column names and values > - Implement equals(), hashCode(), and Comparable on all built-in tuples, > delegate the logic to TupleComparator > - Make Tuple extend Compable > > This way we cover all sorting/comparing/mapping scenarios for built-in > tuples and provide reusable code for third-party implementations. > > Thoughts? >