docs: JournalSegment<E> resetSegments(long index) {
      assertOpen();
  
      // If the index already equals the first segment index, skip the reset.
      JournalSegment<E> firstSegment = getFirstSegment();
      if (index == firstSegment.index()) {
        return firstSegment;
      }
  
      for (JournalSegment<E> segment : segments.values()) {
        segment.close();
        segment.delete();
      }
      segments.clear();
  
      JournalSegmentDescriptor descriptor = JournalSegmentDescriptor.builder()
          .withId(1)
          .withIndex(index)
          .withMaxSegmentSize(maxSegmentSize)
          .withMaxEntries(maxEntriesPerSegment)
          .build();
      currentSegment = createSegment(descriptor);
      segments.put(index, currentSegment);
      return currentSegment;
    }