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


Java RelFieldCollation.getDirection方法代码示例

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


在下文中一共展示了RelFieldCollation.getDirection方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);

}
 
开发者ID:diennea,项目名称:herddb,代码行数:18,代码来源:CalcitePlanner.java

示例2: toSql

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
/**
 * Converts a collation to an ORDER BY item.
 */
final SqlNode toSql(RelFieldCollation collation) {
    SqlNode node = field(collation.getFieldIndex());
    switch (collation.getDirection()) {
    case DESCENDING:
    case STRICTLY_DESCENDING:
        node = SqlStdOperatorTable.DESC.createCall(POS, node);
    // fall through
    default:
    }
    switch (collation.nullDirection) {
    case FIRST:
        node = SqlStdOperatorTable.NULLS_FIRST.createCall(POS, node);
        break;
    case LAST:
        node = SqlStdOperatorTable.NULLS_LAST.createCall(POS, node);
        break;
    default:
    }
    return node;
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:24,代码来源:JdbcImplementor.java

示例3: toSql

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
/**
     * Converts a collation to an ORDER BY item.
     */
    public SqlNode toSql(RelFieldCollation collation) {
      SqlNode node = field(collation.getFieldIndex(), true);
      switch (collation.getDirection()) {
        case DESCENDING:
        case STRICTLY_DESCENDING:
          node = SqlStdOperatorTable.DESC.createCall(POS, node);
      }
// ******* Disable Null Collation ******
//      switch (collation.nullDirection) {
//        case FIRST:
//          node = SqlStdOperatorTable.NULLS_FIRST.createCall(POS, node);
//          break;
//        case LAST:
//          node = SqlStdOperatorTable.NULLS_LAST.createCall(POS, node);
//          break;
//      }
      return node;
    }
 
开发者ID:qubole,项目名称:quark,代码行数:22,代码来源:RelToSqlConverter.java

示例4: implement

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
public void implement(Implementor implementor) {
  implementor.visitChild(0, getInput());

  List<RelFieldCollation> sortCollations = collation.getFieldCollations();
  List<String> fieldOrder = new ArrayList<String>();
  if (!sortCollations.isEmpty()) {
    // Construct a series of order clauses from the desired collation
    final List<RelDataTypeField> fields = getRowType().getFieldList();
    for (RelFieldCollation fieldCollation : sortCollations) {
      final String name =
          fields.get(fieldCollation.getFieldIndex()).getName();
      final String direction;
      switch (fieldCollation.getDirection()) {
      case DESCENDING:
        direction = "DESC";
        break;
      default:
        direction = "ASC";
      }
      fieldOrder.add(name + " " + direction);
    }

    implementor.addOrder(fieldOrder);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:CassandraSort.java

示例5: toSql

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
/** Converts a collation to an ORDER BY item. */
public SqlNode toSql(RelFieldCollation collation) {
  SqlNode node = field(collation.getFieldIndex());
  switch (collation.getDirection()) {
  case DESCENDING:
  case STRICTLY_DESCENDING:
    node = SqlStdOperatorTable.DESC.createCall(POS, node);
  }
  if (collation.nullDirection != dialect.defaultNullDirection(collation.direction)) {
    switch (collation.nullDirection) {
    case FIRST:
      node = SqlStdOperatorTable.NULLS_FIRST.createCall(POS, node);
      break;
    case LAST:
      node = SqlStdOperatorTable.NULLS_LAST.createCall(POS, node);
      break;
    }
  }
  return node;
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:SqlImplementor.java

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

示例7: direction

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
private int direction(RelFieldCollation fieldCollation) {
  switch (fieldCollation.getDirection()) {
  case DESCENDING:
  case STRICTLY_DESCENDING:
    return -1;
  case ASCENDING:
  case STRICTLY_ASCENDING:
  default:
    return 1;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:MongoSort.java

示例8: direction

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
private String direction(RelFieldCollation fieldCollation) {
  switch (fieldCollation.getDirection()) {
  case DESCENDING:
  case STRICTLY_DESCENDING:
    return "\"desc\"";
  case ASCENDING:
  case STRICTLY_ASCENDING:
  default:
    return "\"asc\"";
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:ElasticsearchSort.java


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