DeserializerComparator (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.io.serializer, class: DeserializerComparator

Package org.apache.hadoop.io.serializer

# Class DeserializerComparator<T>

java.lang.Object
org.apache.hadoop.io.serializer.DeserializerComparator<T>

Type Parameters:
  `T` - generic type.

All Implemented Interfaces:
  `Comparator<T>`, `RawComparator<T>`

Direct Known Subclasses:
  `JavaSerializationComparator`

@LimitedPrivate({"HDFS","MapReduce"}) @Evolving public abstract class DeserializerComparator<T> extends Object implements RawComparator<T>

A `RawComparator` that uses a `Deserializer` to deserialize the objects to be compared so that the standard `Comparator` can be used to compare them.

One may optimize compare-intensive operations by using a custom implementation of `RawComparator` that operates directly on byte representations.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `DeserializerComparator(Deserializer<T> deserializer)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2)`
  Compare two objects in binary.

  ### 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

  `compare, equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

- ## Constructor Details

  - ### DeserializerComparator

    protected DeserializerComparator(Deserializer<T> deserializer) throws IOException
    Throws:
      `IOException`

- ## Method Details

  - ### compare

    public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2)
    Description copied from interface: `RawComparator`
    Compare two objects in binary. b1[s1:l1] is the first object, and b2[s2:l2] is the second object.
    Specified by:
      `compare` in interface `RawComparator<T>`
    Parameters:
      `b1` - The first byte array.
      `s1` - The position index in b1. The object under comparison's starting index.
      `l1` - The length of the object in b1.
      `b2` - The second byte array.
      `s2` - The position index in b2. The object under comparison's starting index.
      `l2` - The length of the object under comparison in b2.
    Returns:
      An integer result of the comparison.