code: void preProcessAsTargetSegment(MergeSegmentOperation operation, SegmentMetadataUpdateTransaction sourceMetadata)
              throws StreamSegmentSealedException, StreamSegmentNotSealedException, MetadataUpdateException {
          ensureSegmentId(operation);
  
          if (this.sealed) {
              // We do not allow merging into sealed Segments.
              throw new StreamSegmentSealedException(this.name);
          }
  
          // Check that the Source has been properly sealed and has its length set.
          if (!sourceMetadata.isSealed()) {
              throw new StreamSegmentNotSealedException(this.name);
          }
  
          long transLength = operation.getLength();
          if (transLength < 0) {
              throw new MetadataUpdateException(this.containerId,
                      "MergeSegmentOperation does not have its Source Segment Length set: " + operation.toString());
          }
  
          if (!this.recoveryMode) {
              // Assign entry Segment offset and update Segment offset afterwards.
              operation.setStreamSegmentOffset(this.length);
          }
      }
docs: Pre-processes the given MergeSegmentOperation as a Target Segment (where it will be merged into).
  After this method returns, the operation will have its TargetSegmentOffset set to the length of the Target Segment.
  
  @param operation      The operation to pre-process.
  @param sourceMetadata The metadata for the Stream Segment to merge.
  @throws StreamSegmentSealedException    If the target Segment is already sealed.
  @throws StreamSegmentNotSealedException If the source Segment is not sealed.
  @throws MetadataUpdateException         If the operation cannot be processed because of the current state of the metadata.
  @throws IllegalArgumentException        If the operation is for a different Segment.