private void setEndOffsets() throws StoreException {
    for (Offset segmentStartOffset : validIndexSegments.keySet()) {
      Offset nextIndexSegmentStartOffset = validIndexSegments.higherKey(segmentStartOffset);
      if (nextIndexSegmentStartOffset == null || !segmentStartOffset.getName()
          .equals(nextIndexSegmentStartOffset.getName())) {
        // this is the last index segment for the log segment it refers to.
        IndexSegment indexSegment = validIndexSegments.get(segmentStartOffset);
        LogSegment logSegment = log.getSegment(segmentStartOffset.getName());
        logSegment.setEndOffset(indexSegment.getEndOffset().getOffset());
      }
    }
  }
Sets the end offset of all log segments.
<p/>
Assumed to run only on startup.
@throws StoreException if an end offset could not be set due to store exception.
ambry-store/src/main/java/com/github/ambry/store/PersistentIndex.java