Class AvroCollectionElementComparator

java.lang.Object
com.linkedin.davinci.schema.merge.AvroCollectionElementComparator

@ThreadSafe public class AvroCollectionElementComparator extends Object
This comparator is used to compare GenericRecord collection field elements which must have schemas. This comparison is required in order to determine orders of 2 collection elements when their timestamps are the same.
  • Field Details

  • Method Details

    • compare

      public int compare(Object o1, Object o2, org.apache.avro.Schema schema)
      This function compares two objects using the provided schema.
      Parameters:
      o1 - first object to compare
      o2 - second object to compare
      schema - Schema of o1 and o2. Used to determine their type for the comparison
      Returns:
      a negative integer if o1 is less than o2, zero if o1 is equal to o2, or a positive integer if o1 is greater than o2. When o1 and o2 are IndexedHashMaps: returns a negative integer if o1.size() < o2.size(), a positive integer if o1.size() > o2.size, or a result of entry-by-entry comparison which is done using positional indexes.
      Throws:
      IllegalArgumentException - if o1 and o2 have different schemas