private void fillLastLogSegmentToCapacity(int numberOfEntries, boolean newLogSegment) throws StoreException {
    if (newLogSegment) {
      // to ensure a new log segment is created. If not, find the remaining size below will fail
      state.addPutEntries(1, PUT_RECORD_SIZE, Utils.Infinite_Time);
      numberOfEntries--;
    }
    // add PUT entries that spans the rest of the data in the last segment
    long remainingSize = state.log.getSegmentCapacity() - state.index.getCurrentEndOffset().getOffset();
    long sizePerPutRecord = remainingSize / numberOfEntries;
    for (int i = 0; i < numberOfEntries; i++) {
      state.addPutEntries(1, sizePerPutRecord, Utils.Infinite_Time);
    }
  }
Fill the current log segment to its capacity
@param numberOfEntries number of entries to be added to fill the log segment to its capacity
@param newLogSegment {@code true} if this is a new log segment. {@code false} otherwise
@throws StoreException
ambry-store/src/test/java/com/github/ambry/store/IndexTest.java