Package org.eigenbase.rel

Examples of org.eigenbase.rel.RelNode


  @Override
  public RelOptCost computeSelfCost(RelOptPlanner planner) {
    if(PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
      return super.computeSelfCost(planner).multiplyBy(.1);
    }
    RelNode child = this.getChild();
    double inputRows = RelMetadataQuery.getRowCount(child);
    double cpuCost = DrillCostBase.COMPARE_CPU_COST * numConjuncts * inputRows;
    DrillCostFactory costFactory = (DrillCostFactory)planner.getCostFactory();
    return costFactory.makeCost(inputRows, cpuCost, 0, 0);   
  }
View Full Code Here


  public RelOptCost computeSelfCost(RelOptPlanner planner) {
    if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
      return super.computeSelfCost(planner).multiplyBy(.1);
    }

    RelNode child = this.getChild();
    double inputRows = RelMetadataQuery.getRowCount(child);

    int  rowWidth = child.getRowType().getFieldCount() * DrillCostBase.AVG_FIELD_WIDTH;

    double hashCpuCost = DrillCostBase.HASH_CPU_COST * inputRows / fields.size();
    double svrCpuCost = DrillCostBase.SVR_CPU_COST * inputRows;
    double networkCost = DrillCostBase.BYTE_NETWORK_COST * inputRows * rowWidth;
    DrillCostFactory costFactory = (DrillCostFactory)planner.getCostFactory();
View Full Code Here

  }

  @Override
  public void onMatch(RelOptRuleCall call) {
    final JoinRel join = (JoinRel) call.rel(0);
    final RelNode left = join.getLeft();
    final RelNode right = join.getRight();
    final RelTraitSet traits = join.getTraitSet().plus(DrillRel.DRILL_LOGICAL);

    final RelNode convertedLeft = convert(left, left.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
    final RelNode convertedRight = convert(right, right.getTraitSet().plus(DrillRel.DRILL_LOGICAL));

    List<Integer> leftKeys = Lists.newArrayList();
    List<Integer> rightKeys = Lists.newArrayList();
    int numLeftFields = convertedLeft.getRowType().getFieldCount();

    boolean addFilter = false;
    RexNode origJoinCondition = join.getCondition();
    RexNode newJoinCondition = origJoinCondition;

    RexNode remaining = RelOptUtil.splitJoinCondition(convertedLeft, convertedRight, origJoinCondition, leftKeys, rightKeys);
    boolean hasEquijoins = (leftKeys.size() == rightKeys.size() && leftKeys.size() > 0) ? true : false;

    // If the join involves equijoins and non-equijoins, then we can process the non-equijoins through
    // a filter right after the join
    if (! remaining.isAlwaysTrue()) {
      if (hasEquijoins) {
        addFilter = true;
        List<RexNode> equijoinList = Lists.newArrayList();
        List<RelDataTypeField> leftTypes = convertedLeft.getRowType().getFieldList();
        List<RelDataTypeField> rightTypes = convertedRight.getRowType().getFieldList();
        RexBuilder builder = join.getCluster().getRexBuilder();

        for (int i=0; i < leftKeys.size(); i++) {
          int leftKeyOrdinal = leftKeys.get(i).intValue();
          int rightKeyOrdinal = rightKeys.get(i).intValue();

          equijoinList.add(builder.makeCall(
              SqlStdOperatorTable.EQUALS,
              builder.makeInputRef(leftTypes.get(leftKeyOrdinal).getType(), leftKeyOrdinal),
              builder.makeInputRef(rightTypes.get(rightKeyOrdinal).getType(), rightKeyOrdinal + numLeftFields)
             ) );
        }
        newJoinCondition = RexUtil.composeConjunction(builder, equijoinList, false);
      } else {
//        tracer.warning("Non-equijoins are only supported in the presence of an equijoin.");
        return;
      }
    }
    //else {
    //
    //  return;
    // }

    try {
      if (!addFilter) {
       RelNode joinRel = new DrillJoinRel(join.getCluster(), traits, convertedLeft, convertedRight, origJoinCondition,
                                         join.getJoinType(), leftKeys, rightKeys, false);
       call.transformTo(joinRel);
      } else {
        RelNode joinRel = new DrillJoinRel(join.getCluster(), traits, convertedLeft, convertedRight, newJoinCondition,
                                           join.getJoinType(), leftKeys, rightKeys, false);
        call.transformTo(new DrillFilterRel(join.getCluster(), traits, joinRel, remaining));
      }
    } catch (InvalidRelException e) {
      tracer.warning(e.toString());
View Full Code Here

    limit.setInput(inputOp);
    return limit;
  }
 
  public static DrillLimitRel convert(Limit limit, ConversionContext context) throws InvalidRelException{
    RelNode input = context.toRel(limit.getInput());
    RexNode first = context.getRexBuilder().makeExactLiteral(BigDecimal.valueOf(limit.getFirst()), context.getTypeFactory().createSqlType(SqlTypeName.INTEGER));
    RexNode last = context.getRexBuilder().makeExactLiteral(BigDecimal.valueOf(limit.getLast()), context.getTypeFactory().createSqlType(SqlTypeName.INTEGER));
    return new DrillLimitRel(context.getCluster(), context.getLogicalTraits(), input, first, last);
  }
View Full Code Here

  public void onMatch(RelOptRuleCall call) {
    final UnionRel union = (UnionRel) call.rel(0);
    final RelTraitSet traits = union.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
    final List<RelNode> convertedInputs = new ArrayList<>();
    for (RelNode input : union.getInputs()) {
      final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
      convertedInputs.add(convertedInput);
    }
    try {
      call.transformTo(new DrillUnionRel(union.getCluster(), traits, convertedInputs, union.all));
    } catch (InvalidRelException e) {
View Full Code Here

  @Override
  public RelOptCost computeSelfCost(RelOptPlanner planner) {
    if(PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
      return super.computeSelfCost(planner).multiplyBy(.1);
    }
    RelNode child = this.getChild();
    double inputRows = RelMetadataQuery.getRowCount(child);

    int numGroupByFields = this.getGroupCount();
    int numAggrFields = this.aggCalls.size();
    double cpuCost = DrillCostBase.COMPARE_CPU_COST * numGroupByFields * inputRows;
 
View Full Code Here

  @Override
  public void onMatch(RelOptRuleCall call) {
    final SortRel incomingSort = call.rel(0);
    final RelTraitSet incomingTraits = incomingSort.getTraitSet();
    RelNode input = incomingSort.getChild();

    // if the Optiq sort rel includes a collation and a limit, we need to create a copy the sort rel that excludes the
    // limit information.
    if (!incomingSort.getCollation().getFieldCollations().isEmpty()) {
      input = incomingSort.copy(incomingTraits, input, incomingSort.getCollation(), null, null);
    }

    RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
    call.transformTo(new DrillLimitRel(incomingSort.getCluster(), convertedInput.getTraitSet().plus(DrillRel.DRILL_LOGICAL), convertedInput, incomingSort.offset, incomingSort.fetch));
  }
View Full Code Here

  }
 
  @Override
  public void onMatch(RelOptRuleCall call) {
    final DrillJoinRel join = (DrillJoinRel) call.rel(0);
    final RelNode left = join.getLeft();
    final RelNode right = join.getRight();

    if (!checkPreconditions(join, left, right)) {
      return;
    }
   
View Full Code Here

        }

        String viewSql = createView.getQuery().toString();

        SqlNode validatedQuery = planner.validate(createView.getQuery());
        RelNode validatedRelNode = planner.convert(validatedQuery);

        // If view's field list is specified then its size should match view's query field list size.
        RelDataType queryRowType = validatedRelNode.getRowType();

        List<String> viewFieldNames = createView.getFieldNames();
        if (viewFieldNames.size() > 0) {
          // number of fields match.
          if (viewFieldNames.size() != queryRowType.getFieldCount())
View Full Code Here

    SqlCreateTable sqlCreateTable = unwrap(sqlNode, SqlCreateTable.class);

    try {
      // Convert the query in CTAS statement into a RelNode
      SqlNode validatedQuery = validateNode(sqlCreateTable.getQuery());
      RelNode relQuery = convertToRel(validatedQuery);

      List<String> tblFiledNames = sqlCreateTable.getFieldNames();
      RelDataType queryRowType = relQuery.getRowType();

      if (tblFiledNames.size() > 0) {
        // Field count should match.
        if (tblFiledNames.size() != queryRowType.getFieldCount())
          return DirectPlan.createDirectPlan(context, false,
View Full Code Here

TOP

Related Classes of org.eigenbase.rel.RelNode

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.