Package org.eigenbase.relopt

Examples of org.eigenbase.relopt.RelOptCluster


  private static class HiveProjectFactoryImpl implements ProjectFactory {

    @Override
    public RelNode createProject(RelNode child,
        List<? extends RexNode> childExprs, List<String> fieldNames) {
      RelOptCluster cluster = child.getCluster();
      RelDataType rowType = RexUtil.createStructType(cluster.getTypeFactory(), childExprs, fieldNames);
      RelNode project = HiveProjectRel.create(cluster, child,
          childExprs, rowType,
          child.getTraitSet(), Collections.<RelCollation> emptyList());

      return project;
View Full Code Here


   * operation (UNION, EXCEPT, INTERSECT).
   */
  private static class SetOpFactoryImpl implements SetOpFactory {
    public RelNode createSetOp(SqlKind kind, List<RelNode> inputs,
        boolean all) {
      final RelOptCluster cluster = inputs.get(0).getCluster();
      switch (kind) {
      case UNION:
        return new UnionRel(cluster, inputs, all);
      case EXCEPT:
        return new MinusRel(cluster, inputs, all);
View Full Code Here

   */
  private static class JoinFactoryImpl implements JoinFactory {
    public RelNode createJoin(RelNode left, RelNode right,
        RexNode condition, JoinRelType joinType,
        Set<String> variablesStopped, boolean semiJoinDone) {
      final RelOptCluster cluster = left.getCluster();
      return new JoinRel(cluster, left, right, condition, joinType,
          variablesStopped, semiJoinDone, ImmutableList.<RelDataTypeField>of());
    }
View Full Code Here

    apply(call, null, aggregate, scan);
  }

  protected void apply(RelOptRuleCall call, ProjectRelBase postProject,
      final AggregateRelBase aggregate, StarTable.StarTableScan scan) {
    final RelOptCluster cluster = scan.getCluster();
    final RelOptTable table = scan.getTable();
    final RelOptLattice lattice = call.getPlanner().getLattice(table);
    final List<Lattice.Measure> measures =
        lattice.lattice.toMeasures(aggregate.getAggCallList());
    Pair<OptiqSchema.TableEntry, MaterializationService.TileKey> pair =
        lattice.getAggregate(call.getPlanner(), aggregate.getGroupSet(),
            measures);
    if (pair == null) {
      return;
    }
    final OptiqSchema.TableEntry tableEntry = pair.left;
    final MaterializationService.TileKey tileKey = pair.right;
    final double rowCount = aggregate.getRows();
    final Table aggregateTable = tableEntry.getTable();
    final RelDataType aggregateTableRowType =
        aggregateTable.getRowType(cluster.getTypeFactory());
    final RelOptTable aggregateRelOptTable =
        RelOptTableImpl.create(table.getRelOptSchema(), aggregateTableRowType,
            tableEntry, rowCount);
    RelNode rel = aggregateRelOptTable.toRel(RelOptUtil.getContext(cluster));
    if (tileKey == null) {
View Full Code Here

    final JoinRelBase topJoin = call.rel(0);
    final JoinRelBase bottomJoin = call.rel(1);
    final RelNode relA = bottomJoin.getLeft();
    final RelNode relB = bottomJoin.getRight();
    final RelSubset relC = call.rel(2);
    final RelOptCluster cluster = topJoin.getCluster();
    final RexBuilder rexBuilder = cluster.getRexBuilder();

    if (relC.getConvention() != relA.getConvention()) {
      // relC could have any trait-set. But if we're matching say
      // EnumerableConvention, we're only interested in enumerable subsets.
      return;
View Full Code Here

  public RelNode toRel(ToRelContext context) {
    if (table instanceof TranslatableTable) {
      return ((TranslatableTable) table).toRel(context, this);
    }
    RelOptCluster cluster = context.getCluster();
    Class elementType = deduceElementType();
    return new JavaRules.EnumerableTableAccessRel(
        cluster, cluster.traitSetOf(EnumerableConvention.INSTANCE),
        this, elementType);
  }
View Full Code Here

      throw new UnsupportedOperationException("unknown rex " + node);
    }
  }

  RexNode toRex(RelInput relInput, Object o) {
    final RelOptCluster cluster = relInput.getCluster();
    final RexBuilder rexBuilder = cluster.getRexBuilder();
    if (o == null) {
      return null;
    } else if (o instanceof Map) {
      Map map = (Map) o;
      final String op = (String) map.get("op");
      if (op != null) {
        final List operands = (List) map.get("operands");
        final Object jsonType = map.get("type");
        final SqlOperator operator = toOp(op, map);
        final List<RexNode> rexOperands = toRexList(relInput, operands);
        RelDataType type;
        if (jsonType != null) {
          type = toType(cluster.getTypeFactory(), jsonType);
        } else {
          type = rexBuilder.deriveReturnType(operator, rexOperands);
        }
        return rexBuilder.makeCall(type, operator, rexOperands);
      }
      final Integer input = (Integer) map.get("input");
      if (input != null) {
        List<RelNode> inputNodes = relInput.getInputs();
        int i = input;
        for (RelNode inputNode : inputNodes) {
          final RelDataType rowType = inputNode.getRowType();
          if (i < rowType.getFieldCount()) {
            final RelDataTypeField field = rowType.getFieldList().get(i);
            return rexBuilder.makeInputRef(field.getType(), input);
          }
          i -= rowType.getFieldCount();
        }
        throw new RuntimeException("input field " + input + " is out of range");
      }
      final String field = (String) map.get("field");
      if (field != null) {
        final Object jsonExpr = map.get("expr");
        final RexNode expr = toRex(relInput, jsonExpr);
        return rexBuilder.makeFieldAccess(expr, field, true);
      }
      final String correl = (String) map.get("correl");
      if (correl != null) {
        final Object jsonType = map.get("type");
        RelDataType type = toType(cluster.getTypeFactory(), jsonType);
        return rexBuilder.makeCorrel(type, correl);
      }
      if (map.containsKey("literal")) {
        final Object literal = map.get("literal");
        final SqlTypeName sqlTypeName =
View Full Code Here

    return Statistics.UNKNOWN;
    }

  public RelNode toRel( RelOptTable.ToRelContext context, RelOptTable table )
    {
    RelOptCluster cluster = context.getCluster();

    return new CascadingTableAccessRel( cluster, table, getName(), getIdentifier() );
    }
View Full Code Here

  {
  private static final Logger LOG = LoggerFactory.getLogger( CalcProjectUtil.class );

  static Branch resolveBranch( Stack stack, CascadingRelNode node, RexProgram program )
    {
    final RelOptCluster cluster = node.getCluster();

    CascadingRelNode child = (CascadingRelNode) ( (SingleRel) node ).getChild();
    Branch branch = child.visitChild( stack );
    Pipe pipe = branch.current;

    final List<String> names = getIncomingFieldNames( pipe );

    if( names != null && !names.equals( program.getInputRowType().getFieldNames() ) )
      program = renameInputs( program, cluster.getRexBuilder(), names );

    Split split = Split.of( program, cluster.getRexBuilder() );

    for( Pair<Op, RexProgram> pair : split.list )
      pipe = addProgram( cluster, pipe, pair.left, pair.right );

    pipe = stack.addDebug( node, pipe );
View Full Code Here

      }
    }

  public static RexProgram createRexProgram( CascadingProjectRel projectRel )
    {
    RelOptCluster cluster = projectRel.getCluster();
    RelDataType rowType = projectRel.getChild().getRowType();

    RexProgramBuilder builder = new RexProgramBuilder( rowType, cluster.getRexBuilder() );

    List<Pair<RexNode, String>> projects = projectRel.getNamedProjects();

    for( int i = 0; i < projects.size(); i++ )
      {
View Full Code Here

TOP

Related Classes of org.eigenbase.relopt.RelOptCluster

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.