本文整理汇总了Java中org.apache.calcite.rel.RelFieldCollation.getFieldIndex方法的典型用法代码示例。如果您正苦于以下问题:Java RelFieldCollation.getFieldIndex方法的具体用法?Java RelFieldCollation.getFieldIndex怎么用?Java RelFieldCollation.getFieldIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rel.RelFieldCollation
的用法示例。
在下文中一共展示了RelFieldCollation.getFieldIndex方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: planSort
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
private PlannerOp planSort(EnumerableSort op, RelDataType rowType) {
PlannerOp input = convertRelNode(op.getInput(), rowType, false);
RelCollation collation = op.getCollation();
List<RelFieldCollation> fieldCollations = collation.getFieldCollations();
boolean[] directions = new boolean[fieldCollations.size()];
int[] fields = new int[fieldCollations.size()];
int i = 0;
for (RelFieldCollation col : fieldCollations) {
RelFieldCollation.Direction direction = col.getDirection();
int index = col.getFieldIndex();
directions[i] = direction == RelFieldCollation.Direction.ASCENDING
|| direction == RelFieldCollation.Direction.STRICTLY_ASCENDING;
fields[i++] = index;
}
return new SortOp(input, directions, fields);
}
示例2: implementRewrite
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
@Override
public void implementRewrite(RewriteImplementor implementor) {
implementor.visitChild(this, getInput());
// No need to rewrite "order by" applied on non-olap context.
// Occurs in sub-query like "select ... from (...) inner join (...) order by ..."
if (this.context.realization == null)
return;
for (RelFieldCollation fieldCollation : this.collation.getFieldCollations()) {
int index = fieldCollation.getFieldIndex();
SQLDigest.OrderEnum order = getOrderEnum(fieldCollation.getDirection());
OLAPRel olapChild = (OLAPRel) this.getInput();
TblColRef orderCol = olapChild.getColumnRowType().getAllColumns().get(index);
this.context.addSort(orderCol, order);
this.context.storageContext.markSort();
}
this.rowType = this.deriveRowType();
this.columnRowType = buildColumnRowType();
}
示例3: rewriteRel
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
public void rewriteRel(Sort rel) {
RelCollation oldCollation = rel.getCollation();
final RelNode oldChild = rel.getInput();
final RelNode newChild = getNewForOldRel(oldChild);
final Mappings.TargetMapping mapping =
getNewForOldInputMapping(oldChild);
// validate
for (RelFieldCollation field : oldCollation.getFieldCollations()) {
int oldInput = field.getFieldIndex();
RelDataType sortFieldType =
oldChild.getRowType().getFieldList().get(oldInput).getType();
if (sortFieldType.isStruct()) {
// TODO jvs 10-Feb-2005
throw Util.needToImplement("sorting on structured types");
}
}
RelCollation newCollation = RexUtil.apply(mapping, oldCollation);
Sort newRel =
LogicalSort.create(newChild, newCollation, rel.offset, rel.fetch);
setNewForOldRel(rel, newRel);
}
示例4: getOperandMonotonicity
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
@Override public SqlMonotonicity getOperandMonotonicity(int ordinal) {
RexNode operand = operands.get(ordinal);
if (operand instanceof RexInputRef) {
for (RelCollation ic : inputCollations) {
if (ic.getFieldCollations().isEmpty()) {
continue;
}
for (RelFieldCollation rfc : ic.getFieldCollations()) {
if (rfc.getFieldIndex() == ((RexInputRef) operand).getIndex()) {
return rfc.direction.monotonicity();
// TODO: Is it possible to have more than one RelFieldCollation for a RexInputRef?
}
}
}
} else if (operand instanceof RexCall) {
final RexCallBinding binding =
RexCallBinding.create(typeFactory, (RexCall) operand, inputCollations);
return ((RexCall) operand).getOperator().getMonotonicity(binding);
}
return SqlMonotonicity.NOT_MONOTONIC;
}
示例5: getDistributionField
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
private List<DistributionField> getDistributionField(DrillSortRel rel) {
List<DistributionField> distFields = Lists.newArrayList();
for (RelFieldCollation relField : rel.getCollation().getFieldCollations()) {
DistributionField field = new DistributionField(relField.getFieldIndex());
distFields.add(field);
}
return distFields;
}
示例6: getDistributionFieldsFromCollation
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
private List<DistributionField> getDistributionFieldsFromCollation(Window.Group window) {
List<DistributionField> distFields = Lists.newArrayList();
for (RelFieldCollation relField : window.collation().getFieldCollations()) {
DistributionField field = new DistributionField(relField.getFieldIndex());
distFields.add(field);
}
return distFields;
}
示例7: getDistributionField
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
private List<DistributionField> getDistributionField(SortRel rel) {
List<DistributionField> distFields = Lists.newArrayList();
for (RelFieldCollation relField : rel.getCollation().getFieldCollations()) {
DistributionField field = new DistributionField(relField.getFieldIndex());
distFields.add(field);
}
return distFields;
}
示例8: collationsCompatible
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
/** Check if it is possible to exploit native CQL sorting for a given collation.
*
* @return True if it is possible to achieve this sort in Cassandra
*/
private boolean collationsCompatible(RelCollation sortCollation,
RelCollation implicitCollation) {
List<RelFieldCollation> sortFieldCollations = sortCollation.getFieldCollations();
List<RelFieldCollation> implicitFieldCollations = implicitCollation.getFieldCollations();
if (sortFieldCollations.size() > implicitFieldCollations.size()) {
return false;
}
if (sortFieldCollations.size() == 0) {
return true;
}
// Check if we need to reverse the order of the implicit collation
boolean reversed = reverseDirection(sortFieldCollations.get(0).getDirection())
== implicitFieldCollations.get(0).getDirection();
for (int i = 0; i < sortFieldCollations.size(); i++) {
RelFieldCollation sorted = sortFieldCollations.get(i);
RelFieldCollation implied = implicitFieldCollations.get(i);
// Check that the fields being sorted match
if (sorted.getFieldIndex() != implied.getFieldIndex()) {
return false;
}
// Either all fields must be sorted in the same direction
// or the opposite direction based on whether we decided
// if the sort direction should be reversed above
RelFieldCollation.Direction sortDirection = sorted.getDirection();
RelFieldCollation.Direction implicitDirection = implied.getDirection();
if ((!reversed && sortDirection != implicitDirection)
|| (reversed && reverseDirection(sortDirection) != implicitDirection)) {
return false;
}
}
return true;
}
示例9: getMonotonicity
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
public SqlMonotonicity getMonotonicity(String columnName) {
final int i = rowType.getFieldNames().indexOf(columnName);
if (i >= 0) {
for (RelCollation collation : table.getStatistic().getCollations()) {
final RelFieldCollation fieldCollation =
collation.getFieldCollations().get(0);
if (fieldCollation.getFieldIndex() == i) {
return fieldCollation.direction.monotonicity();
}
}
}
return SqlMonotonicity.NOT_MONOTONIC;
}