private static long getOverlap(long offset1, long length1, long offset2, long length2) {
    // c/p from OrcInputFormat
    long end1 = offset1 + length1;
    long end2 = offset2 + length2;
    if (end2 <= offset1 || end1 <= offset2) {
      return 0;
    } else {
      return Math.min(end1, end2) - Math.max(offset1, offset2);
    }
  }
Compute the number of bytes that overlap between the two ranges.
@param offset1 start of range1
@param length1 length of range1
@param offset2 start of range2
@param length2 length of range2
@return the number of bytes in the overlap range
common/src/test/org/apache/hive/common/util/MockFileSystem.java