本文整理汇总了Java中org.apache.calcite.rex.RexCall.getOperands方法的典型用法代码示例。如果您正苦于以下问题:Java RexCall.getOperands方法的具体用法?Java RexCall.getOperands怎么用?Java RexCall.getOperands使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rex.RexCall
的用法示例。
在下文中一共展示了RexCall.getOperands方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFunction
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private LogicalExpression doFunction(RexCall call, String funcName) {
List<LogicalExpression> args = Lists.newArrayList();
for(RexNode r : call.getOperands()){
args.add(r.accept(this));
}
if (FunctionCallFactory.isBooleanOperator(funcName)) {
LogicalExpression func = FunctionCallFactory.createBooleanOperator(funcName, args);
return func;
} else {
args = Lists.reverse(args);
LogicalExpression lastArg = args.get(0);
for(int i = 1; i < args.size(); i++){
lastArg = FunctionCallFactory.createExpression(funcName, Lists.newArrayList(args.get(i), lastArg));
}
return lastArg;
}
}
示例2: extractEquals
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private static JoinConditionInfo extractEquals(JoinDefinition joinDefinition, RexCall c) {
List<RexNode> operands = c.getOperands();
if (operands.size() != 2) {
throw new IllegalArgumentException(c.toString());
}
RexNode opA = operands.get(0);
RexNode opB = operands.get(1);
RelColumnOrigin oA = getOrigin(joinDefinition, opA);
RelColumnOrigin oB = getOrigin(joinDefinition, opB);
if (oA == null || oB == null) {
return null;
}
return new JoinConditionInfo(Origins.getColName(oA), Origins.getColName(oB))
.setTableAList(Origins.getTable(oA))
.setTableBList(Origins.getTable(oB));
}
示例3: extractJoinColumns
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private List<Pair<Integer, Integer>> extractJoinColumns(int leftRowColumnCount) {
// it's a CROSS JOIN because: condition == true
if (condition instanceof RexLiteral && (Boolean) ((RexLiteral) condition).getValue()) {
throw new UnsupportedOperationException("CROSS JOIN is not supported!");
}
RexCall call = (RexCall) condition;
List<Pair<Integer, Integer>> pairs = new ArrayList<>();
if ("AND".equals(call.getOperator().getName())) {
List<RexNode> operands = call.getOperands();
for (RexNode rexNode : operands) {
Pair<Integer, Integer> pair = extractOneJoinColumn((RexCall) rexNode, leftRowColumnCount);
pairs.add(pair);
}
} else if ("=".equals(call.getOperator().getName())) {
pairs.add(extractOneJoinColumn(call, leftRowColumnCount));
} else {
throw new UnsupportedOperationException(
"Operator " + call.getOperator().getName() + " is not supported in join condition");
}
return pairs;
}
示例4: translateJoinColumn
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
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());
// map left => right
if (op0.getIndex() < columnRowTypeLeftRightCut)
joinColumns.put(col0, col1);
else
joinColumns.put(col1, col0);
}
}
示例5: averageRexSize
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
public Double averageRexSize(RexNode node, List<Double> inputColumnSizes) {
switch (node.getKind()) {
case INPUT_REF:
return inputColumnSizes.get(((RexInputRef) node).getIndex());
case LITERAL:
return typeValueSize(node.getType(),
((RexLiteral) node).getValueAs(Comparable.class));
default:
if (node instanceof RexCall) {
RexCall call = (RexCall) node;
for (RexNode operand : call.getOperands()) {
// It's a reasonable assumption that a function's result will have
// similar size to its argument of a similar type. For example,
// UPPER(c) has the same average size as c.
if (operand.getType().getSqlTypeName()
== node.getType().getSqlTypeName()) {
return averageRexSize(operand, inputColumnSizes);
}
}
}
return averageTypeValueSize(node.getType());
}
}
示例6: populateEquivalences
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private static void populateEquivalences(Map<Integer, BitSet> equivalence,
RexNode predicate) {
switch (predicate.getKind()) {
case EQUALS:
RexCall call = (RexCall) predicate;
final List<RexNode> operands = call.getOperands();
if (operands.get(0) instanceof RexInputRef) {
final RexInputRef ref0 = (RexInputRef) operands.get(0);
if (operands.get(1) instanceof RexInputRef) {
final RexInputRef ref1 = (RexInputRef) operands.get(1);
populateEquivalence(equivalence, ref0.getIndex(), ref1.getIndex());
populateEquivalence(equivalence, ref1.getIndex(), ref0.getIndex());
}
}
}
}
示例7: findCorrelationEquivalent
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
/** Finds a {@link RexInputRef} that is equivalent to a {@link CorRef},
* and if found, throws a {@link org.apache.calcite.util.Util.FoundOne}. */
private void findCorrelationEquivalent(CorRef correlation, RexNode e)
throws Util.FoundOne {
switch (e.getKind()) {
case EQUALS:
final RexCall call = (RexCall) e;
final List<RexNode> operands = call.getOperands();
if (references(operands.get(0), correlation)) {
throw new Util.FoundOne(operands.get(1));
}
if (references(operands.get(1), correlation)) {
throw new Util.FoundOne(operands.get(0));
}
break;
case AND:
for (RexNode operand : ((RexCall) e).getOperands()) {
findCorrelationEquivalent(correlation, operand);
}
}
}
示例8: visitCall
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override
public RexNode visitCall(RexCall call) {
SqlOperator op = call.getOperator();
SqlKind kind = op.getKind();
RelDataType type = call.getType();
if (kind == SqlKind.OR || kind == SqlKind.AND) {
if (call.getOperands().size() > 2) {
List<RexNode> children = new ArrayList(call.getOperands());
RexNode left = children.remove(0).accept(this);
RexNode right = builder.makeCall(type, op, children).accept(this);
return builder.makeCall(type, op, ImmutableList.of(left, right));
}
}
return builder.makeCall(type, op, visitChildren(call));
}
示例9: visitChildren
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private List<RexNode> visitChildren(RexCall call) {
List<RexNode> children = Lists.newArrayList();
for (RexNode child : call.getOperands()) {
children.add(child.accept(this));
}
return ImmutableList.copyOf(children);
}
示例10: visitCall
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override
public RexNode visitCall(RexCall call) {
SqlOperator op = call.getOperator();
SqlKind kind = op.getKind();
RelDataType type = call.getType();
if (kind == SqlKind.OR || kind == SqlKind.AND) {
if (call.getOperands().size() > 2) {
List<RexNode> children = new ArrayList<>(call.getOperands());
RexNode left = children.remove(0).accept(this);
RexNode right = builder.makeCall(type, op, children).accept(this);
return builder.makeCall(type, op, ImmutableList.of(left, right));
}
}
return builder.makeCall(type, op, visitChildren(call));
}
示例11: visitCall
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override
public Boolean visitCall(RexCall call) {
if (call.getOperator() instanceof SqlFlattenOperator) {
return true;
}
for (RexNode op : call.getOperands()) {
if (op.accept(this)) {
return true;
}
}
return false;
}
示例12: visitCall
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override
public Boolean visitCall(RexCall call) {
if (call.getOperator().getName().equalsIgnoreCase("flatten")) {
return true;
}
for (RexNode op : call.getOperands()) {
Boolean opResult = op.accept(this);
if (opResult != null && opResult.booleanValue()) {
return true;
}
}
return false;
}
示例13: visitCall
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override
public Expression visitCall(RexCall call) {
SqlSyntax syntax = call.getOperator().getSyntax();
if (!supportedRexCall(call)) {
throw new PredicateAnalyzerException(format("Unsupported call: [%s]", call));
}
switch (syntax) {
case BINARY:
return binary(call);
case POSTFIX:
return postfix(call);
case SPECIAL:
switch (call.getKind()) {
case CAST:
return cast(call);
case LIKE:
SqlLikeOperator likeOperator = (SqlLikeOperator) call.getOperator();
if (!likeOperator.isNegated()) {
return binary(call);
}
throw new PredicateAnalyzerException(format("Unsupported call: [%s]", call));
default:
throw new PredicateAnalyzerException(format("Unsupported call: [%s]", call));
}
case FUNCTION:
if (call.getOperator().getName().equalsIgnoreCase("CONTAINS")) {
List<Expression> operands = Lists.newArrayList();
for (RexNode node : call.getOperands()) {
final Expression nodeExpr = node.accept(this);
operands.add(nodeExpr);
}
String query = convertQueryString(operands.subList(0, operands.size() - 1), operands.get(operands.size() - 1));
return QueryExpression.create(new NamedFieldExpression(null)).queryString(query);
}
default:
throw new PredicateAnalyzerException(format("Unsupported syntax [%s] for call: [%s]", syntax, call));
}
}
示例14: render
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override
public FunctionRender render(FunctionRenderer renderer, RexCall call) {
List<Iterable<NullReference>> refs = new ArrayList<>();
List<String> operands = Lists.newArrayListWithCapacity(call.getOperands().size());
for (RexNode childCall : call.getOperands()) {
FunctionRender r = childCall.accept(renderer.getVisitor());
operands.add(r.getScript());
refs.add(r.getNulls());
}
return new FunctionRender("( " + Joiner.on(" " + elasticName + " ").join(operands) + " )", Iterables.concat(refs));
}
示例15: extractOneJoinColumn
import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private Pair<Integer, Integer> extractOneJoinColumn(RexCall oneCondition,
int leftRowColumnCount) {
List<RexNode> operands = oneCondition.getOperands();
final int leftIndex = Math.min(((RexInputRef) operands.get(0)).getIndex(),
((RexInputRef) operands.get(1)).getIndex());
final int rightIndex1 = Math.max(((RexInputRef) operands.get(0)).getIndex(),
((RexInputRef) operands.get(1)).getIndex());
final int rightIndex = rightIndex1 - leftRowColumnCount;
return new Pair<>(leftIndex, rightIndex);
}