<commit_before>package nextflow.extension
import groovyx.gpars.dataflow.operator.DataflowProcessor
import nextflow.splitter.FastqSplitter
/**
 * Implements the inner merging logic for splitterXxx operator(s)
 *
 * @author <NAME> <<EMAIL>>
 */
class SplitterMergeClosure extends Closure {

    private int numOfParams

    private List<Integer> indexes

    private int emissionCount

    SplitterMergeClosure(List<Integer> indexes) {
        super(null, null);
        this.numOfParams = indexes.size()
        this.indexes = indexes
    }

    @Override
    public int getMaximumNumberOfParameters() {
        numOfParams
    }

    @Override
    public Class[] getParameterTypes() {
        Collections.nCopies(numOfParams, Object)
    }

    @Override
    public void setDelegate(final Object delegate) {
        super.setDelegate(delegate);
    }

    @Override
    public void setResolveStrategy(final int resolveStrategy) {
        super.setResolveStrategy(resolveStrategy);
    }

    @Override
    public Object call(final Object arguments) {
        throw new UnsupportedOperationException()
    }

    @Override
    public Object call(final Object... args) {

        List result = null
        boolean header = false
        for( int i=0; i<args.size(); i++ ) {
            def item = args[i]
            // - When Pair-ended splitting is enabled the Fastq splitter
            //   emits the indexes of the splitted files as first tuple
            // - Those indexes are needed to merge the final tuple in correct order
            if( emissionCount==0 && item instanceof FastqSplitter.SplitIndex ) {
                indexes[i] = item.value
                header |= true
            }

            // - Compose the i-th tuple
            else if( item instanceof List ) {
                List entry = item
                if( i==0 ) {
                    result = new ArrayList(entry)
                }
                else {
                    result[indexes[i]] = entry[indexes[i]]
                }
            }
            else
                throw new IllegalArgumentException("Invalid splitter entry -- offending value: $item")

        }

        // emit the merged tuple (skipping the header)
        def processor = (DataflowProcessor)getDelegate()
        if( !header && processor )
            processor.bindAllOutputsAtomically(result);

        emissionCount++

        return result;
    }

    @Override
    public Object call() {
        throw new UnsupportedOperationException()
    }
}<commit_msg>Fixed paired-end tuple reconciliation #436<commit_after>package nextflow.extension
import groovyx.gpars.dataflow.operator.DataflowProcessor
import nextflow.splitter.FastqSplitter
/**
 * Implements the inner merging logic for splitterXxx operator(s)
 *
 * @author <NAME> <<EMAIL>>
 */
class SplitterMergeClosure extends Closure {

    private int numOfParams

    private List<Integer> indexes

    private int emissionCount

    SplitterMergeClosure(List<Integer> indexes) {
        super(null, null);
        this.numOfParams = indexes.size()
        this.indexes = indexes
    }

    @Override
    public int getMaximumNumberOfParameters() {
        numOfParams
    }

    @Override
    public Class[] getParameterTypes() {
        Collections.nCopies(numOfParams, Object)
    }

    @Override
    public void setDelegate(final Object delegate) {
        super.setDelegate(delegate);
    }

    @Override
    public void setResolveStrategy(final int resolveStrategy) {
        super.setResolveStrategy(resolveStrategy);
    }

    @Override
    public Object call(final Object arguments) {
        throw new UnsupportedOperationException()
    }

    @Override
    public Object call(final Object... args) {

        List result = null
        boolean header = false
        for( int i=0; i<args.size(); i++ ) {
            def item = args[i]
            // - When Pair-ended splitting is enabled the Fastq splitter
            //   emits the indexes of the splitted files as first tuple
            // - Those indexes are needed to merge the final tuple in correct order
            if( emissionCount==0 && item instanceof FastqSplitter.SplitIndex ) {
                indexes[i] = item.value
                header |= true
            }

            // - Compose the i-th tuple
            else if( item instanceof List ) {
                List entry = item
                if( i==0 ) {
                    result = new ArrayList(entry)
                }
                result[indexes[i]] = entry[indexes[i]]
            }
            else
                throw new IllegalArgumentException("Invalid splitter entry -- offending value: $item")

        }

        // emit the merged tuple (skipping the header)
        def processor = (DataflowProcessor)getDelegate()
        if( !header && processor )
            processor.bindAllOutputsAtomically(result);

        emissionCount++

        return result;
    }

    @Override
    public Object call() {
        throw new UnsupportedOperationException()
    }
}
{'fraction_non_alphanumeric': 0.08082408874801902, 'fraction_numerical': 0.0017828843106180666, 'mean_word_length': 2.017931858936043, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4229166', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1251, 'n_words': 371}