Package plan_runner.components

Examples of plan_runner.components.Component


  private IndexCompGen generateTableJoins() {
    final List<Table> tableList = _pq.getTableList();

    final IndexCompGen cg = new IndexCompGen(_schema, _pq, _map);
    Component firstParent = cg
        .generateDataSource(ParserUtil.getComponentName(tableList.get(0)));

    // a special case
    if (tableList.size() == 1)
      return cg;
View Full Code Here


    for (final SelectItem elem : selectItems)
      elem.accept(selectVisitor);
    final List<AggregateOperator> aggOps = selectVisitor.getAggOps();
    final List<ValueExpression> groupByVEs = selectVisitor.getGroupByVEs();

    final Component affectedComponent = _cg.getQueryPlan().getLastComponent();
    attachSelectClause(aggOps, groupByVEs, affectedComponent);
    return (aggOps.isEmpty() ? IndexSelectItemsVisitor.NON_AGG : IndexSelectItemsVisitor.AGG);
  }
View Full Code Here

    return (aggOps.isEmpty() ? IndexSelectItemsVisitor.NON_AGG : IndexSelectItemsVisitor.AGG);
  }

  private void processWhereClause(Expression whereExpr) {
    // all the selection are performed on the last component
    final Component affectedComponent = _cg.getQueryPlan().getLastComponent();
    final IndexWhereVisitor whereVisitor = new IndexWhereVisitor(affectedComponent, _schema,
        _pq.getTan());
    if (whereExpr != null) {
      whereExpr.accept(whereVisitor);
      attachWhereClause(whereVisitor.getSelectOperator(), affectedComponent);
View Full Code Here

    // sorted by increasing cardinalities
    final List<String> sourceNames = factory.getParAssigner().getSortedSourceNames();

    final NameCompGen ncg = factory.create();

    Component first = ncg.generateDataSource(sourceNames.remove(0));
    final int numSources = sourceNames.size(); // first component is already
    // removed
    for (int i = 0; i < numSources; i++) {
      final String secondStr = chooseSmallestSource(first, sourceNames);
      final Component second = ncg.generateDataSource(secondStr);
      first = ncg.generateEquiJoin(first, second);
    }

    ParserUtil.parallelismToMap(ncg, _map);
View Full Code Here

    final ComparisonPredicate pred2 = new ComparisonPredicate(ComparisonPredicate.LESS_OP,
        mult, colOrdersInequality);

    final AndPredicate overallPred = new AndPredicate(pred1, pred2);

    Component lastJoiner = ThetaJoinComponentFactory
        .createThetaJoinOperator(Theta_JoinType, relationLineitem, relationOrders,
            _queryPlan).setJoinPredicate(overallPred)
        .addOperator(new ProjectOperator(new int[] { 1, 2, 4 })).addOperator(agg);
    ;
View Full Code Here

      final String firstCompName = sourceNames.get(i);
      final List<String> joinedWith = _pq.getJte().getJoinedWithSingleDir(firstCompName);
      if (joinedWith != null)
        for (final String secondCompName : joinedWith) {
          final NameCompGen ncg = factory.create();
          final Component first = ncg.generateDataSource(firstCompName);
          final Component second = ncg.generateDataSource(secondCompName);
          addEquiJoinNotSuboptimal(first, second, ncg, ncgListFirst);
        }
    }
    if (numSources == 2)
      optimal = chooseBest(ncgListFirst);

    // **************creating multi-way joins********************
    for (int level = 2; level < numSources; level++) {
      List<NameCompGen> ncgListSecond = new ArrayList<NameCompGen>();
      for (int i = 0; i < ncgListFirst.size(); i++) {
        final NameCompGen ncg = ncgListFirst.get(i);
        Component firstComp = ncg.getQueryPlan().getLastComponent();
        final List<String> ancestors = ParserUtil.getSourceNameList(firstComp);
        final List<String> joinedWith = _pq.getJte().getJoinedWith(ancestors);
        for (final String compName : joinedWith) {
          NameCompGen newNcg = ncg;
          if (joinedWith.size() > 1) {
            // doing deepCopy only if there are multiple tables to
            // be joined with
            newNcg = ncg.deepCopy();
            firstComp = newNcg.getQueryPlan().getLastComponent();
          }

          final Component secondComp = newNcg.generateDataSource(compName);
          addEquiJoinNotSuboptimal(firstComp, secondComp, newNcg, ncgListSecond);
        }
      }

      if (level == numSources - 1)
View Full Code Here

      _cpList.add(cp);
    }
  }

  private List<Integer> arrivedFromParents(CompPackage cp) {
    final Component comp = cp.getComponent();
    final Component[] parents = comp.getParents();

    final List<Integer> fromParents = new ArrayList<Integer>();
    // at least one parent
    final Component leftParent = parents[0];
    fromParents.addAll(extractProjIndexesAfterBottomUp(leftParent));

    if (parents.length == 2) {
      final Component rightParent = parents[1];
      List<Integer> rightIndexes = extractProjIndexesAfterBottomUp(rightParent);

      // take into account neglected hash from rhs
      rightIndexes = filterHash(rightIndexes, rightParent.getHashIndexes());

      // fromParents contains leftParent, that's why we use its size as an
      // offset
      rightIndexes = addOffset(rightIndexes, cp.getLeftParentOutputSize());
      fromParents.addAll(rightIndexes);
View Full Code Here

    //-------------------------------------------------------------------------------------
    ColumnReference colP = new ColumnReference(_ic, 0);
    ColumnReference colL = new ColumnReference(_ic, 1);
    ComparisonPredicate P_L_comp = new ComparisonPredicate(ComparisonPredicate.EQUAL_OP, colP,
        colL);
    Component P_Ljoin = ThetaJoinComponentFactory
        .createThetaJoinOperator(Theta_JoinType, relationPart, relationLineitem, _queryPlan)
        .setHashIndexes(Arrays.asList(0, 2)).setJoinPredicate(P_L_comp)
        .addOperator(new ProjectOperator(new int[] { 0, 1, 3, 4, 5, 6 }));

    //-------------------------------------------------------------------------------------

    List<Integer> hashPartsupp = Arrays.asList(0, 1);

    ProjectOperator projectionPartsupp = new ProjectOperator(new int[] { 0, 1, 3 });

    DataSourceComponent relationPartsupp = new DataSourceComponent("PARTSUPP", dataPath
        + "partsupp" + extension, _queryPlan).setHashIndexes(hashPartsupp).addOperator(
        projectionPartsupp);

    //-------------------------------------------------------------------------------------
    ColumnReference colP_L1 = new ColumnReference(_ic, 0);
    ColumnReference colP_L2 = new ColumnReference(_ic, 2);
    ColumnReference colPS1 = new ColumnReference(_ic, 0);
    ColumnReference colPS2 = new ColumnReference(_ic, 1);
    ComparisonPredicate P_L_PS1_comp = new ComparisonPredicate(ComparisonPredicate.EQUAL_OP,
        colP_L1, colPS1);

    ComparisonPredicate P_L_PS2_comp = new ComparisonPredicate(ComparisonPredicate.EQUAL_OP,
        colP_L2, colPS2);
    AndPredicate P_L_PS = new AndPredicate(P_L_PS1_comp, P_L_PS2_comp);

    Component P_L_PSjoin = ThetaJoinComponentFactory
        .createThetaJoinOperator(Theta_JoinType, P_Ljoin, relationPartsupp, _queryPlan)
        .setHashIndexes(Arrays.asList(0))
        .addOperator(new ProjectOperator(new int[] { 1, 2, 3, 4, 5, 8 }))
        .setJoinPredicate(P_L_PS);

    //-------------------------------------------------------------------------------------

    List<Integer> hashOrders = Arrays.asList(0);

    ProjectOperator projectionOrders = new ProjectOperator(new ColumnReference(_sc, 0),
        new IntegerYearFromDate(new ColumnReference(_dateConv, 4)));

    DataSourceComponent relationOrders = new DataSourceComponent("ORDERS", dataPath + "orders"
        + extension, _queryPlan).setHashIndexes(hashOrders).addOperator(projectionOrders);

    //-------------------------------------------------------------------------------------
    ColumnReference colP_L_PS = new ColumnReference(_ic, 0);
    ColumnReference colO = new ColumnReference(_ic, 0);
    ComparisonPredicate P_L_PS_O_comp = new ComparisonPredicate(ComparisonPredicate.EQUAL_OP,
        colP_L_PS, colO);

    Component P_L_PS_Ojoin = ThetaJoinComponentFactory
        .createThetaJoinOperator(Theta_JoinType, P_L_PSjoin, relationOrders, _queryPlan)
        .addOperator(new ProjectOperator(new int[] { 1, 2, 3, 4, 5, 7 }))
        .setJoinPredicate(P_L_PS_O_comp);

    //-------------------------------------------------------------------------------------

    List<Integer> hashSupplier = Arrays.asList(0);

    ProjectOperator projectionSupplier = new ProjectOperator(new int[] { 0, 3 });

    DataSourceComponent relationSupplier = new DataSourceComponent("SUPPLIER", dataPath
        + "supplier" + extension, _queryPlan).setHashIndexes(hashSupplier).addOperator(
        projectionSupplier);

    //-------------------------------------------------------------------------------------

    ColumnReference P_L_PS_O = new ColumnReference(_ic, 0);
    ColumnReference colS = new ColumnReference(_ic, 0);
    ComparisonPredicate P_L_PS_O_S_comp = new ComparisonPredicate(ComparisonPredicate.EQUAL_OP,
        P_L_PS_O, colS);

    Component P_L_PS_O_Sjoin = ThetaJoinComponentFactory
        .createThetaJoinOperator(Theta_JoinType, P_L_PS_Ojoin, relationSupplier, _queryPlan)
        .setHashIndexes(Arrays.asList(5))
        .addOperator(new ProjectOperator(new int[] { 1, 2, 3, 4, 5, 7 }))
        .setJoinPredicate(P_L_PS_O_S_comp);

    //-------------------------------------------------------------------------------------
    List<Integer> hashNation = Arrays.asList(0);

    ProjectOperator projectionNation = new ProjectOperator(new int[] { 0, 1 });

    DataSourceComponent relationNation = new DataSourceComponent("NATION", dataPath + "nation"
        + extension, _queryPlan).setHashIndexes(hashNation).addOperator(projectionNation);

    //-------------------------------------------------------------------------------------
    // set up aggregation function on the StormComponent(Bolt) where join is performed

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

    //ps_supplycost * l_quantity
    ValueExpression<Double> product2 = new Multiplication(new ColumnReference(_doubleConv, 3),
        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(
        ComparisonPredicate.EQUAL_OP, P_L_PS_O_S, colN);

    Component P_L_PS_O_S_Njoin = ThetaJoinComponentFactory
        .createThetaJoinOperator(Theta_JoinType, P_L_PS_O_Sjoin, relationNation, _queryPlan)
        .addOperator(new ProjectOperator(new int[] { 0, 1, 2, 3, 4, 7 })).addOperator(agg)
        .setJoinPredicate(P_L_PS_O_S_N_comp);

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

    // sending to parents
    final Component[] parents = component.getParents();
    if (parents != null) {
      // left
      final Component leftParent = parents[0];
      final int leftParentSize = ParserUtil.getPreOpsOutputSize(leftParent, _schema, _tan);
      final List<Integer> leftSentUsedIndexes = filterLess(allUsedIndexes, leftParentSize);
      bottomUp(leftParent, leftSentUsedIndexes, level + 1);

      // right
      if (parents.length == 2) {
        final Component rightParent = parents[1];
        final List<Integer> rightUsedIndexes = filterEqualBigger(allUsedIndexes,
            leftParentSize);
        final List<Integer> rightSentUsedIndexes = createRightSendIndexes(rightUsedIndexes,
            rightParent, leftParentSize);
        bottomUp(rightParent, rightSentUsedIndexes, level + 1);
View Full Code Here

  private void topDown() {
    Collections.sort(_cpList);
    for (final CompPackage cp : _cpList) {
      final List<Integer> fromParents = arrivedFromParents(cp);
      final Component comp = cp.getComponent();

      // update Selection indexes
      final List<ValueExpression> beforeProjVE = getBeforeProjVEs(comp);
      final List<ColumnReference> beforeProjColRefs = ParserUtil
          .getColumnRefFromVEs(beforeProjVE);
      updateColumnRefs(beforeProjColRefs, fromParents);

      // update Projection indexes
      final List<ValueExpression> projVE = comp.getChainOperator().getProjection()
          .getExpressions();
      final List<ColumnReference> projColRefs = ParserUtil.getColumnRefFromVEs(projVE);

      // after bottom-up: projection will be set, so it will contain all
      // the necessary fields,
View Full Code Here

TOP

Related Classes of plan_runner.components.Component

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.