Search in sources :

Example 1 with Symbol

use of com.sap.hadoop.windowing.functions2.table.npath.SymbolFunction.Symbol in project SQLWindowing by hbutani.

the class SymbolParser method parse.

public void parse() throws WindowingException {
    symbols = patternStr.split("\\.");
    symbolFunctions = new ArrayList<SymbolFunction>();
    for (String symbol : symbols) {
        boolean isStar = symbol.endsWith("*");
        boolean isPlus = symbol.endsWith("+");
        symbol = (isStar || isPlus) ? symbol.substring(0, symbol.length() - 1) : symbol;
        Object[] symbolDetails = symbolExprEvalMap.get(symbol.toLowerCase());
        if (symbolDetails == null) {
            throw new WindowingException(sprintf("Unknown Symbol %s", symbol));
        }
        ExprNodeEvaluator symbolExprEval = (ExprNodeEvaluator) symbolDetails[0];
        ObjectInspector symbolExprOI = (ObjectInspector) symbolDetails[1];
        SymbolFunction sFn = new Symbol(symbolExprEval, symbolExprOI);
        if (isStar) {
            sFn = new Star(sFn);
        } else if (isPlus) {
            sFn = new Plus(sFn);
        }
        symbolFunctions.add(sFn);
    }
    symbolFnChain = new Chain(symbolFunctions);
}
Also used : Chain(com.sap.hadoop.windowing.functions2.table.npath.SymbolFunction.Chain) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) Symbol(com.sap.hadoop.windowing.functions2.table.npath.SymbolFunction.Symbol) ExprNodeEvaluator(org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator) Star(com.sap.hadoop.windowing.functions2.table.npath.SymbolFunction.Star) WindowingException(com.sap.hadoop.windowing.WindowingException) Plus(com.sap.hadoop.windowing.functions2.table.npath.SymbolFunction.Plus)

Aggregations

WindowingException (com.sap.hadoop.windowing.WindowingException)1 Chain (com.sap.hadoop.windowing.functions2.table.npath.SymbolFunction.Chain)1 Plus (com.sap.hadoop.windowing.functions2.table.npath.SymbolFunction.Plus)1 Star (com.sap.hadoop.windowing.functions2.table.npath.SymbolFunction.Star)1 Symbol (com.sap.hadoop.windowing.functions2.table.npath.SymbolFunction.Symbol)1 ExprNodeEvaluator (org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator)1 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)1