Package plan_runner.operators

Examples of plan_runner.operators.AggregateOperator


    ValueExpression<Double> substract = new Subtraction(
        new ValueSpecification(_doubleConv, 1.0), new ColumnReference(_doubleConv, 8));
    //extendedPrice*(1-discount)
    ValueExpression<Double> product = new Multiplication(new ColumnReference(_doubleConv, 7),
        substract);
    AggregateOperator agg = new AggregateSumOperator(product, conf)
    //.setGroupByColumns(Arrays.asList(0, 1, 4, 6, 2, 3, 5));
        .setGroupByColumns(Arrays.asList(0, 1, 4, 6, 2, 3, 5));

    ColumnReference colC_O_N = new ColumnReference(_ic, 6);
    ColumnReference colL = new ColumnReference(_ic, 0);
View Full Code Here


        new ValueSpecification(_doubleConv, 1.0), new ColumnReference(_doubleConv, 2));
    //extendedPrice*(1-discount)
    ValueExpression<Double> product = new Multiplication(new ColumnReference(_doubleConv, 1),
        substract);

    AggregateOperator aggOp = new AggregateSumOperator(product, conf).setGroupByColumns(Arrays
        .asList(0));
    OperatorComponent finalComponent = new OperatorComponent(R_N_S_L_C_Ojoin, "FINAL_RESULT",
        _queryPlan).addOperator(aggOp);

    //-------------------------------------------------------------------------------------
View Full Code Here

    if (aggOps.isEmpty()) {
      if (project != null)
        lastComponent.addOperator(project);
    } else if (aggOps.size() == 1) {
      // all the others are group by
      final AggregateOperator firstAgg = aggOps.get(0);
      if (project != null)
        firstAgg.setGroupByProjection(project);

      /*
       * Avg result cannot be aggregated over multiple nodes. Solution is
       * one of the following: a) the output of average is keeped in a
       * form (Sum, Count) and then a user is responsible to aggregate it
       * over nodes b) if NameTranslator.isSuperset for last join keys and
       * GroupBy is not fullfilled create new level node with aggregation
       * as the only operation To be akin to Sum and Count aggregates, we
       * opted for a)
       */
      if (firstAgg.getDistinct() == null)
        lastComponent.addOperator(firstAgg);
      else
        // in general groupByVEs is not a ColumnReference (it can be an
        // addition, for example).
        // ProjectOperator is not obliged to create schema which fully
View Full Code Here

    OperatorComponent opComp = null;

    // projectOperator is already set to firstAgg in attachLastJoin method
    // if we decide to do construct new NSIV, then projectOperator has to be
    // set as well
    final AggregateOperator firstAgg = aggOps.get(0);

    // Setting new level of components is only necessary for distinct in
    // aggregates
    if (firstAgg.getDistinct() != null) {
      opComp = createAndAddOperatorComp(lastComponent);

      createCompCost(opComp);
      if (_costEst != null)
        _costEst.setInputParams(opComp);
View Full Code Here

    if (aggOps.isEmpty()) {
      final ProjectOperator project = new ProjectOperator(groupByVEs);
      lastComponent.addOperator(project);
    } else if (aggOps.size() == 1) {
      // all the others are group by
      final AggregateOperator firstAgg = aggOps.get(0);

      if (ParserUtil.isAllColumnRefs(groupByVEs)) {
        // plain fields in select
        final List<Integer> groupByColumns = ParserUtil.extractColumnIndexes(groupByVEs);
        firstAgg.setGroupByColumns(groupByColumns);

        // Setting new level of components is necessary for correctness
        // only for distinct in aggregates
        // but it's certainly pleasant to have the final result grouped
        // on nodes by group by columns.
        final boolean newLevel = !(_it.isHashedBy(lastComponent, groupByColumns));
        if (newLevel) {
          lastComponent.setHashIndexes(groupByColumns);
          new OperatorComponent(lastComponent, ParserUtil.generateUniqueName("OPERATOR"),
              _cg.getQueryPlan()).addOperator(firstAgg);

        } else
          lastComponent.addOperator(firstAgg);
      } else {
        // Sometimes groupByVEs contains other functions, so we have to
        // use projections instead of simple groupBy
        // always new level

        // WARNING: groupByVEs cannot be used on two places: that's why
        // we do deep copy
        final ProjectOperator groupByProj = new ProjectOperator(
            (List<ValueExpression>) DeepCopy.copy(groupByVEs));
        if (!(groupByProj.getExpressions() == null || groupByProj.getExpressions()
            .isEmpty()))
          firstAgg.setGroupByProjection(groupByProj);

        // current component
        lastComponent.setHashExpressions((List<ValueExpression>) DeepCopy.copy(groupByVEs));

        new OperatorComponent(lastComponent, ParserUtil.generateUniqueName("OPERATOR"),
View Full Code Here

    if (aggOps.isEmpty()) {
      final ProjectOperator project = new ProjectOperator(groupByVEs);
      affectedComponent.addOperator(project);
    } else if (aggOps.size() == 1) {
      // all the others are group by
      final AggregateOperator firstAgg = aggOps.get(0);

      if (ParserUtil.isAllColumnRefs(groupByVEs)) {
        // plain fields in select
        final List<Integer> groupByColumns = ParserUtil.extractColumnIndexes(groupByVEs);
        firstAgg.setGroupByColumns(groupByColumns);

        // Setting new level of components is necessary for correctness
        // only for distinct in aggregates
        // but it's certainly pleasant to have the final result grouped
        // on nodes by group by columns.
        final boolean newLevel = !(_it.isHashedBy(affectedComponent, groupByColumns));
        if (newLevel) {
          affectedComponent.setHashIndexes(groupByColumns);
          new OperatorComponent(affectedComponent,
              ParserUtil.generateUniqueName("OPERATOR"), _cg.getQueryPlan())
              .addOperator(firstAgg);

        } else
          affectedComponent.addOperator(firstAgg);
      } else {
        // Sometimes groupByVEs contains other functions, so we have to
        // use projections instead of simple groupBy
        // always new level

        if (affectedComponent.getHashExpressions() != null
            && !affectedComponent.getHashExpressions().isEmpty())
          throw new RuntimeException(
              "Too complex: cannot have hashExpression both for joinCondition and groupBy!");

        // WARNING: groupByVEs cannot be used on two places: that's why
        // we do deep copy
        final ProjectOperator groupByProj = new ProjectOperator(
            (List<ValueExpression>) DeepCopy.copy(groupByVEs));
        if (!(groupByProj.getExpressions() == null || groupByProj.getExpressions()
            .isEmpty()))
          firstAgg.setGroupByProjection(groupByProj);

        // current component
        affectedComponent.setHashExpressions((List<ValueExpression>) DeepCopy
            .copy(groupByVEs));
View Full Code Here

            new ValueSpecification(_sc, _secondCountryName))), new AndPredicate(
        new ComparisonPredicate(new ColumnReference(_sc, 0), new ValueSpecification(_sc,
            _secondCountryName)), new ComparisonPredicate(new ColumnReference(_sc, 2),
            new ValueSpecification(_sc, _firstCountryName)))));

    final AggregateOperator agg = new AggregateSumOperator(new ColumnReference(_doubleConv, 4),
        conf).setGroupByColumns(new ArrayList<Integer>(Arrays.asList(2, 0, 3)));

    final ColumnReference colN_C_O = new ColumnReference(_ic, 1);
    final ColumnReference colL_S_N = new ColumnReference(_ic, 3);
    final ComparisonPredicate N_C_O_L_S_N_comp = new ComparisonPredicate(
View Full Code Here

    final ValueExpression<Double> substract = new Subtraction(new ValueSpecification(
        _doubleConv, 1.0), new ColumnReference(_doubleConv, 1));
    // extendedPrice*(1-discount)
    final ValueExpression<Double> product = new Multiplication(new ColumnReference(_doubleConv,
        0), substract);
    final AggregateOperator agg = new AggregateSumOperator(product, conf);

    // /Join predicate
    final ColumnReference colLineItems = new ColumnReference(_ic, 0);
    final ColumnReference colOrders = new ColumnReference(_ic, 0);
    final ComparisonPredicate pred1 = new ComparisonPredicate(ComparisonPredicate.EQUAL_OP,
View Full Code Here

    // add integers: hashIndexes and groupBy in aggregation
    final List<Integer> hashIndexes = component.getHashIndexes();
    if (hashIndexes != null)
      result.addAll(hashIndexes);
    final AggregateOperator agg = component.getChainOperator().getAggregation();
    if (agg != null) {
      final List<Integer> groupBy = agg.getGroupByColumns();
      if (groupBy != null)
        result.addAll(groupBy);
    }

    return result;
View Full Code Here

        new ColumnReference(_doubleConv, 0));

    //all together
    ValueExpression<Double> substract2 = new Subtraction(product1, product2);

    AggregateOperator agg = new AggregateSumOperator(substract2, conf).setGroupByColumns(Arrays
        .asList(5, 4));

    ColumnReference P_L_PS_O_S = new ColumnReference(_ic, 5);
    ColumnReference colN = new ColumnReference(_ic, 0);
    ComparisonPredicate P_L_PS_O_S_N_comp = new ComparisonPredicate(
View Full Code Here

TOP

Related Classes of plan_runner.operators.AggregateOperator

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.