本文整理了Java中org.apache.calcite.rel.RelFieldCollation.<init>
方法的一些代码示例,展示了RelFieldCollation.<init>
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RelFieldCollation.<init>
方法的具体详情如下:
包路径:org.apache.calcite.rel.RelFieldCollation
类名称:RelFieldCollation
方法名:<init>
[英]Creates an ascending field collation.
[中]创建升序字段排序规则。
代码示例来源:origin: apache/storm
private Statistic buildStatistic() {
if (stats != null || primaryKey == -1) {
return stats;
}
Direction dir = primaryKeyMonotonicity == INCREASING ? ASCENDING : DESCENDING;
RelFieldCollation collation = new RelFieldCollation(primaryKey, dir, NullDirection.UNSPECIFIED);
return Statistics.of(fields.size(), ImmutableList.of(ImmutableBitSet.of(primaryKey)),
ImmutableList.of(RelCollations.of(collation)));
}
代码示例来源:origin: apache/hive
public ImmutableList<RelCollation> collations(HiveAggregate aggregate, RelMetadataQuery mq) {
// Compute collations
ImmutableList.Builder<RelFieldCollation> collationListBuilder =
new ImmutableList.Builder<RelFieldCollation>();
for (int pos : aggregate.getGroupSet().asList()) {
final RelFieldCollation fieldCollation = new RelFieldCollation(pos);
collationListBuilder.add(fieldCollation);
}
// Return aggregate collations
return ImmutableList.of(
RelCollationTraitDef.INSTANCE.canonize(
new HiveRelCollation(collationListBuilder.build())));
}
代码示例来源:origin: apache/drill
private List<RelFieldCollation> getFieldCollations(IndexDesc desc, Collection<IndexFieldDesc> descCollection) {
List<RelFieldCollation> fieldCollations = new ArrayList<>();
int i = 0;
for (IndexFieldDesc field : descCollection) {
RelFieldCollation.Direction direction = (field.getSortOrder() == IndexFieldDesc.Order.Asc) ?
RelFieldCollation.Direction.ASCENDING : (field.getSortOrder() == IndexFieldDesc.Order.Desc ?
RelFieldCollation.Direction.DESCENDING : null);
if (direction != null) {
// assume null direction of NULLS UNSPECIFIED for now until MapR-DB adds that to the APIs
RelFieldCollation.NullDirection nulldir =
direction == RelFieldCollation.Direction.ASCENDING ? NullDirection.LAST :
(direction == RelFieldCollation.Direction.DESCENDING ?
NullDirection.FIRST : NullDirection.UNSPECIFIED);
RelFieldCollation c = new RelFieldCollation(i++, direction, nulldir);
fieldCollations.add(c);
} else {
// if the direction is not present for a field, no need to examine remaining fields
break;
}
}
return fieldCollations;
}
代码示例来源:origin: apache/hive
getEquiJoinPredicateElements().get(i);
for (int leftPos : joinLeafPredInfo.getProjsFromLeftPartOfJoinKeysInJoinSchema()) {
final RelFieldCollation leftFieldCollation = new RelFieldCollation(leftPos);
collationListBuilder.add(leftFieldCollation);
leftCollationListBuilder.add(leftFieldCollation);
final RelFieldCollation rightFieldCollation = new RelFieldCollation(rightPos);
collationListBuilder.add(rightFieldCollation);
rightCollationListBuilder.add(rightFieldCollation);
代码示例来源:origin: apache/hive
@Override
public List<RelCollation> getCollationList() {
ImmutableList.Builder<RelFieldCollation> collationList = new ImmutableList.Builder<RelFieldCollation>();
for (Order sortColumn : this.hiveTblMetadata.getSortCols()) {
for (int i=0; i<this.hiveTblMetadata.getSd().getCols().size(); i++) {
FieldSchema field = this.hiveTblMetadata.getSd().getCols().get(i);
if (field.getName().equals(sortColumn.getCol())) {
Direction direction;
NullDirection nullDirection;
if (sortColumn.getOrder() == BaseSemanticAnalyzer.HIVE_COLUMN_ORDER_ASC) {
direction = Direction.ASCENDING;
nullDirection = NullDirection.FIRST;
} else {
direction = Direction.DESCENDING;
nullDirection = NullDirection.LAST;
}
collationList.add(new RelFieldCollation(i, direction, nullDirection));
break;
}
}
}
return new ImmutableList.Builder<RelCollation>()
.add(RelCollationTraitDef.INSTANCE.canonize(
new HiveRelCollation(collationList.build())))
.build();
}
代码示例来源:origin: apache/hive
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()));
}
}
代码示例来源:origin: apache/hive
propagateCollationsLeft.add(new RelFieldCollation(e.getKey()));
propagateCollationsRight.add(new RelFieldCollation(refToRef.get(e.getKey()) - nLeftColumns));
} else {
propagateCollationsLeft.add(new RelFieldCollation(refToRef.get(e.getKey())));
propagateCollationsRight.add(new RelFieldCollation(e.getKey() - nLeftColumns));
代码示例来源:origin: apache/drill
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()));
}
}
代码示例来源:origin: apache/hive
public RelNode align(Aggregate rel, List<RelFieldCollation> collations) {
// 1) We extract the group by positions that are part of the collations and
// sort them so they respect it
LinkedHashSet<Integer> aggregateColumnsOrder = new LinkedHashSet<>();
ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
if (rel.getGroupType() == Group.SIMPLE && !collations.isEmpty()) {
for (RelFieldCollation c : collations) {
if (c.getFieldIndex() < rel.getGroupCount()) {
// Group column found
if (aggregateColumnsOrder.add(c.getFieldIndex())) {
propagateCollations.add(c.copy(rel.getGroupSet().nth(c.getFieldIndex())));
}
}
}
}
for (int i = 0; i < rel.getGroupCount(); i++) {
if (!aggregateColumnsOrder.contains(i)) {
// Not included in the input collations, but can be propagated as this Aggregate
// will enforce it
propagateCollations.add(new RelFieldCollation(rel.getGroupSet().nth(i)));
}
}
// 2) We propagate
final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
// 3) We annotate the Aggregate operator with this info
final HiveAggregate newAggregate = (HiveAggregate) rel.copy(rel.getTraitSet(),
ImmutableList.of(child));
newAggregate.setAggregateColumnsOrder(aggregateColumnsOrder);
return newAggregate;
}
代码示例来源:origin: apache/drill
propagateCollationsLeft.add(new RelFieldCollation(e.getKey()));
propagateCollationsRight.add(new RelFieldCollation(refToRef.get(e.getKey()) - nLeftColumns));
} else {
propagateCollationsLeft.add(new RelFieldCollation(refToRef.get(e.getKey())));
propagateCollationsRight.add(new RelFieldCollation(e.getKey() - nLeftColumns));
代码示例来源:origin: apache/hive
fieldCollations.add(new RelFieldCollation(m.get(fc.getFieldIndex()), fc.direction,
fc.nullDirection));
代码示例来源:origin: apache/drill
public ImmutableList<RelCollation> collations(HiveAggregate aggregate, RelMetadataQuery mq) {
// Compute collations
ImmutableList.Builder<RelFieldCollation> collationListBuilder =
new ImmutableList.Builder<RelFieldCollation>();
for (int pos : aggregate.getGroupSet().asList()) {
final RelFieldCollation fieldCollation = new RelFieldCollation(pos);
collationListBuilder.add(fieldCollation);
}
// Return aggregate collations
return ImmutableList.of(
RelCollationTraitDef.INSTANCE.canonize(
new HiveRelCollation(collationListBuilder.build())));
}
代码示例来源:origin: apache/hive
if (!joinKeyPositions.contains(pos)) {
joinKeyPositions.add(pos);
collationListBuilder.add(new RelFieldCollation(pos));
代码示例来源:origin: apache/drill
@Override
public List<RelCollation> getCollationList() {
ImmutableList.Builder<RelFieldCollation> collationList = new ImmutableList.Builder<RelFieldCollation>();
for (Order sortColumn : this.hiveTblMetadata.getSortCols()) {
for (int i=0; i<this.hiveTblMetadata.getSd().getCols().size(); i++) {
FieldSchema field = this.hiveTblMetadata.getSd().getCols().get(i);
if (field.getName().equals(sortColumn.getCol())) {
Direction direction;
NullDirection nullDirection;
if (sortColumn.getOrder() == BaseSemanticAnalyzer.HIVE_COLUMN_ORDER_ASC) {
direction = Direction.ASCENDING;
nullDirection = NullDirection.FIRST;
}
else {
direction = Direction.DESCENDING;
nullDirection = NullDirection.LAST;
}
collationList.add(new RelFieldCollation(i,direction,nullDirection));
break;
}
}
}
return new ImmutableList.Builder<RelCollation>()
.add(RelCollationTraitDef.INSTANCE.canonize(
new HiveRelCollation(collationList.build())))
.build();
}
代码示例来源:origin: apache/drill
public RelNode align(Aggregate rel, List<RelFieldCollation> collations) {
// 1) We extract the group by positions that are part of the collations and
// sort them so they respect it
LinkedHashSet<Integer> aggregateColumnsOrder = new LinkedHashSet<>();
ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
if (!rel.indicator && !collations.isEmpty()) {
for (RelFieldCollation c : collations) {
if (c.getFieldIndex() < rel.getGroupCount()) {
// Group column found
if (aggregateColumnsOrder.add(c.getFieldIndex())) {
propagateCollations.add(c.copy(rel.getGroupSet().nth(c.getFieldIndex())));
}
}
}
}
for (int i = 0; i < rel.getGroupCount(); i++) {
if (!aggregateColumnsOrder.contains(i)) {
// Not included in the input collations, but can be propagated as this Aggregate
// will enforce it
propagateCollations.add(new RelFieldCollation(rel.getGroupSet().nth(i)));
}
}
// 2) We propagate
final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
// 3) We annotate the Aggregate operator with this info
final HiveAggregate newAggregate = (HiveAggregate) rel.copy(rel.getTraitSet(),
ImmutableList.of(child));
newAggregate.setAggregateColumnsOrder(aggregateColumnsOrder);
return newAggregate;
}
代码示例来源:origin: apache/hive
fieldCollations.add(new RelFieldCollation(fieldIndex, order, nullOrder));
代码示例来源:origin: apache/drill
getEquiJoinPredicateElements().get(i);
for (int leftPos : joinLeafPredInfo.getProjsFromLeftPartOfJoinKeysInJoinSchema()) {
final RelFieldCollation leftFieldCollation = new RelFieldCollation(leftPos);
collationListBuilder.add(leftFieldCollation);
leftCollationListBuilder.add(leftFieldCollation);
final RelFieldCollation rightFieldCollation = new RelFieldCollation(rightPos);
collationListBuilder.add(rightFieldCollation);
rightCollationListBuilder.add(rightFieldCollation);
代码示例来源:origin: apache/drill
if (!joinKeyPositions.contains(pos)) {
joinKeyPositions.add(pos);
collationListBuilder.add(new RelFieldCollation(pos));
代码示例来源:origin: apache/drill
fieldCollations.add(new RelFieldCollation(fieldIndex, order, nullOrder));
代码示例来源:origin: dremio/dremio-oss
@Override
public RelFieldCollation apply(Integer input) {
return new RelFieldCollation(input);
}
}).toList()));
内容来源于网络,如有侵权,请联系作者删除!