static Node parse ( String expr , JobConf job ) throws IOException { if ( null == expr ) { throw new IOException ( "Expression is null" ) ; } Class < ? extends WritableComparator > cmpcl = job . getClass ( "mapred.join.keycomparator" , null , WritableComparator . class ) ; Lexer lex = new Lexer ( expr ) ; Stack < Token > st = new Stack < Token > ( ) ; Token tok ; while ( ( tok = lex . next ( ) ) != null ) { if ( TType . RPAREN . equals ( tok . getType ( ) ) ) { st . push ( reduce ( st , job ) ) ; } else { st . push ( tok ) ; } } if ( st . size ( ) == 1 && TType . CIF . equals ( st . peek ( ) . getType ( ) ) ) { Node ret = st . pop ( ) . getNode ( ) ; if ( cmpcl != null ) { ret . setKeyComparator ( cmpcl ) ; } return ret ; } throw new IOException ( "Missing ')'" ) ; }
Given an expression and an optional comparator build a tree of InputFormats using the comparator to sort keys .