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


Java RelFieldCollation类代码示例

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


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

示例1: convert

import org.apache.calcite.rel.RelFieldCollation; //导入依赖的package包/类
public static RelNode convert(Order order, ConversionContext context) throws InvalidRelException{

    // if there are compound expressions in the order by, we need to convert into projects on either side.
    RelNode input = context.toRel(order.getInput());
    List<String> fields = input.getRowType().getFieldNames();

    // build a map of field names to indices.
    Map<String, Integer> fieldMap = Maps.newHashMap();
    int i =0;
    for(String field : fields){
      fieldMap.put(field, i);
      i++;
    }

    List<RelFieldCollation> collations = Lists.newArrayList();

    for(Ordering o : order.getOrderings()){
      String fieldName = ExprHelper.getFieldName(o.getExpr());
      int fieldId = fieldMap.get(fieldName);
      RelFieldCollation c = new RelFieldCollation(fieldId, o.getDirection(), o.getNullDirection());
    }
    return new DrillSortRel(context.getCluster(), context.getLogicalTraits(), input, RelCollationImpl.of(collations));
  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:24,代码来源:DrillSortRel.java

示例2: getNullOrderingFromString

import org.apache.calcite.rel.RelFieldCollation; //导入依赖的package包/类
private static NullDirection getNullOrderingFromString( String strNullOrdering ) {
   final RelFieldCollation.NullDirection nullOrdering;
   if ( null == strNullOrdering ) {
     nullOrdering = NullDirection.UNSPECIFIED;
   }
   else {
     try {
       nullOrdering = NullDirection.valueOf( strNullOrdering );
     }
     catch ( IllegalArgumentException e ) {
       throw new DrillRuntimeException(
           "Internal error:  Unknown <null ordering> string (not "
           + "\"" + NullDirection.FIRST.name() + "\", "
           + "\"" + NullDirection.LAST.name() + "\", or "
           + "\"" + NullDirection.UNSPECIFIED.name() + "\" or null): "
           + "\"" + strNullOrdering + "\"" );
     }
   }
   return nullOrdering;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:21,代码来源:Order.java

示例3: convert

import org.apache.calcite.rel.RelFieldCollation; //导入依赖的package包/类
public static RelNode convert(Order order, ConversionContext context) throws InvalidRelException{

    // if there are compound expressions in the order by, we need to convert into projects on either side.
    RelNode input = context.toRel(order.getInput());
    List<String> fields = input.getRowType().getFieldNames();

    // build a map of field names to indices.
    Map<String, Integer> fieldMap = Maps.newHashMap();
    int i =0;
    for(String field : fields){
      fieldMap.put(field, i);
      i++;
    }

    List<RelFieldCollation> collations = Lists.newArrayList();

    for(Ordering o : order.getOrderings()){
      String fieldName = ExprHelper.getFieldName(o.getExpr());
      int fieldId = fieldMap.get(fieldName);
      RelFieldCollation c = new RelFieldCollation(fieldId, o.getDirection(), o.getNullDirection());
    }
    return new SortRel(context.getCluster(), context.getLogicalTraits(), input, RelCollationImpl.of(collations));
  }
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:24,代码来源:SortRel.java

示例4: 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

示例5: gatherOrderExprs

import org.apache.calcite.rel.RelFieldCollation; //导入依赖的package包/类
/**
 * Creates a list of collations required to implement the ORDER BY clause,
 * if there is one. Populates <code>extraOrderExprs</code> with any sort
 * expressions which are not in the select clause.
 *
 * @param bb              Scope within which to resolve identifiers
 * @param select          Select clause. Never null, because we invent a
 *                        dummy SELECT if ORDER BY is applied to a set
 *                        operation (UNION etc.)
 * @param orderList       Order by clause, may be null
 * @param extraOrderExprs Sort expressions which are not in the select
 *                        clause (output)
 * @param collationList   List of collations (output)
 */
protected void gatherOrderExprs(
	Blackboard bb,
	SqlSelect select,
	SqlNodeList orderList,
	List<SqlNode> extraOrderExprs,
	List<RelFieldCollation> collationList) {
	// TODO:  add validation rules to SqlValidator also
	assert bb.root != null : "precondition: child != null";
	assert select != null;
	if (orderList == null) {
		return;
	}
	for (SqlNode orderItem : orderList) {
		collationList.add(
			convertOrderItem(
				select,
				orderItem,
				extraOrderExprs,
				RelFieldCollation.Direction.ASCENDING,
				RelFieldCollation.NullDirection.UNSPECIFIED));
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:37,代码来源:SqlToRelConverter.java

示例6: testTopN

import org.apache.calcite.rel.RelFieldCollation; //导入依赖的package包/类
@Test
public void testTopN() {
  TopN sortConf = new TopN(null,
      Lists.newArrayList(ordering("b", RelFieldCollation.Direction.ASCENDING, RelFieldCollation.NullDirection.FIRST)), false, 3);
  List<String> inputJsonBatches = Lists.newArrayList(
      "[{\"a\": 5, \"b\" : 1 }]",
      "[{\"a\": 5, \"b\" : 5},{\"a\": 3, \"b\" : 8}]",
      "[{\"a\": 40, \"b\" : 3},{\"a\": 13, \"b\" : 100}]");
  opTestBuilder()
      .physicalOperator(sortConf)
      .inputDataStreamJson(inputJsonBatches)
      .baselineColumns("a", "b")
      .baselineValues(5l, 1l)
      .baselineValues(40l, 3l)
      .baselineValues(5l, 5l)
      .go();
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:18,代码来源:BasicPhysicalOpUnitTest.java

示例7: testSimpleMergingReceiver

import org.apache.calcite.rel.RelFieldCollation; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Ignore
@Test
public void testSimpleMergingReceiver() {
  MergingReceiverPOP mergeConf = new MergingReceiverPOP(-1, Lists.<MinorFragmentEndpoint>newArrayList(),
      Lists.newArrayList(ordering("x", RelFieldCollation.Direction.ASCENDING, RelFieldCollation.NullDirection.FIRST)), false);
  List<String> leftJsonBatches = Lists.newArrayList(
      "[{\"x\": 5, \"a\" : \"a string\"}]",
      "[{\"x\": 5, \"a\" : \"a different string\"},{\"x\": 5, \"a\" : \"meh\"}]");
  List<String> rightJsonBatches = Lists.newArrayList(
      "[{\"x\": 5, \"a\" : \"asdf\"}]",
      "[{\"x\": 5, \"a\" : \"12345\"}, {\"x\": 6, \"a\" : \"qwerty\"}]");
  opTestBuilder()
      .physicalOperator(mergeConf)
      .inputDataStreamsJson(Lists.newArrayList(leftJsonBatches, rightJsonBatches))
      .baselineColumns("x", "a")
      .baselineValues(5l, "a string")
      .baselineValues(5l, "a different string")
      .baselineValues(5l, "meh")
      .baselineValues(5l, "asdf")
      .baselineValues(5l, "12345")
      .baselineValues(6l, "qwerty")
      .go();
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:25,代码来源:BasicPhysicalOpUnitTest.java

示例8: 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

示例9: 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

示例10: 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();
}
 
开发者ID:apache,项目名称:kylin,代码行数:22,代码来源:OLAPSortRel.java

示例11: gatherOrderExprs

import org.apache.calcite.rel.RelFieldCollation; //导入依赖的package包/类
/**
 * Creates a list of collations required to implement the ORDER BY clause,
 * if there is one. Populates <code>extraOrderExprs</code> with any sort
 * expressions which are not in the select clause.
 *
 * @param bb              Scope within which to resolve identifiers
 * @param select          Select clause. Never null, because we invent a
 *                        dummy SELECT if ORDER BY is applied to a set
 *                        operation (UNION etc.)
 * @param orderList       Order by clause, may be null
 * @param extraOrderExprs Sort expressions which are not in the select
 *                        clause (output)
 * @param collationList   List of collations (output)
 */
protected void gatherOrderExprs(
    Blackboard bb,
    SqlSelect select,
    SqlNodeList orderList,
    List<SqlNode> extraOrderExprs,
    List<RelFieldCollation> collationList) {
  // TODO:  add validation rules to SqlValidator also
  assert bb.root != null : "precondition: child != null";
  assert select != null;
  if (orderList == null) {
    return;
  }
  for (SqlNode orderItem : orderList) {
    collationList.add(
        convertOrderItem(
            select,
            orderItem,
            extraOrderExprs,
            RelFieldCollation.Direction.ASCENDING,
            RelFieldCollation.NullDirection.UNSPECIFIED));
  }
}
 
开发者ID:apache,项目名称:kylin,代码行数:37,代码来源:SqlToRelConverter.java

示例12: 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

示例13: CassandraFilter

import org.apache.calcite.rel.RelFieldCollation; //导入依赖的package包/类
public CassandraFilter(
    RelOptCluster cluster,
    RelTraitSet traitSet,
    RelNode child,
    RexNode condition,
    List<String> partitionKeys,
    List<String> clusteringKeys,
    List<RelFieldCollation> implicitFieldCollations) {
  super(cluster, traitSet, child, condition);

  this.partitionKeys = partitionKeys;
  this.singlePartition = false;
  this.clusteringKeys = new ArrayList<String>(clusteringKeys);
  this.implicitFieldCollations = implicitFieldCollations;

  Translator translator =
      new Translator(getRowType(), partitionKeys, clusteringKeys,
          implicitFieldCollations);
  this.match = translator.translateMatch(condition);
  this.singlePartition = translator.isSinglePartition();
  this.implicitCollation = translator.getImplicitCollation();

  assert getConvention() == CassandraRel.CONVENTION;
  assert getConvention() == child.getConvention();
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:CassandraFilter.java

示例14: getImplicitCollation

import org.apache.calcite.rel.RelFieldCollation; //导入依赖的package包/类
/** Infer the implicit correlation from the unrestricted clustering keys.
 *
 * @return The collation of the filtered results
 */
public RelCollation getImplicitCollation() {
  // No collation applies if we aren't restricted to a single partition
  if (!isSinglePartition()) {
    return RelCollations.EMPTY;
  }

  // Pull out the correct fields along with their original collations
  List<RelFieldCollation> fieldCollations = new ArrayList<RelFieldCollation>();
  for (int i = restrictedClusteringKeys; i < clusteringKeys.size(); i++) {
    int fieldIndex = fieldNames.indexOf(clusteringKeys.get(i));
    RelFieldCollation.Direction direction = implicitFieldCollations.get(i).getDirection();
    fieldCollations.add(new RelFieldCollation(fieldIndex, direction));
  }

  return RelCollations.of(fieldCollations);
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:CassandraFilter.java

示例15: 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


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