public void setSpecificOrderBy ( String schemaName , OrderBy ordering ) throws TupleMRException { // TODO failIfNull ( schemaName , "Not able to set specific orderBy for null source" ) ; if ( ! schemaAlreadyExists ( schemaName ) ) { throw new TupleMRException ( "Unknown source '" + schemaName + "' in specific OrderBy" ) ; } failIfNull ( ordering , "Not able to set null criteria for source '" + schemaName + "'" ) ; failIfEmpty ( ordering . getElements ( ) , "Can't set empty ordering" ) ; failIfNull ( commonOrderBy , "Not able to set specific order with no previous common OrderBy" ) ; if ( commonOrderBy . getSchemaOrderIndex ( ) == null ) { throw new TupleMRException ( "Need to specify source order in common OrderBy when using specific OrderBy" ) ; } if ( ordering . getSchemaOrderIndex ( ) != null ) { throw new TupleMRException ( "Not allowed to set source order in specific order" ) ; } Schema schema = getSchemaByName ( schemaName ) ; Map < String , String > aliases = fieldAliases . get ( schema . getName ( ) ) ; for ( SortElement e : ordering . getElements ( ) ) { if ( ! Schema . containsFieldUsingAlias ( schema , e . getName ( ) , aliases ) ) { throw new TupleMRException ( "Source '" + schemaName + "' doesn't contain field '" + e . getName ( ) ) ; } if ( e . getCustomComparator ( ) != null ) { Field field = schema . getField ( e . getName ( ) ) ; if ( field == null ) { field = schema . getField ( aliases . get ( e . getName ( ) ) ) ; } if ( field . getType ( ) != Type . OBJECT ) { throw new TupleMRException ( "Not allowed to set custom comparator for type=" + field . getType ( ) ) ; } } } for ( SortElement e : ordering . getElements ( ) ) { if ( commonOrderBy . containsFieldName ( e . getName ( ) ) ) { throw new TupleMRException ( "Common sort by already contains sorting for field '" + e . getName ( ) ) ; } } this . specificsOrderBy . put ( schemaName , ordering ) ; }
Sets how tuples from the specific schemaName will be sorted after being sorted by commonOrderBy and schemaOrder