本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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\"";
}
}