@Override
  public SplitResult<OffsetRange> trySplit(double fractionOfRemainder) {
    // Convert to BigDecimal in computation to prevent overflow, which may result in loss of
    // precision.
    BigDecimal cur =
        (lastAttemptedOffset == null)
            ? BigDecimal.valueOf(range.getFrom()).subtract(BigDecimal.ONE, MathContext.DECIMAL128)
            : BigDecimal.valueOf(lastAttemptedOffset);
    // split = cur + max(1, (range.getTo() - cur) * fractionOfRemainder)
    BigDecimal splitPos =
        cur.add(
            BigDecimal.valueOf(range.getTo())
                .subtract(cur, MathContext.DECIMAL128)
                .multiply(BigDecimal.valueOf(fractionOfRemainder), MathContext.DECIMAL128)
                .max(BigDecimal.ONE),
            MathContext.DECIMAL128);

    long split = splitPos.longValue();
    if (split >= range.getTo()) {
      return null;
    }
    OffsetRange res = new OffsetRange(split, range.getTo());
    this.range = new OffsetRange(range.getFrom(), split);
    return SplitResult.of(range, res);
  }
@Test
  public void testTrySplitAtEmptyRange() throws Exception {
    OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(100, 100));
    assertNull(tracker.trySplit(0));
    assertNull(tracker.trySplit(0.1));
    assertNull(tracker.trySplit(1));
  }