@Override
  public synchronized double getFractionConsumed() {
    if (position == null) {
      return 0;
    } else if (done) {
      return 1.0;
    } else if (position.compareTo(range.getEndKey()) >= 0) {
      return 1.0;
    }

    return range.estimateFractionForKey(position);
  }
@Test
  public void testGetFractionConsumed() {
    ByteKeyRangeTracker tracker = ByteKeyRangeTracker.of(INITIAL_RANGE);
    double delta = 0.00001;

    assertEquals(0.0, tracker.getFractionConsumed(), delta);

    tracker.tryReturnRecordAt(true, INITIAL_START_KEY);
    assertEquals(0.0, tracker.getFractionConsumed(), delta);

    tracker.tryReturnRecordAt(true, INITIAL_MIDDLE_KEY);
    assertEquals(0.5, tracker.getFractionConsumed(), delta);

    tracker.tryReturnRecordAt(true, BEFORE_END_KEY);
    assertEquals(1 - 1 / INITIAL_RANGE_SIZE, tracker.getFractionConsumed(), delta);
  }