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


Java SqlMonotonicity.NOT_MONOTONIC属性代码示例

本文整理汇总了Java中org.apache.calcite.sql.validate.SqlMonotonicity.NOT_MONOTONIC属性的典型用法代码示例。如果您正苦于以下问题:Java SqlMonotonicity.NOT_MONOTONIC属性的具体用法?Java SqlMonotonicity.NOT_MONOTONIC怎么用?Java SqlMonotonicity.NOT_MONOTONIC使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.calcite.sql.validate.SqlMonotonicity的用法示例。


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

示例1: getMonotonicity

public SqlMonotonicity getMonotonicity(SqlValidatorScope scope) {
  // for "star" column, whether it's static or dynamic return not_monotonic directly.
  if (Util.last(names).equals("") || DynamicRecordType.isDynamicStarColName(Util.last(names))) {
    return SqlMonotonicity.NOT_MONOTONIC;
  }

  // First check for builtin functions which don't have parentheses,
  // like "LOCALTIME".
  final SqlValidator validator = scope.getValidator();
  SqlCall call =
      SqlUtil.makeCall(
          validator.getOperatorTable(),
          this);
  if (call != null) {
    return call.getMonotonicity(scope);
  }
  final SqlQualified qualified = scope.fullyQualify(this);
  final SqlIdentifier fqId = qualified.identifier;
  return qualified.namespace.resolve().getMonotonicity(Util.last(fqId.names));
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:SqlIdentifier.java

示例2: getOperandMonotonicity

@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;
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:RexCallBinding.java

示例3: deduceMonotonicity

private List<RelCollation> deduceMonotonicity(SqlValidatorTable table) {
  final RelDataType rowType = table.getRowType();
  final List<RelCollation> collationList = new ArrayList<>();

  // Deduce which fields the table is sorted on.
  int i = -1;
  for (RelDataTypeField field : rowType.getFieldList()) {
    ++i;
    final SqlMonotonicity monotonicity =
        table.getMonotonicity(field.getName());
    if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) {
      final RelFieldCollation.Direction direction =
          monotonicity.isDecreasing()
              ? RelFieldCollation.Direction.DESCENDING
              : RelFieldCollation.Direction.ASCENDING;
      collationList.add(
          RelCollations.of(new RelFieldCollation(i, direction)));
    }
  }
  return collationList;
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:SqlToRelTestBase.java

示例4: deduceMonotonicity

private static List<RelCollation> deduceMonotonicity(
    Prepare.PreparingTable table) {
  final List<RelCollation> collationList = Lists.newArrayList();

  // Deduce which fields the table is sorted on.
  int i = -1;
  for (RelDataTypeField field : table.getRowType().getFieldList()) {
    ++i;
    final SqlMonotonicity monotonicity =
        table.getMonotonicity(field.getName());
    if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) {
      final RelFieldCollation.Direction direction =
          monotonicity.isDecreasing()
              ? RelFieldCollation.Direction.DESCENDING
              : RelFieldCollation.Direction.ASCENDING;
      collationList.add(
          RelCollations.of(
              new RelFieldCollation(i, direction)));
    }
  }
  return collationList;
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:MockCatalogReader.java

示例5: getMonotonicity

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;
}
 
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:RelOptTableImpl.java

示例6: getMonotonicity

@Override public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) {
  // SUBSTRING(x FROM 0 FOR constant) has same monotonicity as x
  if (call.getOperandCount() == 3) {
    final SqlMonotonicity mono0 = call.getOperandMonotonicity(0);
    if ((mono0 != SqlMonotonicity.NOT_MONOTONIC)
        && call.getOperandMonotonicity(1) == SqlMonotonicity.CONSTANT
        && call.getOperandLiteralValue(1, BigDecimal.class)
            .equals(BigDecimal.ZERO)
        && call.getOperandMonotonicity(2) == SqlMonotonicity.CONSTANT) {
      return mono0.unstrict();
    }
  }
  return super.getMonotonicity(call);
}
 
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:SqlSubstringFunction.java

示例7: getMonotonicity

@Override public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) {
  switch (call.getOperandLiteralValue(0, TimeUnitRange.class)) {
  case YEAR:
    return call.getOperandMonotonicity(1).unstrict();
  default:
    return SqlMonotonicity.NOT_MONOTONIC;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:SqlExtractFunction.java

示例8: getMonotonicity

@Override public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) {
  RelDataTypeFamily castFrom = call.getOperandType(0).getFamily();
  RelDataTypeFamily castTo = call.getOperandType(1).getFamily();
  if (castFrom instanceof SqlTypeFamily
      && castTo instanceof SqlTypeFamily
      && nonMonotonicCasts.containsEntry(castFrom, castTo)) {
    return SqlMonotonicity.NOT_MONOTONIC;
  } else {
    return call.getOperandMonotonicity(0);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:SqlCastFunction.java

示例9: onMatch

public void onMatch(RelOptRuleCall call) {
  final Sort sort = call.rel(0);
  final Project project = call.rel(1);
  final RelOptCluster cluster = project.getCluster();

  if (sort.getConvention() != project.getConvention()) {
    return;
  }

  // Determine mapping between project input and output fields. If sort
  // relies on non-trivial expressions, we can't push.
  final Mappings.TargetMapping map =
      RelOptUtil.permutationIgnoreCast(
          project.getProjects(), project.getInput().getRowType());
  for (RelFieldCollation fc : sort.getCollation().getFieldCollations()) {
    if (map.getTargetOpt(fc.getFieldIndex()) < 0) {
      return;
    }
    final RexNode node = project.getProjects().get(fc.getFieldIndex());
    if (node.isA(SqlKind.CAST)) {
      // Check whether it is a monotonic preserving cast, otherwise we cannot push
      final RexCall cast = (RexCall) node;
      final RexCallBinding binding =
          RexCallBinding.create(cluster.getTypeFactory(), cast,
              ImmutableList.of(RelCollations.of(RexUtil.apply(map, fc))));
      if (cast.getOperator().getMonotonicity(binding) == SqlMonotonicity.NOT_MONOTONIC) {
        return;
      }
    }
  }
  final RelCollation newCollation =
      cluster.traitSet().canonize(
          RexUtil.apply(map, sort.getCollation()));
  final Sort newSort =
      sort.copy(
          sort.getTraitSet().replace(newCollation),
          project.getInput(),
          newCollation,
          sort.offset,
          sort.fetch);
  RelNode newProject =
      project.copy(
          sort.getTraitSet(),
          ImmutableList.<RelNode>of(newSort));
  // Not only is newProject equivalent to sort;
  // newSort is equivalent to project's input
  // (but only if the sort is not also applying an offset/limit).
  Map<RelNode, RelNode> equiv;
  if (sort.offset == null
      && sort.fetch == null
      && cluster.getPlanner().getRelTraitDefs()
          .contains(RelCollationTraitDef.INSTANCE)) {
    equiv = ImmutableMap.of((RelNode) newSort, project.getInput());
  } else {
    equiv = ImmutableMap.of();
  }
  call.transformTo(newProject, equiv);
}
 
开发者ID:apache,项目名称:calcite,代码行数:58,代码来源:SortProjectTransposeRule.java

示例10: getMonotonicity

public SqlMonotonicity getMonotonicity(String columnName) {
  return monotonicColumnSet.contains(columnName)
      ? SqlMonotonicity.INCREASING
      : SqlMonotonicity.NOT_MONOTONIC;
}
 
开发者ID:apache,项目名称:calcite,代码行数:5,代码来源:MockCatalogReader.java

示例11: getOperandMonotonicity

/**
 * Gets the monotonicity of a bound operand.
 *
 * @param ordinal zero-based ordinal of operand of interest
 * @return monotonicity of operand
 */
public SqlMonotonicity getOperandMonotonicity(int ordinal) {
  return SqlMonotonicity.NOT_MONOTONIC;
}
 
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:SqlOperatorBinding.java

示例12: getMonotonicity

/**
 * Returns whether expression is always ascending, descending or constant.
 * This property is useful because it allows to safely aggregate infinite
 * streams of values.
 *
 * <p>The default implementation returns
 * {@link SqlMonotonicity#NOT_MONOTONIC}.
 *
 * @param scope Scope
 */
public SqlMonotonicity getMonotonicity(SqlValidatorScope scope) {
  return SqlMonotonicity.NOT_MONOTONIC;
}
 
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:SqlNode.java

示例13: getMonotonicity

/**
 * Returns whether a call to this operator is monotonic.
 *
 * <p>Default implementation returns {@link SqlMonotonicity#NOT_MONOTONIC}.
 *
 * @param call Call to this operator with particular arguments and information
 *             about the monotonicity of the arguments
 */
public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) {
  return SqlMonotonicity.NOT_MONOTONIC;
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:SqlOperator.java


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