private final boolean isEqual(byte[] left, int leftOffset, int rightIndex, int rightFrom, int length) {
    if (length == 0) {
      return true;
    }
    // invariant: rightLength = leftLength
    // rightOffset is within the buffers
    byte[] rightBuffer = writeBuffers.get(rightIndex);
    if (rightFrom + length <= wbSize) {
      // TODO: allow using unsafe optionally.
      // bounds check first, to trigger bugs whether the first byte matches or not
      if (left[leftOffset + length - 1] != rightBuffer[rightFrom + length - 1]) {
        return false;
      }
      for (int i = 0; i < length; ++i) {
        if (left[leftOffset + i] != rightBuffer[rightFrom + i]) {
          return false;
        }
      }
      return true;
    }
    for (int i = 0; i < length; ++i) {
      if (rightFrom == wbSize) {
        ++rightIndex;
        rightBuffer = writeBuffers.get(rightIndex);
        rightFrom = 0;
      }
      if (left[leftOffset + i] != rightBuffer[rightFrom++]) {
        return false;
      }
    }
    return true;
  }
Compares two parts of the buffer with each other. Does not modify readPoint.
serde/src/java/org/apache/hadoop/hive/serde2/WriteBuffers.java