private static void throwRangesError(DiskRangeList ranges, long offset, long end) {
    // We are going to fail, so it is ok to do expensive stuff. Ranges are broken, play it safe.
    IdentityHashMap<DiskRangeList, Boolean> seen = new IdentityHashMap<>();
    seen.put(ranges, true);
    StringBuilder errors = new StringBuilder();
    while (ranges.prev != null) {
      if (ranges.prev.next != ranges) {
        errors.append("inconsistent list going back: [").append(ranges).append("].prev = [")
          .append(ranges.prev).append("]; prev.next = [").append(ranges.prev.next).append("]; ");
        // Stop, as we won't be able to go forward.
        break;
      }
      if (seen.containsKey(ranges.prev)) {
        errors.append("loop: [").append(ranges).append(
            "].prev = [").append(ranges.prev).append("]; ");
        break;
      }
      ranges = ranges.prev;
      seen.put(ranges, true);
    }
    seen.clear();
    seen.put(ranges, true);
    StringBuilder sb = new StringBuilder("Incorrect ranges detected while looking for ");
    if (offset == end) {
      sb.append(offset);
    } else {
      sb.append("[").append(offset).append(", ").append(end).append(")");
    }
    sb.append(": [").append(ranges).append("], ");
    while (ranges.next != null) {
      if (ranges.next.prev != ranges) {
        errors.append("inconsistent list going forward: [").append(ranges).append(
            "].next.prev = [").append(ranges.next.prev).append("]; ");
      }
      if (seen.containsKey(ranges.next)) {
        errors.append("loop: [").append(ranges).append(
            "].next = [").append(ranges.next).append("]; ");
        break;
      }
      ranges = ranges.next;
      sb.append("[").append(ranges).append("], ");
      seen.put(ranges, true);
    }
    sb.append("; ").append(errors);
    String error = sb.toString();
    LOG.error(error);
    throw new RuntimeException(error);
  }
Finds compressed offset in a stream and makes sure iter points to its position.
     This may be necessary for obscure combinations of compression and encoding boundaries.
ql/src/java/org/apache/hadoop/hive/ql/io/orc/encoded/EncodedReaderImpl.java