当前位置: 首页>>代码示例>>Java>>正文


Java RexCall类代码示例

本文整理汇总了Java中org.eigenbase.rex.RexCall的典型用法代码示例。如果您正苦于以下问题:Java RexCall类的具体用法?Java RexCall怎么用?Java RexCall使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RexCall类属于org.eigenbase.rex包,在下文中一共展示了RexCall类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: translateRexNode

import org.eigenbase.rex.RexCall; //导入依赖的package包/类
private TblColRef translateRexNode(RexNode rexNode, ColumnRowType inputColumnRowType, String fieldName, Set<TblColRef> sourceCollector) {
    TblColRef column = null;
    if (rexNode instanceof RexInputRef) {
        RexInputRef inputRef = (RexInputRef) rexNode;
        column = translateRexInputRef(inputRef, inputColumnRowType, fieldName, sourceCollector);
    } else if (rexNode instanceof RexLiteral) {
        RexLiteral literal = (RexLiteral) rexNode;
        column = translateRexLiteral(literal);
    } else if (rexNode instanceof RexCall) {
        RexCall call = (RexCall) rexNode;
        column = translateRexCall(call, inputColumnRowType, fieldName, sourceCollector);
    } else {
        throw new IllegalStateException("Unsupport RexNode " + rexNode);
    }
    return column;
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:17,代码来源:OLAPProjectRel.java

示例2: translateJoinColumn

import org.eigenbase.rex.RexCall; //导入依赖的package包/类
private void translateJoinColumn(RexCall condition, Map<TblColRef, TblColRef> joinColumns) {
    SqlKind kind = condition.getOperator().getKind();
    if (kind == SqlKind.AND) {
        for (RexNode operand : condition.getOperands()) {
            RexCall subCond = (RexCall) operand;
            translateJoinColumn(subCond, joinColumns);
        }
    } else if (kind == SqlKind.EQUALS) {
        List<RexNode> operands = condition.getOperands();
        RexInputRef op0 = (RexInputRef) operands.get(0);
        TblColRef col0 = columnRowType.getColumnByIndex(op0.getIndex());
        RexInputRef op1 = (RexInputRef) operands.get(1);
        TblColRef col1 = columnRowType.getColumnByIndex(op1.getIndex());
        joinColumns.put(col0, col1);
    }
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:17,代码来源:OLAPJoinRel.java

示例3: getExprVarsFromRexCall

import org.eigenbase.rex.RexCall; //导入依赖的package包/类
public static void getExprVarsFromRexCall(RexNode cond, List<ExprVar> result) {
	if(cond instanceof RexCall) {
		RexCall call = (RexCall) cond;
		for(int i = 0; i < call.getOperands().size(); i++) {
			getExprVarsFromRexCall(call.getOperands().get(i), result);
		}
		return;
	}
	// assignable variable
	if(cond instanceof RexInputRef) {
		RexInputRef ref = (RexInputRef) cond;
		for (ExprVar expr : result) {
			if(expr.varName.equals(ref.getName())) {
				// variable already created;
				return;
			}
		}
		ExprVar e = new ExprVar();
		e.varName = ref.getName();
		e.positionInRecord = ref.getIndex();
		e.type = getTypeClass(ref.getType());
		result.add(e);
		return;
	}
}
 
开发者ID:rmetzger,项目名称:stratosphere-sql,代码行数:26,代码来源:StratosphereRelUtils.java

示例4: visitBinary

import org.eigenbase.rex.RexCall; //导入依赖的package包/类
public ChildVisitor visitBinary(RexCall binarySyntax) {

    ChildVisitor left = binarySyntax.getOperands().get(0).accept(this);
    ChildVisitor right = binarySyntax.getOperands().get(1).accept(this);

    SqlOperator operator = binarySyntax.getOperator();
    Operator op = null;
    switch (operator.getKind()) {
      case EQUALS:
        op = new FieldEquality(left, right);
        break;
      case AND:
        op = new AndOperator();
        break;
      case OR:
        op = new OrOperator();
        break;
      default:
        op = new Operator(operator);

    }
    op.addChild("left", left);
    op.addChild("right", right);
    return op;

  }
 
开发者ID:joshelser,项目名称:cosmos,代码行数:27,代码来源:OperationVisitor.java

示例5: buildJoin

import org.eigenbase.rex.RexCall; //导入依赖的package包/类
private JoinDesc buildJoin(RexCall condition) {
    Map<TblColRef, TblColRef> joinColumns = new HashMap<TblColRef, TblColRef>();
    translateJoinColumn(condition, joinColumns);

    List<String> pks = new ArrayList<String>();
    List<TblColRef> pkCols = new ArrayList<TblColRef>();
    List<String> fks = new ArrayList<String>();
    List<TblColRef> fkCols = new ArrayList<TblColRef>();
    String factTable = context.firstTableScan.getTableName();
    for (Map.Entry<TblColRef, TblColRef> columnPair : joinColumns.entrySet()) {
        TblColRef fromCol = columnPair.getKey();
        TblColRef toCol = columnPair.getValue();
        if (factTable.equalsIgnoreCase(fromCol.getTable())) {
            fks.add(fromCol.getName());
            fkCols.add(fromCol);
            pks.add(toCol.getName());
            pkCols.add(toCol);
        } else {
            fks.add(toCol.getName());
            fkCols.add(toCol);
            pks.add(fromCol.getName());
            pkCols.add(fromCol);
        }
    }

    JoinDesc join = new JoinDesc();
    join.setForeignKey(fks.toArray(COLUMN_ARRAY_MARKER));
    join.setForeignKeyColumns(fkCols.toArray(new TblColRef[fkCols.size()]));
    join.setPrimaryKey(pks.toArray(COLUMN_ARRAY_MARKER));
    join.setPrimaryKeyColumns(pkCols.toArray(new TblColRef[pkCols.size()]));
    return join;
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:33,代码来源:OLAPJoinRel.java

示例6: convertRexCallToJexlExpr

import org.eigenbase.rex.RexCall; //导入依赖的package包/类
public static String convertRexCallToJexlExpr(RexNode c) {
	StringBuffer sb = new StringBuffer();
	if(c instanceof RexCall) {
		RexCall call = (RexCall) c;
		sb.append("(");
		for(int i = 0; i < call.getOperands().size(); i++) {
			sb.append( convertRexCallToJexlExpr(call.getOperands().get(i)));
			if(i+1 <call.getOperands().size()) {
				switch(c.getKind()) {
					case AND:
						sb.append(" && ");
						break;
					case OR:
						sb.append(" || ");
						break;
					case EQUALS:
						sb.append(" == ");
						break;
					case LESS_THAN:
						sb.append(" < ");
						break;
					default:
						throw new RuntimeException("Unknown kind "+c.getKind());
				}
			}
		}
		sb.append(")");
	}
	// assignable variable
	if(c instanceof RexInputRef) {
		RexInputRef ref = (RexInputRef) c;
		return ref.getName();
	}
	if(c instanceof RexLiteral) {
		RexLiteral lit = (RexLiteral) c;
		return lit.getValue().toString();
	}
	return sb.toString();
}
 
开发者ID:rmetzger,项目名称:stratosphere-sql,代码行数:40,代码来源:StratosphereRelUtils.java

示例7: visitCall

import org.eigenbase.rex.RexCall; //导入依赖的package包/类
@Override
public ChildVisitor visitCall(RexCall call) {
  final SqlSyntax syntax = call.getOperator().getSyntax();
  switch (syntax) {
    case Binary:
      return visitBinary(call);
    case Function:
      buf.append(call.getOperator().getName().toLowerCase()).append("(");
      for (Ord<RexNode> operand : Ord.zip(call.getOperands())) {
        buf.append(operand.i > 0 ? ", " : "");
        operand.e.accept(this);
      }
      return null;
    case Special:
      switch (call.getKind()) {
        case Cast:
          // Ignore casts. Drill is type-less.
          return call.getOperands().get(0).accept(this);
        default:
          break;
      }
      if (call.getOperator() == SqlStdOperatorTable.itemOp) {
        final RexNode left = call.getOperands().get(0);
        final int length = buf.length();
        left.accept(this);
        if (buf.length() > length) {
          // check before generating empty LHS if inputName is null
          buf.append('.');
        }
        // return buf.append(field);
        return null;
      }
      // fall through
    default:
      throw new AssertionError("todo: implement syntax " + syntax + "(" + call + ")");
  }
}
 
开发者ID:joshelser,项目名称:cosmos,代码行数:38,代码来源:OperationVisitor.java

示例8: implementOLAP

import org.eigenbase.rex.RexCall; //导入依赖的package包/类
@Override
public void implementOLAP(OLAPImplementor implementor) {

    // create context for root join
    if (!(implementor.getParentNode() instanceof OLAPJoinRel)) {
        implementor.allocateContext();
    }
    this.context = implementor.getContext();
    this.isTopJoin = !this.context.hasJoin;
    this.context.hasJoin = true;

    // as we keep the first table as fact table, we need to visit from left
    // to right
    implementor.visitChild(this.left, this);
    if (this.context != implementor.getContext() || ((OLAPRel) this.left).hasSubQuery()) {
        this.hasSubQuery = true;
        implementor.freeContext();
    }
    implementor.visitChild(this.right, this);
    if (this.context != implementor.getContext() || ((OLAPRel) this.right).hasSubQuery()) {
        this.hasSubQuery = true;
        implementor.freeContext();
    }

    this.columnRowType = buildColumnRowType();
    if (isTopJoin) {
        this.context.afterJoin = true;
    }

    if (!this.hasSubQuery) {
        this.context.allColumns.clear();
        this.context.olapRowType = getRowType();
        buildAliasMap();

        // build JoinDesc
        RexCall condition = (RexCall) this.getCondition();
        JoinDesc join = buildJoin(condition);

        JoinRelType joinRelType = this.getJoinType();
        String joinType = joinRelType == JoinRelType.INNER ? "INNER" : joinRelType == JoinRelType.LEFT ? "LEFT" : null;
        join.setType(joinType);

        this.context.joins.add(join);
    }
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:46,代码来源:OLAPJoinRel.java


注:本文中的org.eigenbase.rex.RexCall类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。