code: @SneakyThrows(IOException.class)
      private KeyUpdateCollection readKeysFromSegment(DirectSegmentAccess segment, long firstOffset, long lastOffset, TimeoutTimer timer) {
          KeyUpdateCollection keyUpdates = new KeyUpdateCollection();
          try (InputStream input = readFromInMemorySegment(segment, firstOffset, lastOffset, timer)) {
              long segmentOffset = firstOffset;
              while (segmentOffset < lastOffset) {
                  segmentOffset += indexSingleKey(input, segmentOffset, keyUpdates);
              }
          }
          return keyUpdates;
      }
docs: Reads all the Keys from the given Segment between the given offsets and indexes them by key.
  
  @param segment     The InputStream to process.
  @param firstOffset The first offset in the Segment to start reading Keys at.
  @param lastOffset  The last offset in the Segment to read Keys until.
  @param timer       Timer for the operation.
  @return A {@link KeyUpdateCollection}s containing the indexed keys.