本文整理汇总了Java中org.apache.calcite.rel.RelFieldCollation.Direction方法的典型用法代码示例。如果您正苦于以下问题:Java RelFieldCollation.Direction方法的具体用法?Java RelFieldCollation.Direction怎么用?Java RelFieldCollation.Direction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rel.RelFieldCollation
的用法示例。
在下文中一共展示了RelFieldCollation.Direction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: defaultNullDirection
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
/** Returns whether NULL values are sorted first or last, in this dialect,
* in an ORDER BY item of a given direction. */
public RelFieldCollation.NullDirection defaultNullDirection(
RelFieldCollation.Direction direction) {
switch (direction) {
case ASCENDING:
case STRICTLY_ASCENDING:
return getNullCollation().last(false)
? RelFieldCollation.NullDirection.LAST
: RelFieldCollation.NullDirection.FIRST;
case DESCENDING:
case STRICTLY_DESCENDING:
return getNullCollation().last(true)
? RelFieldCollation.NullDirection.LAST
: RelFieldCollation.NullDirection.FIRST;
default:
return RelFieldCollation.NullDirection.UNSPECIFIED;
}
}
示例4: collation
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
private static RelFieldCollation collation(RexNode node,
RelFieldCollation.Direction direction,
RelFieldCollation.NullDirection nullDirection, List<RexNode> extraNodes) {
switch (node.getKind()) {
case INPUT_REF:
return new RelFieldCollation(((RexInputRef) node).getIndex(), direction,
Util.first(nullDirection, direction.defaultNullDirection()));
case DESCENDING:
return collation(((RexCall) node).getOperands().get(0),
RelFieldCollation.Direction.DESCENDING,
nullDirection, extraNodes);
case NULLS_FIRST:
return collation(((RexCall) node).getOperands().get(0), direction,
RelFieldCollation.NullDirection.FIRST, extraNodes);
case NULLS_LAST:
return collation(((RexCall) node).getOperands().get(0), direction,
RelFieldCollation.NullDirection.LAST, extraNodes);
default:
final int fieldIndex = extraNodes.size();
extraNodes.add(node);
return new RelFieldCollation(fieldIndex, direction,
Util.first(nullDirection, direction.defaultNullDirection()));
}
}
示例5: deduceMonotonicity
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
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;
}
示例6: deduceMonotonicity
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
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;
}
示例7: desc
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
private static boolean desc(RelFieldCollation.Direction direction) {
switch (direction) {
case DESCENDING:
case STRICTLY_DESCENDING:
return true;
default:
return false;
}
}
示例8: getOrderEnum
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
SQLDigest.OrderEnum getOrderEnum(RelFieldCollation.Direction direction) {
if (direction == RelFieldCollation.Direction.DESCENDING) {
return SQLDigest.OrderEnum.DESCENDING;
} else {
return SQLDigest.OrderEnum.ASCENDING;
}
}
示例9: desc
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
private static boolean desc(RelFieldCollation.Direction direction) {
switch (direction) {
case DESCENDING:
case STRICTLY_DESCENDING:
return true;
default:
return false;
}
}
示例10: getClusteringOrder
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
/** Get the collation of all clustering key columns.
*
* @return A RelCollations representing the collation of all clustering keys
*/
public List<RelFieldCollation> getClusteringOrder(String columnFamily, boolean view) {
AbstractTableMetadata table;
if (view) {
table = getKeyspace().getMaterializedView(columnFamily);
} else {
table = getKeyspace().getTable(columnFamily);
}
List<ClusteringOrder> clusteringOrder = table.getClusteringOrder();
List<RelFieldCollation> keyCollations = new ArrayList<RelFieldCollation>();
int i = 0;
for (ClusteringOrder order : clusteringOrder) {
RelFieldCollation.Direction direction;
switch (order) {
case DESC:
direction = RelFieldCollation.Direction.DESCENDING;
break;
case ASC:
default:
direction = RelFieldCollation.Direction.ASCENDING;
break;
}
keyCollations.add(new RelFieldCollation(i, direction));
i++;
}
return keyCollations;
}
示例11: 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;
}
示例12: reverseDirection
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
/** Find the reverse of a given collation direction.
*
* @return Reverse of the input direction
*/
private RelFieldCollation.Direction reverseDirection(RelFieldCollation.Direction direction) {
switch (direction) {
case ASCENDING:
case STRICTLY_ASCENDING:
return RelFieldCollation.Direction.DESCENDING;
case DESCENDING:
case STRICTLY_DESCENDING:
return RelFieldCollation.Direction.ASCENDING;
default:
return null;
}
}
示例13: toFieldCollation
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
public RelFieldCollation toFieldCollation(Map<String, Object> map) {
final Integer field = (Integer) map.get("field");
final RelFieldCollation.Direction direction =
Util.enumVal(RelFieldCollation.Direction.class,
(String) map.get("direction"));
final RelFieldCollation.NullDirection nullDirection =
Util.enumVal(RelFieldCollation.NullDirection.class,
(String) map.get("nulls"));
return new RelFieldCollation(field, direction, nullDirection);
}
示例14: ordering
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
protected Order.Ordering ordering(String expression, RelFieldCollation.Direction direction, RelFieldCollation.NullDirection nullDirection) {
return new Order.Ordering(direction, parseExpr(expression), nullDirection);
}
示例15: convertOrderItem
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
protected RelFieldCollation convertOrderItem(
SqlSelect select,
SqlNode orderItem, List<SqlNode> extraExprs,
RelFieldCollation.Direction direction,
RelFieldCollation.NullDirection nullDirection) {
assert select != null;
// Handle DESC keyword, e.g. 'select a, b from t order by a desc'.
switch (orderItem.getKind()) {
case DESCENDING:
return convertOrderItem(
select,
((SqlCall) orderItem).operand(0),
extraExprs,
RelFieldCollation.Direction.DESCENDING,
nullDirection);
case NULLS_FIRST:
return convertOrderItem(
select,
((SqlCall) orderItem).operand(0),
extraExprs,
direction,
RelFieldCollation.NullDirection.FIRST);
case NULLS_LAST:
return convertOrderItem(
select,
((SqlCall) orderItem).operand(0),
extraExprs,
direction,
RelFieldCollation.NullDirection.LAST);
}
SqlNode converted = validator.expandOrderExpr(select, orderItem);
switch (nullDirection) {
case UNSPECIFIED:
nullDirection = validator.getDefaultNullCollation().last(desc(direction))
? RelFieldCollation.NullDirection.LAST
: RelFieldCollation.NullDirection.FIRST;
}
// Scan the select list and order exprs for an identical expression.
final SelectScope selectScope = validator.getRawSelectScope(select);
int ordinal = -1;
for (SqlNode selectItem : selectScope.getExpandedSelectList()) {
++ordinal;
if (converted.equalsDeep(stripAs(selectItem), Litmus.IGNORE)) {
return new RelFieldCollation(ordinal, direction, nullDirection);
}
}
for (SqlNode extraExpr : extraExprs) {
++ordinal;
if (converted.equalsDeep(extraExpr, Litmus.IGNORE)) {
return new RelFieldCollation(ordinal, direction, nullDirection);
}
}
// TODO: handle collation sequence
// TODO: flag expressions as non-standard
extraExprs.add(converted);
return new RelFieldCollation(ordinal + 1, direction, nullDirection);
}