示例#1
0
        /// <summary>
        /// Given an expression and an optional comparator, build a tree of
        /// InputFormats using the comparator to sort keys.
        /// </summary>
        /// <exception cref="System.IO.IOException"/>
        internal static Parser.Node Parse(string expr, Configuration conf)
        {
            if (null == expr)
            {
                throw new IOException("Expression is null");
            }
            Type cmpcl = conf.GetClass <WritableComparator>(CompositeInputFormat.JoinComparator
                                                            , null);

            Parser.Lexer         lex = new Parser.Lexer(expr);
            Stack <Parser.Token> st  = new Stack <Parser.Token>();

            Parser.Token tok;
            while ((tok = lex.Next()) != null)
            {
                if (Parser.TType.Rparen.Equals(tok.GetType()))
                {
                    st.Push(Reduce(st, conf));
                }
                else
                {
                    st.Push(tok);
                }
            }
            if (st.Count == 1 && Parser.TType.Cif.Equals(st.Peek().GetType()))
            {
                Parser.Node ret = st.Pop().GetNode();
                if (cmpcl != null)
                {
                    ret.SetKeyComparator(cmpcl);
                }
                return(ret);
            }
            throw new IOException("Missing ')'");
        }
示例#2
0
        /// <exception cref="System.IO.IOException"/>
        private static Parser.Token Reduce(Stack <Parser.Token> st, Configuration conf)
        {
            List <Parser.Token> args = new List <Parser.Token>();

            while (!st.IsEmpty() && !Parser.TType.Lparen.Equals(st.Peek().GetType()))
            {
                args.AddFirst(st.Pop());
            }
            if (st.IsEmpty())
            {
                throw new IOException("Unmatched ')'");
            }
            st.Pop();
            if (st.IsEmpty() || !Parser.TType.Ident.Equals(st.Peek().GetType()))
            {
                throw new IOException("Identifier expected");
            }
            Parser.Node n = Parser.Node.ForIdent(st.Pop().GetStr());
            n.Parse(args, conf);
            return(new Parser.NodeToken(n));
        }
示例#3
0
 // expression parse tree to which IF requests are proxied
 /// <summary>Interpret a given string as a composite expression.</summary>
 /// <remarks>
 /// Interpret a given string as a composite expression.
 /// <c>
 /// func  ::= &lt;ident&gt;([&lt;func&gt;,]*&lt;func&gt;)
 /// func  ::= tbl(&lt;class&gt;,"&lt;path&gt;")
 /// class ::= @see java.lang.Class#forName(java.lang.String)
 /// path  ::= @see org.apache.hadoop.fs.Path#Path(java.lang.String)
 /// </c>
 /// Reads expression from the <tt>mapreduce.join.expr</tt> property and
 /// user-supplied join types from <tt>mapreduce.join.define.&lt;ident&gt;</tt>
 /// types. Paths supplied to <tt>tbl</tt> are given as input paths to the
 /// InputFormat class listed.
 /// </remarks>
 /// <seealso cref="CompositeInputFormat{K}.Compose(string, System.Type{T}, string[])"
 ///     />
 /// <exception cref="System.IO.IOException"/>
 public virtual void SetFormat(Configuration conf)
 {
     AddDefaults();
     AddUserIdentifiers(conf);
     root = Parser.Parse(conf.Get(JoinExpr, null), conf);
 }
示例#4
0
 internal NodeToken(Parser.Node node)
     : base(Parser.TType.Cif)
 {
     this.node = node;
 }