public Optional<OffsetPosition> fetchUpperBoundOffset(OffsetPosition fetchOffset, int fetchSize) {
        return maybeLock(lock, () -> {
            ByteBuffer idx = mmap().duplicate();
            int slot = smallestUpperBoundSlotFor(idx, fetchOffset.position + fetchSize, IndexSearchType.VALUE);
            if (slot == -1)
                return Optional.empty();
            else
                return Optional.of(parseEntry(idx, slot));
        });
    }
@Test
    public void testFetchUpperBoundOffset() {
        OffsetPosition first = new OffsetPosition(BASE_OFFSET, 0);
        OffsetPosition second = new OffsetPosition(BASE_OFFSET + 1, 10);
        OffsetPosition third = new OffsetPosition(BASE_OFFSET + 2, 23);
        OffsetPosition fourth = new OffsetPosition(BASE_OFFSET + 3, 37);

        assertEquals(Optional.empty(), index.fetchUpperBoundOffset(first, 5));

        Stream.of(first, second, third, fourth)
                .forEach(offsetPosition -> index.append(offsetPosition.offset, offsetPosition.position));

        assertEquals(Optional.of(second), index.fetchUpperBoundOffset(first, 5));
        assertEquals(Optional.of(second), index.fetchUpperBoundOffset(first, 10));
        assertEquals(Optional.of(third), index.fetchUpperBoundOffset(first, 23));
        assertEquals(Optional.of(third), index.fetchUpperBoundOffset(first, 22));
        assertEquals(Optional.of(fourth), index.fetchUpperBoundOffset(second, 24));
        assertEquals(Optional.empty(), index.fetchUpperBoundOffset(fourth, 1));
        assertEquals(Optional.empty(), index.fetchUpperBoundOffset(first, 200));
        assertEquals(Optional.empty(), index.fetchUpperBoundOffset(second, 200));
    }