本文整理汇总了Java中org.apache.calcite.rex.RexInputRef.getIndex方法的典型用法代码示例。如果您正苦于以下问题:Java RexInputRef.getIndex方法的具体用法?Java RexInputRef.getIndex怎么用?Java RexInputRef.getIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rex.RexInputRef
的用法示例。
在下文中一共展示了RexInputRef.getIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRootField
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的package包/类
RelDataTypeField getRootField(RexInputRef inputRef) {
int fieldOffset = inputRef.getIndex();
for (RelNode input : inputs) {
RelDataType rowType = input.getRowType();
if (rowType == null) {
// TODO: remove this once leastRestrictive
// is correctly implemented
return null;
}
if (fieldOffset < rowType.getFieldCount()) {
return rowType.getFieldList().get(fieldOffset);
}
fieldOffset -= rowType.getFieldCount();
}
throw new AssertionError();
}
示例2: visitInputRef
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的package包/类
@Override
public RexNode visitInputRef(RexInputRef inputRef) {
if (currentRel instanceof LogicalCorrelate) {
// if this rel references corVar
// and now it needs to be rewritten
// it must have been pulled above the Correlator
// replace the input ref to account for the LHS of the
// Correlator
final int leftInputFieldCount = ((LogicalCorrelate) currentRel).getLeft().getRowType().getFieldCount();
RelDataType newType = inputRef.getType();
if (projectPulledAboveLeftCorrelator) {
newType = typeFactory.createTypeWithNullability(newType, true);
}
int pos = inputRef.getIndex();
RexInputRef newInputRef = new RexInputRef(leftInputFieldCount + pos, newType);
if ((isCount != null) && isCount.contains(pos)) {
return createCaseExpression(newInputRef, rexBuilder.makeExactLiteral(BigDecimal.ZERO), newInputRef);
} else {
return newInputRef;
}
}
return inputRef;
}
示例3: translateRexInputRef
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的package包/类
TblColRef translateRexInputRef(RexInputRef inputRef, ColumnRowType inputColumnRowType, String fieldName,
Set<TblColRef> sourceCollector) {
int index = inputRef.getIndex();
// check it for rewrite count
if (index < inputColumnRowType.size()) {
TblColRef column = inputColumnRowType.getColumnByIndex(index);
if (!column.isInnerColumn() && context.belongToContextTables(column) && !this.rewriting
&& !this.afterAggregate) {
if (!isMerelyPermutation) {
context.allColumns.add(column);
}
sourceCollector.add(column);
}
return column;
} else {
throw new IllegalStateException("Can't find " + inputRef + " from child columnrowtype " + inputColumnRowType
+ " with fieldname " + fieldName);
}
}
示例4: translateJoinColumn
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的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: getRootField
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的package包/类
RelDataTypeField getRootField(RexInputRef inputRef) {
int fieldOffset = inputRef.getIndex();
for (RelNode input : inputs) {
RelDataType rowType = input.getRowType();
if (rowType == null) {
// TODO: remove this once leastRestrictive
// is correctly implemented
return null;
}
if (fieldOffset < rowType.getFieldCount()) {
return rowType.getFieldList().get(fieldOffset);
}
fieldOffset -= rowType.getFieldCount();
}
throw new AssertionError();
}
示例6: inputField
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的package包/类
/** Converts an expression into an (input, field) pair. */
private static int[] inputField(List<RelNode> leaves, RexNode rex) {
if (!(rex instanceof RexInputRef)) {
throw new RuntimeException("only equi-join of columns allowed: " + rex);
}
RexInputRef ref = (RexInputRef) rex;
int start = 0;
for (int i = 0; i < leaves.size(); i++) {
final RelNode leaf = leaves.get(i);
final int end = start + leaf.getRowType().getFieldCount();
if (ref.getIndex() < end) {
return new int[] {i, ref.getIndex() - start};
}
start = end;
}
throw new AssertionError("input not found");
}
示例7: simplyProjects
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的package包/类
private boolean simplyProjects(RelNode rel, ImmutableBitSet columns) {
if (!(rel instanceof Project)) {
return false;
}
Project project = (Project) rel;
final List<RexNode> projects = project.getProjects();
for (int column : columns) {
if (column >= projects.size()) {
return false;
}
if (!(projects.get(column) instanceof RexInputRef)) {
return false;
}
final RexInputRef ref = (RexInputRef) projects.get(column);
if (ref.getIndex() != column) {
return false;
}
}
return true;
}
示例8: getRootField
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的package包/类
RelDataTypeField getRootField(RexInputRef inputRef) {
if (inputs == null) {
return null;
}
int fieldOffset = inputRef.getIndex();
for (RelNode input : inputs) {
RelDataType rowType = input.getRowType();
if (rowType == null) {
// TODO: remove this once leastRestrictive
// is correctly implemented
return null;
}
if (fieldOffset < rowType.getFieldCount()) {
return rowType.getFieldList().get(fieldOffset);
}
fieldOffset -= rowType.getFieldCount();
}
throw new AssertionError();
}
示例9: visitInputRef
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的package包/类
public RexNode visitInputRef(RexInputRef var) {
int srcIndex = var.getIndex();
int destIndex = srcIndex + adjustments[srcIndex];
RelDataType type;
if (destFields != null) {
type = destFields.get(destIndex).getType();
} else if (leftDestFields != null) {
if (destIndex < nLeftDestFields) {
type = leftDestFields.get(destIndex).getType();
} else {
type =
rightDestFields.get(destIndex - nLeftDestFields).getType();
}
} else {
type = srcFields.get(srcIndex).getType();
}
if ((adjustments[srcIndex] != 0)
|| (srcFields == null)
|| (type != srcFields.get(srcIndex).getType())) {
return rexBuilder.makeInputRef(type, destIndex);
} else {
return var;
}
}
示例10: findItemOrFlatten
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的package包/类
private RexCall findItemOrFlatten(
final RexNode node,
final List<RexNode> projExprs) {
try {
RexVisitor<Void> visitor =
new RexVisitorImpl<Void>(true) {
public Void visitCall(RexCall call) {
if ("item".equals(call.getOperator().getName().toLowerCase()) ||
"flatten".equals(call.getOperator().getName().toLowerCase())) {
throw new Util.FoundOne(call); /* throw exception to interrupt tree walk (this is similar to
other utility methods in RexUtil.java */
}
return super.visitCall(call);
}
public Void visitInputRef(RexInputRef inputRef) {
final int index = inputRef.getIndex();
RexNode n = projExprs.get(index);
if (n instanceof RexCall) {
RexCall r = (RexCall) n;
if ("item".equals(r.getOperator().getName().toLowerCase()) ||
"flatten".equals(r.getOperator().getName().toLowerCase())) {
throw new Util.FoundOne(r);
}
}
return super.visitInputRef(inputRef);
}
};
node.accept(visitor);
return null;
} catch (Util.FoundOne e) {
Util.swallow(e, null);
return (RexCall) e.getNode();
}
}
示例11: visitInputRef
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的package包/类
@Override
public PathSegment visitInputRef(RexInputRef inputRef) {
int index = inputRef.getIndex();
String name = fieldNames.get(index);
RelDataTypeField field = fields.get(index);
DesiredField f = new DesiredField(index, name, field);
desiredFields.add(f);
return new NameSegment(name);
}
示例12: containIdentity
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的package包/类
/**
* Returns whether the leading edge of a given array of expressions is
* wholly {@link RexInputRef} objects with types and names corresponding
* to the underlying row type. */
private static boolean containIdentity(List<? extends RexNode> exps,
RelDataType rowType, RelDataType childRowType) {
List<RelDataTypeField> fields = rowType.getFieldList();
List<RelDataTypeField> childFields = childRowType.getFieldList();
int fieldCount = childFields.size();
if (exps.size() != fieldCount) {
return false;
}
for (int i = 0; i < exps.size(); i++) {
RexNode exp = exps.get(i);
if (!(exp instanceof RexInputRef)) {
return false;
}
RexInputRef var = (RexInputRef) exp;
if (var.getIndex() != i) {
return false;
}
if (!fields.get(i).getName().equals(childFields.get(i).getName())) {
return false;
}
if (!fields.get(i).getType().equals(childFields.get(i).getType())) {
return false;
}
}
return true;
}
示例13: getColumnOrigins
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的package包/类
@SuppressWarnings("unused") // Called through reflection
public Set<RelColumnOrigin> getColumnOrigins(LogicalWindow window, RelMetadataQuery mq, int iOutputColumn) {
final RelNode inputRel = window.getInput();
final int numFieldsInInput = inputRel.getRowType().getFieldCount();
if (iOutputColumn < numFieldsInInput) {
return mq.getColumnOrigins(inputRel, iOutputColumn);
}
if (iOutputColumn >= numFieldsInInput + window.groups.size()) {
return null;
}
final Group group = window.groups.get(iOutputColumn - numFieldsInInput);
final Set<RelColumnOrigin> set = new HashSet<>();
// Add aggregation column references
for(RexWinAggCall aggCall : group.aggCalls) {
for(RexNode operand : aggCall.operands) {
if (operand instanceof RexInputRef) {
final RexInputRef opInputRef = (RexInputRef) operand;
if (opInputRef.getIndex() < numFieldsInInput) {
Set<RelColumnOrigin> inputSet =
mq.getColumnOrigins(inputRel, opInputRef.getIndex());
inputSet = createDerivedColumnOrigins(inputSet);
if (inputSet != null) {
set.addAll(inputSet);
}
}
}
}
}
return set;
}
示例14: visitInputRef
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的package包/类
@Override
public RexNode visitInputRef(RexInputRef inputRef) {
if(inputRef instanceof MutableRexInputRef){
return new RexInputRef(inputRef.getIndex(), inputRef.getType());
}
return super.visitInputRef(inputRef);
}
示例15: findItemOrFlatten
import org.apache.calcite.rex.RexInputRef; //导入方法依赖的package包/类
private RexCall findItemOrFlatten(
final RexNode node,
final List<RexNode> projExprs) {
try {
RexVisitor<Void> visitor =
new RexVisitorImpl<Void>(true) {
@Override
public Void visitCall(RexCall call) {
if ("item".equals(call.getOperator().getName().toLowerCase()) ||
"flatten".equals(call.getOperator().getName().toLowerCase())) {
throw new Util.FoundOne(call); /* throw exception to interrupt tree walk (this is similar to
other utility methods in RexUtil.java */
}
return super.visitCall(call);
}
@Override
public Void visitInputRef(RexInputRef inputRef) {
final int index = inputRef.getIndex();
RexNode n = projExprs.get(index);
if (n instanceof RexCall) {
RexCall r = (RexCall) n;
if ("item".equals(r.getOperator().getName().toLowerCase()) ||
"flatten".equals(r.getOperator().getName().toLowerCase())) {
throw new Util.FoundOne(r);
}
}
return super.visitInputRef(inputRef);
}
};
node.accept(visitor);
return null;
} catch (Util.FoundOne e) {
Util.swallow(e, null);
return (RexCall) e.getNode();
}
}