public Builder toBuilder() {
        return builder()
                .setManagedKeyedState(managedKeyedState)
                .setManagedOperatorState(managedOperatorState)
                .setRawOperatorState(rawOperatorState)
                .setRawKeyedState(rawKeyedState)
                .setInputChannelState(inputChannelState)
                .setResultSubpartitionState(resultSubpartitionState)
                .setInputRescalingDescriptor(inputRescalingDescriptor)
                .setOutputRescalingDescriptor(outputRescalingDescriptor);
    }
@Test
    void testToBuilderCorrectness() throws IOException {
        // given: Initialized operator subtask state.
        OperatorSubtaskState operatorSubtaskState = generateSampleOperatorSubtaskState().f1;

        // when: Copy the operator subtask state.
        OperatorSubtaskState operatorSubtaskStateCopy = operatorSubtaskState.toBuilder().build();

        // then: It should be equal to original one.
        assertThat(reflectionEquals(operatorSubtaskState, operatorSubtaskStateCopy)).isTrue();
    }