@Test public void testDistribute1() { ConstantTupleExpression n = new ConstantTupleExpression(10); ExpressionCountDistributor cntDistributor = new ExpressionCountDistributor(n); TupleExpression t0 = new ConstantTupleExpression(1); TupleExpression t1 = new ConstantTupleExpression(1); TupleExpression t2 = new ConstantTupleExpression(2); TblColRef c = PowerMockito.mock(TblColRef.class); PowerMockito.when(c.getType()).thenReturn(DataType.getType("decimal")); TupleExpression t3 = new ColumnTupleExpression(c); IEvaluatableTuple evaluatableTuple = PowerMockito.mock(IEvaluatableTuple.class); IFilterCodeSystem filterCodeSystem = PowerMockito.mock(IFilterCodeSystem.class); t3 = PowerMockito.spy(t3); PowerMockito.when(t3.calculate(evaluatableTuple, filterCodeSystem)).thenReturn(new BigDecimal(3)); TupleExpression t4 = new ConstantTupleExpression(1); TupleExpression t5 = new ConstantTupleExpression(3); TupleExpression t6 = new ConstantTupleExpression(4); TupleExpression t7 = new ConstantTupleExpression(1); TupleExpression t8 = new ConstantTupleExpression(2); TupleExpression t9 = new ConstantTupleExpression(3); TupleExpression t10 = new ConstantTupleExpression(1); TupleExpression t11 = new ConstantTupleExpression(4); TupleExpression t12 = new ConstantTupleExpression(5); TupleExpression t13 = new ConstantTupleExpression(4); TupleExpression t14 = new ConstantTupleExpression(5); TupleExpression b0 = new BinaryTupleExpression(ExpressionOperatorEnum.PLUS, t1, t2); TupleExpression b1 = new BinaryTupleExpression(ExpressionOperatorEnum.MULTIPLE, t0, b0); TupleExpression b2 = new BinaryTupleExpression(ExpressionOperatorEnum.PLUS, t3, t4); TupleExpression b3 = new BinaryTupleExpression(ExpressionOperatorEnum.PLUS, t7, t8); TupleExpression b4 = new BinaryTupleExpression(ExpressionOperatorEnum.PLUS, t9, t10); TupleExpression b11 = new BinaryTupleExpression(ExpressionOperatorEnum.MULTIPLE, b1, b2); TupleExpression b12 = new BinaryTupleExpression(ExpressionOperatorEnum.PLUS, t5, t6); TupleExpression b13 = new BinaryTupleExpression(ExpressionOperatorEnum.MULTIPLE, b3, b4); TupleExpression b14 = new BinaryTupleExpression(ExpressionOperatorEnum.PLUS, t11, t12); TupleExpression b21 = new BinaryTupleExpression(ExpressionOperatorEnum.MULTIPLE, b11, b12); TupleExpression b22 = new BinaryTupleExpression(ExpressionOperatorEnum.MULTIPLE, b13, b14); TupleExpression b31 = new BinaryTupleExpression(ExpressionOperatorEnum.PLUS, b21, b22); TupleExpression b41 = new BinaryTupleExpression(ExpressionOperatorEnum.MINUS, b31, t13); TupleExpression b51 = new BinaryTupleExpression(ExpressionOperatorEnum.PLUS, b41, t14); TupleExpression ret = b51.accept(cntDistributor); assertTrue(cntDistributor.ifCntSet()); assertEquals(new BigDecimal(1363), ret.calculate(evaluatableTuple, filterCodeSystem)); }
public boolean ifCntSet() { return ifCntSet; }
ExpressionCountDistributor implements ExpressionVisitor { public boolean ifCntSet() { return ifCntSet; } }
ExpressionCountDistributor implements ExpressionVisitor { public boolean ifCntSet() { return ifCntSet; } ExpressionCountDistributor(TupleExpression cntExpr); }
ExpressionCountDistributor implements ExpressionVisitor { public boolean ifCntSet() { return ifCntSet; } ExpressionCountDistributor(TupleExpression cntExpr); @Override TupleExpression visitConstant(ConstantTupleExpression constExpr); @Override TupleExpression visitColumn(ColumnTupleExpression colExpr); @Override TupleExpression visitBinary(BinaryTupleExpression binaryExpr); @Override TupleExpression visitCaseCall(CaseTupleExpression caseExpr); @Override TupleExpression visitRexCall(RexCallTupleExpression rexCallExpr); @Override TupleExpression visitNone(NoneTupleExpression noneExpr); boolean ifCntSet(); }
ExpressionCountDistributor implements ExpressionVisitor { public boolean ifCntSet() { return ifCntSet; } ExpressionCountDistributor(TupleExpression cntExpr); @Override TupleExpression visitConstant(ConstantTupleExpression constExpr); @Override TupleExpression visitColumn(ColumnTupleExpression colExpr); @Override TupleExpression visitBinary(BinaryTupleExpression binaryExpr); @Override TupleExpression visitCaseCall(CaseTupleExpression caseExpr); @Override TupleExpression visitRexCall(RexCallTupleExpression rexCallExpr); @Override TupleExpression visitNone(NoneTupleExpression noneExpr); boolean ifCntSet();  }