src/main/java/it/unibo/bd1819/reducers/DirectorsNameReducer.java
private Text buildSortedActorString(final String directorID, final List<String> directorTuples) {
        String sortedAndAggregatedString = directorID;
        while (! directorTuples.isEmpty()) {
            int maxCollaboration = 0;
            String selectedDirectorTuple = "";
            for(String tuple : directorTuples) {
                try {
                int currentCollaboration = Integer.parseInt(tuple.split(CUSTOM_VALUE_SEPARATOR)[1]);
                if ( currentCollaboration > maxCollaboration ) {
                    maxCollaboration = currentCollaboration;
                    selectedDirectorTuple = tuple;
                }
            } catch (Exception e) {
                return new Text("EXCEPTION CAUSED BY " + tuple);
            }}
            sortedAndAggregatedString += CUSTOM_VALUE_SEPARATOR + selectedDirectorTuple.split(CUSTOM_VALUE_SEPARATOR)[0];
            sortedAndAggregatedString += "(" + maxCollaboration + ")";
            directorTuples.remove(selectedDirectorTuple);
        }

        return  new Text(sortedAndAggregatedString);
    }
/**
     * Aggregate three actor tuples into one sorted by the collaboration number
     * @param directorID the director ID key of the reducer
     * @param directorTuples the input tuples corresponding to a Director
     * @return
     */
Aggregate three actor tuples into one sorted by the collaboration number
@param directorID the director ID key of the reducer
@param directorTuples the input tuples corresponding to a Director
@return
Aggregate three actor tuples into one sorted by the collaboration number @param directorID the director ID key of the reducer @param directorTuples the input tuples corresponding to a Director @return
private Text buildSortedActorString(final String directorID, final List<String> directorTuples) {
        String sortedAndAggregatedString = directorID;
        while (! directorTuples.isEmpty()) {
            int maxCollaboration = 0;
            String selectedDirectorTuple = "";
            for(String tuple : directorTuples) {
                try {
                int currentCollaboration = Integer.parseInt(tuple.split(CUSTOM_VALUE_SEPARATOR)[1]);
                if ( currentCollaboration > maxCollaboration ) {
                    maxCollaboration = currentCollaboration;
                    selectedDirectorTuple = tuple;
                }
            } catch (Exception e) {
                return new Text("EXCEPTION CAUSED BY " + tuple);
            }}
            sortedAndAggregatedString += CUSTOM_VALUE_SEPARATOR + selectedDirectorTuple.split(CUSTOM_VALUE_SEPARATOR)[0];
            sortedAndAggregatedString += "(" + maxCollaboration + ")";
            directorTuples.remove(selectedDirectorTuple);
        }
        return  new Text(sortedAndAggregatedString);
    }
private Text buildSortedActorString ( final String directorID , final List < String > directorTuples ) { String sortedAndAggregatedString = directorID ; while ( ! directorTuples . isEmpty ( ) ) { int maxCollaboration = 0 ; String selectedDirectorTuple = "" ; for ( String tuple : directorTuples ) { try { int currentCollaboration = Integer . parseInt ( tuple . split ( CUSTOM_VALUE_SEPARATOR ) [ 1 ] ) ; if ( currentCollaboration > maxCollaboration ) { maxCollaboration = currentCollaboration ; selectedDirectorTuple = tuple ; } } catch ( Exception e ) { return new Text ( "EXCEPTION CAUSED BY " + tuple ) ; } } sortedAndAggregatedString += CUSTOM_VALUE_SEPARATOR + selectedDirectorTuple . split ( CUSTOM_VALUE_SEPARATOR ) [ 0 ] ; sortedAndAggregatedString += "(" + maxCollaboration + ")" ; directorTuples . remove ( selectedDirectorTuple ) ; } return new Text ( sortedAndAggregatedString ) ; }
Aggregate three actor tuples into one sorted by the collaboration number
 @param directorID the director ID key of the reducer
 @param directorTuples the input tuples corresponding to a Director
 @return
Aggregate three actor tuples into one sorted by the collaboration number @param directorID the director ID key of the reducer @param directorTuples the input tuples corresponding to a Director @return