本文整理汇总了Java中org.apache.calcite.rel.RelFieldCollation.NullDirection方法的典型用法代码示例。如果您正苦于以下问题:Java RelFieldCollation.NullDirection方法的具体用法?Java RelFieldCollation.NullDirection怎么用?Java RelFieldCollation.NullDirection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rel.RelFieldCollation
的用法示例。
在下文中一共展示了RelFieldCollation.NullDirection方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
}
示例3: 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()));
}
}
示例4: BeamSortRel
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
public BeamSortRel(
RelOptCluster cluster,
RelTraitSet traits,
RelNode child,
RelCollation collation,
RexNode offset,
RexNode fetch) {
super(cluster, traits, child, collation, offset, fetch);
List<RexNode> fieldExps = getChildExps();
RelCollationImpl collationImpl = (RelCollationImpl) collation;
List<RelFieldCollation> collations = collationImpl.getFieldCollations();
for (int i = 0; i < fieldExps.size(); i++) {
RexNode fieldExp = fieldExps.get(i);
RexInputRef inputRef = (RexInputRef) fieldExp;
fieldIndices.add(inputRef.getIndex());
orientation.add(collations.get(i).getDirection() == RelFieldCollation.Direction.ASCENDING);
RelFieldCollation.NullDirection rawNullDirection = collations.get(i).nullDirection;
if (rawNullDirection == RelFieldCollation.NullDirection.UNSPECIFIED) {
rawNullDirection = collations.get(i).getDirection().defaultNullDirection();
}
nullsFirst.add(rawNullDirection == RelFieldCollation.NullDirection.FIRST);
}
if (fetch == null) {
throw new UnsupportedOperationException("ORDER BY without a LIMIT is not supported!");
}
RexLiteral fetchLiteral = (RexLiteral) fetch;
count = ((BigDecimal) fetchLiteral.getValue()).intValue();
if (offset != null) {
RexLiteral offsetLiteral = (RexLiteral) offset;
startIndex = ((BigDecimal) offsetLiteral.getValue()).intValue();
}
}
示例5: 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);
}
示例6: getNullDirection
import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
public RelFieldCollation.NullDirection getNullDirection() {
return right.contains(SqlKind.NULLS_LAST)
? RelFieldCollation.NullDirection.LAST
: right.contains(SqlKind.NULLS_FIRST)
? RelFieldCollation.NullDirection.FIRST
: getDirection().defaultNullDirection();
}
示例7: 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);
}
示例8: 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);
}
示例9: 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);
}
示例10: 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);
}