本文整理了Java中org.apache.calcite.rex.RexInputRef.getIndex
方法的一些代码示例,展示了RexInputRef.getIndex
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RexInputRef.getIndex
方法的具体详情如下:
包路径:org.apache.calcite.rex.RexInputRef
类名称:RexInputRef
方法名:getIndex
暂无
代码示例来源:origin: apache/nifi
private int[] getProjectFields(List<RexNode> exps) {
final int[] fields = new int[exps.size()];
for (int i = 0; i < exps.size(); i++) {
final RexNode exp = exps.get(i);
if (exp instanceof RexInputRef) {
fields[i] = ((RexInputRef) exp).getIndex();
} else {
return null; // not a simple projection
}
}
return fields;
}
}
代码示例来源:origin: apache/drill
private boolean isSimple(Project project) {
RexNode r = project.getProjects().get(joinKey);
if (r instanceof RexInputRef) {
joinKey = ((RexInputRef) r).getIndex();
return true;
}
return false;
}
代码示例来源:origin: apache/hive
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());
}
}
}
}
代码示例来源:origin: apache/hive
@Override
public RexNode visitInputRef(RexInputRef inputRef) {
RelDataTypeField f = rType.getFieldList().get(inputRef.getIndex());
if (partCols.contains(f.getName())) {
return inputRef;
} else {
return null;
}
}
代码示例来源:origin: apache/drill
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());
}
}
}
}
代码示例来源:origin: apache/drill
@Override
public RexNode visitInputRef(RexInputRef inputRef) {
RelDataTypeField f = rType.getFieldList().get(inputRef.getIndex());
if (partCols.contains(f.getName())) {
return inputRef;
} else {
return null;
}
}
代码示例来源:origin: apache/hive
@Override
public ExprNodeDesc visitInputRef(RexInputRef inputRef) {
RelDataTypeField f = inputRowType.getFieldList().get(inputRef.getIndex());
return new ExprNodeColumnDesc(TypeConverter.convert(f.getType()), f.getName(), tabAlias,
inputVCols.contains(inputRef.getIndex()));
}
代码示例来源:origin: apache/hive
private static Pair<ArrayList<ColumnInfo>, Set<Integer>> createColInfos(
List<RexNode> calciteExprs, List<ExprNodeDesc> hiveExprs, List<String> projNames,
OpAttr inpOpAf) {
if (hiveExprs.size() != projNames.size()) {
throw new RuntimeException("Column expressions list doesn't match Column Names list");
}
RexNode rexN;
ExprNodeDesc pe;
ArrayList<ColumnInfo> colInfos = new ArrayList<ColumnInfo>();
boolean vc;
Set<Integer> newVColSet = new HashSet<Integer>();
for (int i = 0; i < hiveExprs.size(); i++) {
pe = hiveExprs.get(i);
rexN = calciteExprs.get(i);
vc = false;
if (rexN instanceof RexInputRef) {
if (inpOpAf.vcolsInCalcite.contains(((RexInputRef) rexN).getIndex())) {
newVColSet.add(i);
vc = true;
}
}
colInfos
.add(new ColumnInfo(projNames.get(i), pe.getTypeInfo(), inpOpAf.tabAlias, vc));
}
return new Pair<ArrayList<ColumnInfo>, Set<Integer>>(colInfos, newVColSet);
}
代码示例来源:origin: apache/kylin
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);
}
}
代码示例来源:origin: apache/drill
private static Pair<ArrayList<ColumnInfo>, Set<Integer>> createColInfos(
List<RexNode> calciteExprs, List<ExprNodeDesc> hiveExprs, List<String> projNames,
OpAttr inpOpAf) {
if (hiveExprs.size() != projNames.size()) {
throw new RuntimeException("Column expressions list doesn't match Column Names list");
}
RexNode rexN;
ExprNodeDesc pe;
ArrayList<ColumnInfo> colInfos = new ArrayList<ColumnInfo>();
boolean vc;
Set<Integer> newVColSet = new HashSet<Integer>();
for (int i = 0; i < hiveExprs.size(); i++) {
pe = hiveExprs.get(i);
rexN = calciteExprs.get(i);
vc = false;
if (rexN instanceof RexInputRef) {
if (inpOpAf.vcolsInCalcite.contains(((RexInputRef) rexN).getIndex())) {
newVColSet.add(i);
vc = true;
}
}
colInfos
.add(new ColumnInfo(projNames.get(i), pe.getTypeInfo(), inpOpAf.tabAlias, vc));
}
return new Pair<ArrayList<ColumnInfo>, Set<Integer>>(colInfos, newVColSet);
}
代码示例来源:origin: apache/drill
@Override
public ExprNodeDesc visitInputRef(RexInputRef inputRef) {
RelDataTypeField f = inputRowType.getFieldList().get(inputRef.getIndex());
return new ExprNodeColumnDesc(TypeConverter.convert(f.getType()), f.getName(), tabAlias,
inputVCols.contains(inputRef.getIndex()));
}
代码示例来源:origin: apache/drill
@Override public RexNode visitInputRef(RexInputRef ref) {
RelDataTypeField f = oldFields.get(ref.getIndex());
for (int index = 0; index < newFields.size(); index++) {
RelDataTypeField newf = newFields.get(index);
if (f.getKey().equals(newf.getKey())
&& f.getValue() == newf.getValue()) {
return new RexInputRef(index, f.getValue());
}
}
throw MatchFailed.INSTANCE;
}
};
代码示例来源:origin: apache/hive
private boolean isSimple(Project project) {
ImmutableBitSet.Builder b = ImmutableBitSet.builder();
for (int pos : joinKey) {
RexNode r = project.getProjects().get(pos);
if (!(r instanceof RexInputRef)) {
return false;
}
b.set(((RexInputRef) r).getIndex());
}
joinKey = b.build();
return true;
}
代码示例来源:origin: apache/drill
/** Finds a {@link RexInputRef} that is equivalent to a {@link CorRef},
* and if found, throws a {@link 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)
&& operands.get(1) instanceof RexInputRef) {
throw new Util.FoundOne(((RexInputRef) operands.get(1)).getIndex());
}
if (references(operands.get(1), correlation)
&& operands.get(0) instanceof RexInputRef) {
throw new Util.FoundOne(((RexInputRef) operands.get(0)).getIndex());
}
break;
case AND:
for (RexNode operand : ((RexCall) e).getOperands()) {
findCorrelationEquivalent(correlation, operand);
}
}
}
代码示例来源:origin: apache/hive
@Override
public Void visitInputRef(RexInputRef inputRef) {
if (!areTypesCompatible(inputRef.getType(), types.get(inputRef.getIndex()).getType())) {
throw new Util.FoundOne(inputRef);
}
return super.visitInputRef(inputRef);
}
代码示例来源:origin: apache/hive
@Override
public Void visitCall(RexCall call) {
if(AnnotationUtils.getAnnotation(GenericUDFOPNotNull.class, Description.class).name().equals(call.getOperator().getName())) {
if(call.getOperands().get(0) instanceof RexInputRef &&
!types.get(((RexInputRef)call.getOperands().get(0)).getIndex()).getType().isNullable()) {
// No need to add not null filter for a constant.
throw new Util.FoundOne(call);
}
}
return super.visitCall(call);
}
代码示例来源:origin: apache/hive
if (!(equals.getOperands().get(0) instanceof RexInputRef) ||
!(equals.getOperands().get(1) instanceof RexInputRef)) {
otherConjuncts.add(conj);
continue;
RexInputRef ref0 = (RexInputRef) equals.getOperands().get(0);
RexInputRef ref1 = (RexInputRef) equals.getOperands().get(1);
if ((ref0.getIndex() < nLeftColumns && ref1.getIndex() >= nLeftColumns) ||
(ref1.getIndex() < nLeftColumns && ref0.getIndex() >= nLeftColumns)) {
idxToConjuncts.put(ref0.getIndex(), equals);
idxToConjuncts.put(ref1.getIndex(), equals);
refToRef.put(ref0.getIndex(), ref1.getIndex());
refToRef.put(ref1.getIndex(), ref0.getIndex());
} else {
otherConjuncts.add(conj);
代码示例来源:origin: apache/hive
public RelNode align(Project rel, List<RelFieldCollation> collations) {
// 1) We extract the collations indices
boolean containsWindowing = false;
for (RexNode childExp : rel.getChildExps()) {
if (childExp instanceof RexOver) {
// TODO: support propagation for partitioning/ordering in windowing
containsWindowing = true;
break;
}
}
ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
if (!containsWindowing) {
for (RelFieldCollation c : collations) {
RexNode rexNode = rel.getChildExps().get(c.getFieldIndex());
if (rexNode instanceof RexInputRef) {
int newIdx = ((RexInputRef) rexNode).getIndex();
propagateCollations.add(c.copy((newIdx)));
}
}
}
// 2) We propagate
final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
// 3) Return new Project
return rel.copy(rel.getTraitSet(), ImmutableList.of(child));
}
代码示例来源:origin: apache/drill
@Override
public Void visitCall(RexCall call) {
if(AnnotationUtils.getAnnotation(GenericUDFOPNotNull.class, Description.class).name().equals(call.getOperator().getName())) {
if(call.getOperands().get(0) instanceof RexInputRef &&
!types.get(((RexInputRef)call.getOperands().get(0)).getIndex()).getType().isNullable()) {
// No need to add not null filter for a constant.
throw new Util.FoundOne(call);
}
}
return super.visitCall(call);
}
}
代码示例来源:origin: apache/hive
RexNode projExpr = projExprs.get(i);
if (projExpr instanceof RexInputRef) {
mapInToOutPos.put(((RexInputRef) projExpr).getIndex(), i);
内容来源于网络,如有侵权,请联系作者删除!