code: public CompletableFuture<StreamCutRecord> generateStreamCut(final String scope, final String stream, final StreamCutRecord previous,
                                                                  final OperationContext contextOpt, String delegationToken) {
          final OperationContext context = contextOpt == null ? streamMetadataStore.createContext(scope, stream) : contextOpt;
  
          return streamMetadataStore.getActiveSegments(scope, stream, context, executor)
                  .thenCompose(activeSegments -> Futures.allOfWithResults(activeSegments
                          .stream()
                          .parallel()
                          .collect(Collectors.toMap(x -> x, x -> getSegmentOffset(scope, stream, x.segmentId(), delegationToken)))))
                  .thenCompose(map -> {
                      final long generationTime = System.currentTimeMillis();
                      ImmutableMap.Builder<Long, Long> builder = ImmutableMap.builder();
                      map.forEach((key, value) -> builder.put(key.segmentId(), value));
                      ImmutableMap<Long, Long> streamCutMap = builder.build();
                      return streamMetadataStore.getSizeTillStreamCut(scope, stream, streamCutMap, Optional.ofNullable(previous), context, executor)
                                                .thenApply(sizeTill -> new StreamCutRecord(generationTime, sizeTill, streamCutMap));
                  });
      }
docs: Generate a new stream cut.
  
  @param scope      scope.
  @param stream     stream name.
  @param contextOpt optional context
  @param delegationToken token to be sent to segmentstore.
  @param previous previous stream cut record
  @return streamCut.