Package com.sap.hadoop.windowing.query2.translate

Examples of com.sap.hadoop.windowing.query2.translate.WindowFunctionTranslation



    // $ANTLR start rowsboundary
    // QSpecBuilder2.g:186:1: rowsboundary returns [BoundarySpec bs] : ( ^( PRECEDING UNBOUNDED ) | ^( FOLLOWING UNBOUNDED ) | CURRENT | ^( PRECEDING n= Number ) | ^( FOLLOWING n= Number ) );
    public final BoundarySpec rowsboundary() throws RecognitionException {
        BoundarySpec bs = null;

        CommonTree n=null;


          RangeBoundarySpec rbs = new RangeBoundarySpec();
View Full Code Here


    // $ANTLR start window_value_expression
    // QSpecBuilder2.g:199:1: window_value_expression returns [WindowFrameSpec wf] : ^( WINDOWVALUES s= valuesboundary e= valuesboundary ) ;
    public final WindowFrameSpec window_value_expression() throws RecognitionException {
        WindowFrameSpec wf = null;

        BoundarySpec s = null;

        BoundarySpec e = null;


        try {
            // QSpecBuilder2.g:199:54: ( ^( WINDOWVALUES s= valuesboundary e= valuesboundary ) )
            // QSpecBuilder2.g:200:2: ^( WINDOWVALUES s= valuesboundary e= valuesboundary )
View Full Code Here


    // $ANTLR start valuesboundary
    // QSpecBuilder2.g:203:1: valuesboundary returns [BoundarySpec bs] : ( ^( PRECEDING UNBOUNDED ) | ^( FOLLOWING UNBOUNDED ) | CURRENT | ^( LESS e= expression n= Number ) | ^( MORE e= expression n= Number ) );
    public final BoundarySpec valuesboundary() throws RecognitionException {
        BoundarySpec bs = null;

        CommonTree n=null;
        CommonTree e = null;

View Full Code Here

                case 3 :
                    // QSpecBuilder2.g:194:3: CURRENT
                    {
                    match(input,CURRENT,FOLLOW_CURRENT_in_rowsboundary894); if (failed) return bs;
                    if ( backtracking==0 ) {
                      bs = new CurrentRowSpec();
                    }

                    }
                    break;
                case 4 :
View Full Code Here

                case 3 :
                    // QSpecBuilder2.g:206:3: CURRENT
                    {
                    match(input,CURRENT,FOLLOW_CURRENT_in_valuesboundary990); if (failed) return bs;
                    if ( backtracking==0 ) {
                      bs = new CurrentRowSpec();
                    }

                    }
                    break;
                case 4 :
View Full Code Here

    if ( amt == BoundarySpec.UNBOUNDED_AMOUNT )
    {
      return bndDef.getDirection() == Direction.PRECEDING ? 0 : p.size();
    }
   
    Direction d = bndDef.getDirection();
    boolean scanNext = rowValue != null;
    r = d == Direction.FOLLOWING ? r-- : r++;
    while ( scanNext )
    {
      if ( r < 0 || r >= p.size() )
View Full Code Here

        BoundarySpec bs = null;

        CommonTree n=null;


          RangeBoundarySpec rbs = new RangeBoundarySpec();
          bs = rbs;

        try {
            // QSpecBuilder2.g:191:3: ( ^( PRECEDING UNBOUNDED ) | ^( FOLLOWING UNBOUNDED ) | CURRENT | ^( PRECEDING n= Number ) | ^( FOLLOWING n= Number ) )
            int alt37=5;
            switch ( input.LA(1) ) {
            case PRECEDING:
                {
                int LA37_1 = input.LA(2);

                if ( (LA37_1==DOWN) ) {
                    int LA37_4 = input.LA(3);

                    if ( (LA37_4==Number) ) {
                        alt37=4;
                    }
                    else if ( (LA37_4==UNBOUNDED) ) {
                        alt37=1;
                    }
                    else {
                        if (backtracking>0) {failed=true; return bs;}
                        NoViableAltException nvae =
                            new NoViableAltException("186:1: rowsboundary returns [BoundarySpec bs] : ( ^( PRECEDING UNBOUNDED ) | ^( FOLLOWING UNBOUNDED ) | CURRENT | ^( PRECEDING n= Number ) | ^( FOLLOWING n= Number ) );", 37, 4, input);

                        throw nvae;
                    }
                }
                else {
                    if (backtracking>0) {failed=true; return bs;}
                    NoViableAltException nvae =
                        new NoViableAltException("186:1: rowsboundary returns [BoundarySpec bs] : ( ^( PRECEDING UNBOUNDED ) | ^( FOLLOWING UNBOUNDED ) | CURRENT | ^( PRECEDING n= Number ) | ^( FOLLOWING n= Number ) );", 37, 1, input);

                    throw nvae;
                }
                }
                break;
            case FOLLOWING:
                {
                int LA37_2 = input.LA(2);

                if ( (LA37_2==DOWN) ) {
                    int LA37_5 = input.LA(3);

                    if ( (LA37_5==Number) ) {
                        alt37=5;
                    }
                    else if ( (LA37_5==UNBOUNDED) ) {
                        alt37=2;
                    }
                    else {
                        if (backtracking>0) {failed=true; return bs;}
                        NoViableAltException nvae =
                            new NoViableAltException("186:1: rowsboundary returns [BoundarySpec bs] : ( ^( PRECEDING UNBOUNDED ) | ^( FOLLOWING UNBOUNDED ) | CURRENT | ^( PRECEDING n= Number ) | ^( FOLLOWING n= Number ) );", 37, 5, input);

                        throw nvae;
                    }
                }
                else {
                    if (backtracking>0) {failed=true; return bs;}
                    NoViableAltException nvae =
                        new NoViableAltException("186:1: rowsboundary returns [BoundarySpec bs] : ( ^( PRECEDING UNBOUNDED ) | ^( FOLLOWING UNBOUNDED ) | CURRENT | ^( PRECEDING n= Number ) | ^( FOLLOWING n= Number ) );", 37, 2, input);

                    throw nvae;
                }
                }
                break;
            case CURRENT:
                {
                alt37=3;
                }
                break;
            default:
                if (backtracking>0) {failed=true; return bs;}
                NoViableAltException nvae =
                    new NoViableAltException("186:1: rowsboundary returns [BoundarySpec bs] : ( ^( PRECEDING UNBOUNDED ) | ^( FOLLOWING UNBOUNDED ) | CURRENT | ^( PRECEDING n= Number ) | ^( FOLLOWING n= Number ) );", 37, 0, input);

                throw nvae;
            }

            switch (alt37) {
                case 1 :
                    // QSpecBuilder2.g:192:3: ^( PRECEDING UNBOUNDED )
                    {
                    match(input,PRECEDING,FOLLOW_PRECEDING_in_rowsboundary870); if (failed) return bs;

                    match(input, Token.DOWN, null); if (failed) return bs;
                    match(input,UNBOUNDED,FOLLOW_UNBOUNDED_in_rowsboundary872); if (failed) return bs;

                    match(input, Token.UP, null); if (failed) return bs;
                    if ( backtracking==0 ) {
                      rbs.setDirection(Direction.PRECEDING); rbs.setAmt(BoundarySpec.UNBOUNDED_AMOUNT);
                    }

                    }
                    break;
                case 2 :
                    // QSpecBuilder2.g:193:3: ^( FOLLOWING UNBOUNDED )
                    {
                    match(input,FOLLOWING,FOLLOW_FOLLOWING_in_rowsboundary883); if (failed) return bs;

                    match(input, Token.DOWN, null); if (failed) return bs;
                    match(input,UNBOUNDED,FOLLOW_UNBOUNDED_in_rowsboundary885); if (failed) return bs;

                    match(input, Token.UP, null); if (failed) return bs;
                    if ( backtracking==0 ) {
                      rbs.setDirection(Direction.FOLLOWING); rbs.setAmt(BoundarySpec.UNBOUNDED_AMOUNT);
                    }

                    }
                    break;
                case 3 :
                    // QSpecBuilder2.g:194:3: CURRENT
                    {
                    match(input,CURRENT,FOLLOW_CURRENT_in_rowsboundary894); if (failed) return bs;
                    if ( backtracking==0 ) {
                      bs = new CurrentRowSpec();
                    }

                    }
                    break;
                case 4 :
                    // QSpecBuilder2.g:195:3: ^( PRECEDING n= Number )
                    {
                    match(input,PRECEDING,FOLLOW_PRECEDING_in_rowsboundary903); if (failed) return bs;

                    match(input, Token.DOWN, null); if (failed) return bs;
                    n=(CommonTree)input.LT(1);
                    match(input,Number,FOLLOW_Number_in_rowsboundary907); if (failed) return bs;

                    match(input, Token.UP, null); if (failed) return bs;
                    if ( backtracking==0 ) {
                      rbs.setDirection(Direction.PRECEDING); rbs.setAmt(Integer.parseInt(n.getText()));
                    }

                    }
                    break;
                case 5 :
                    // QSpecBuilder2.g:196:3: ^( FOLLOWING n= Number )
                    {
                    match(input,FOLLOWING,FOLLOW_FOLLOWING_in_rowsboundary917); if (failed) return bs;

                    match(input, Token.DOWN, null); if (failed) return bs;
                    n=(CommonTree)input.LT(1);
                    match(input,Number,FOLLOW_Number_in_rowsboundary921); if (failed) return bs;

                    match(input, Token.UP, null); if (failed) return bs;
                    if ( backtracking==0 ) {
                      rbs.setDirection(Direction.FOLLOWING); rbs.setAmt(Integer.parseInt(n.getText()));
                    }

                    }
                    break;
View Full Code Here

                    match(input, Token.DOWN, null); if (failed) return bs;
                    match(input,UNBOUNDED,FOLLOW_UNBOUNDED_in_valuesboundary968); if (failed) return bs;

                    match(input, Token.UP, null); if (failed) return bs;
                    if ( backtracking==0 ) {
                      bs = new ValueBoundarySpec(Direction.PRECEDING, null, BoundarySpec.UNBOUNDED_AMOUNT);
                    }

                    }
                    break;
                case 2 :
                    // QSpecBuilder2.g:205:3: ^( FOLLOWING UNBOUNDED )
                    {
                    match(input,FOLLOWING,FOLLOW_FOLLOWING_in_valuesboundary979); if (failed) return bs;

                    match(input, Token.DOWN, null); if (failed) return bs;
                    match(input,UNBOUNDED,FOLLOW_UNBOUNDED_in_valuesboundary981); if (failed) return bs;

                    match(input, Token.UP, null); if (failed) return bs;
                    if ( backtracking==0 ) {
                      bs = new ValueBoundarySpec(Direction.FOLLOWING, null, BoundarySpec.UNBOUNDED_AMOUNT);
                    }

                    }
                    break;
                case 3 :
                    // QSpecBuilder2.g:206:3: CURRENT
                    {
                    match(input,CURRENT,FOLLOW_CURRENT_in_valuesboundary990); if (failed) return bs;
                    if ( backtracking==0 ) {
                      bs = new CurrentRowSpec();
                    }

                    }
                    break;
                case 4 :
                    // QSpecBuilder2.g:207:3: ^( LESS e= expression n= Number )
                    {
                    match(input,LESS,FOLLOW_LESS_in_valuesboundary999); if (failed) return bs;

                    match(input, Token.DOWN, null); if (failed) return bs;
                    pushFollow(FOLLOW_expression_in_valuesboundary1003);
                    e=expression();
                    _fsp--;
                    if (failed) return bs;
                    n=(CommonTree)input.LT(1);
                    match(input,Number,FOLLOW_Number_in_valuesboundary1007); if (failed) return bs;

                    match(input, Token.UP, null); if (failed) return bs;
                    if ( backtracking==0 ) {
                      bs = new ValueBoundarySpec(Direction.PRECEDING, e, Integer.parseInt(n.getText()));
                    }

                    }
                    break;
                case 5 :
                    // QSpecBuilder2.g:208:3: ^( MORE e= expression n= Number )
                    {
                    match(input,MORE,FOLLOW_MORE_in_valuesboundary1017); if (failed) return bs;

                    match(input, Token.DOWN, null); if (failed) return bs;
                    pushFollow(FOLLOW_expression_in_valuesboundary1021);
                    e=expression();
                    _fsp--;
                    if (failed) return bs;
                    n=(CommonTree)input.LT(1);
                    match(input,Number,FOLLOW_Number_in_valuesboundary1025); if (failed) return bs;

                    match(input, Token.UP, null); if (failed) return bs;
                    if ( backtracking==0 ) {
                      bs = new ValueBoundarySpec(Direction.PRECEDING, e, Integer.parseInt(n.getText()));
                    }

                    }
                    break;
View Full Code Here

 
  static BoundaryDef translateBoundary(QueryDef qDef, BoundarySpec bndSpec, InputInfo iInfo) throws WindowingException
  {
    if ( bndSpec instanceof ValueBoundarySpec )
    {
      ValueBoundarySpec vBndSpec = (ValueBoundarySpec) bndSpec;
      ValueBoundaryDef vbDef = new ValueBoundaryDef(vBndSpec);
      TranslateUtils.validateNoLeadLagInValueBoundarySpec(vBndSpec.getExpression());
      ExprNodeDesc exprNode = TranslateUtils.buildExprNode(vBndSpec.getExpression(), iInfo.getTypeCheckCtx());
      vbDef.setExprNode(exprNode);
      ExprNodeEvaluator exprEval = WindowingExprNodeEvaluatorFactory.get(qDef.getTranslationInfo(), exprNode);
      ObjectInspector OI = TranslateUtils.initExprNodeEvaluator(qDef, exprNode, exprEval, iInfo);
      TranslateUtils.validateValueBoundaryExprType(OI);
      vbDef.setExprEvaluator(exprEval);
View Full Code Here

 
  static void setupEvaluator(WindowFunctionDef wFnDef) throws WindowingException
  {
    try
    {
      WindowFunctionSpec wSpec = wFnDef.getSpec();
      ArrayList<ArgDef> args = wFnDef.getArgs();
      ArrayList<ObjectInspector> argOIs = getWritableObjectInspector(args);
      GenericUDAFEvaluator wFnEval = org.apache.hadoop.hive.ql.exec.FunctionRegistry.getGenericUDAFEvaluator(wSpec.getName(), argOIs, wSpec.isDistinct(), wSpec.isStar());
      ObjectInspector[] funcArgOIs = null;
     
      if ( args != null)
      {
        funcArgOIs = new ObjectInspector[args.size()];
View Full Code Here

TOP

Related Classes of com.sap.hadoop.windowing.query2.translate.WindowFunctionTranslation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.