private long reduceValidDataSizeInLogSegments(List<LogSegmentName> logSegmentsToReduceFrom, long ceilingSize)
      throws StoreException {
    List<LogSegmentName> logSegments = new ArrayList<>(logSegmentsToReduceFrom);
    long validDataSize = getValidDataSize(logSegmentsToReduceFrom, state.time.milliseconds(), purgeDeleteTombstone);
    while (validDataSize > ceilingSize) {
      assertTrue("There are no more segments to delete data from", logSegments.size() > 0);
      int selectedIdx = TestUtils.RANDOM.nextInt(logSegments.size());
      LogSegmentName segmentToDeleteFrom = logSegments.get(selectedIdx);
      MockId idToDelete = state.getIdToDeleteFromLogSegment(state.log.getSegment(segmentToDeleteFrom), false);
      if (idToDelete == null) {
        logSegments.remove(selectedIdx);
      } else {
        state.addDeleteEntry(idToDelete);
        validDataSize = getValidDataSize(logSegmentsToReduceFrom, state.time.milliseconds() + 1, purgeDeleteTombstone);
      }
    }
    state.advanceTime(Time.MsPerSec);
    return state.time.milliseconds();
  }
Reduces the valid data size in {@code logSegmentsToReduceFrom} to <= {@code ceilingSize} by deleting keys in these
segments.
@param logSegmentsToReduceFrom the names of the log segments to reduce the data from.
@param ceilingSize the maximum allowed valid size in these log segments.
@return the time (in ms) at which all the deletes are valid.
@throws StoreException
ambry-store/src/test/java/com/github/ambry/store/BlobStoreCompactorTest.java