public synchronized long getPositionForFractionConsumed(double fraction) {
    if (stopOffset == OFFSET_INFINITY) {
      throw new IllegalArgumentException(
          "getPositionForFractionConsumed is not applicable to an unbounded range: " + this);
    }
    return (long) Math.floor(startOffset + fraction * (stopOffset - startOffset));
  }
@Test
  public void testGetPositionForFractionDense() throws Exception {
    // Represents positions 3, 4, 5.
    OffsetRangeTracker tracker = new OffsetRangeTracker(3, 6);
    // [3, 3) represents from [0, 1/3) fraction of [3, 6)
    assertEquals(3, tracker.getPositionForFractionConsumed(0.0));
    assertEquals(3, tracker.getPositionForFractionConsumed(1.0 / 6));
    assertEquals(3, tracker.getPositionForFractionConsumed(0.333));
    // [3, 4) represents from [0, 2/3) fraction of [3, 6)
    assertEquals(4, tracker.getPositionForFractionConsumed(0.334));
    assertEquals(4, tracker.getPositionForFractionConsumed(0.666));
    // [3, 5) represents from [0, 1) fraction of [3, 6)
    assertEquals(5, tracker.getPositionForFractionConsumed(0.667));
    assertEquals(5, tracker.getPositionForFractionConsumed(0.999));
    // The whole [3, 6) is consumed for fraction 1
    assertEquals(6, tracker.getPositionForFractionConsumed(1.0));
  }