Class KafkaInputKeyComparator

  • All Implemented Interfaces:
    java.io.Serializable, java.util.Comparator<org.apache.hadoop.io.BytesWritable>, org.apache.hadoop.io.RawComparator<org.apache.hadoop.io.BytesWritable>
    Direct Known Subclasses:
    KafkaInputValueGroupingComparator

    public class KafkaInputKeyComparator
    extends java.lang.Object
    implements org.apache.hadoop.io.RawComparator<org.apache.hadoop.io.BytesWritable>, java.io.Serializable
    This class is used to support secondary sorting for KafkaInput Repush. The key is composed by the raw key + offset, and this class will compare key part first to make it in ascending order and then compare the offset part when keys are equal to maintain an offset-descending order for the same key.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2)  
      protected int compare​(KafkaInputMapperKey k1, KafkaInputMapperKey k2)  
      int compare​(org.apache.hadoop.io.BytesWritable o1, org.apache.hadoop.io.BytesWritable o2)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Constructor Detail

      • KafkaInputKeyComparator

        public KafkaInputKeyComparator()
    • Method Detail

      • compare

        public int compare​(byte[] b1,
                           int s1,
                           int l1,
                           byte[] b2,
                           int s2,
                           int l2)
        Specified by:
        compare in interface org.apache.hadoop.io.RawComparator<org.apache.hadoop.io.BytesWritable>
      • compare

        public int compare​(org.apache.hadoop.io.BytesWritable o1,
                           org.apache.hadoop.io.BytesWritable o2)
        Specified by:
        compare in interface java.util.Comparator<org.apache.hadoop.io.BytesWritable>