本文整理汇总了Java中org.apache.calcite.rel.RelCollations类的典型用法代码示例。如果您正苦于以下问题:Java RelCollations类的具体用法?Java RelCollations怎么用?Java RelCollations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RelCollations类属于org.apache.calcite.rel包,在下文中一共展示了RelCollations类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: empty
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
/** Creates a relational expression that reads from an input and throws
* all of the rows away.
*/
@Override
public RelBuilder empty() {
final Frame frame = stack.pop();
final RelNode input;
// If the rel that we are limiting the output of a rel, we should just add a limit 0 on top.
// If the rel that we are limiting is a Filter replace it as well since Filter does not
// change the row type.
if (!(frame.rel instanceof Filter)) {
input = frame.rel;
} else {
input = frame.rel.getInput(0);
}
final RelNode sort = sortFactory.createSort(input, RelCollations.EMPTY,
frame.rel.getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(0)),
frame.rel.getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(0)));
push(sort);
return this;
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:RelBuilder.java
示例2: trimUnusedFields
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
/**
* Walks over a tree of relational expressions, replacing each
* {@link RelNode} with a 'slimmed down' relational expression that projects
* only the fields required by its consumer.
*
* <p>This may make things easier for the optimizer, by removing crud that
* would expand the search space, but is difficult for the optimizer itself
* to do it, because optimizer rules must preserve the number and type of
* fields. Hence, this transform that operates on the entire tree, similar
* to the {@link RelStructuredTypeFlattener type-flattening transform}.
*
* <p>Currently this functionality is disabled in farrago/luciddb; the
* default implementation of this method does nothing.
*
* @param ordered Whether the relational expression must produce results in
* a particular order (typically because it has an ORDER BY at top level)
* @param rootRel Relational expression that is at the root of the tree
* @return Trimmed relational expression
*/
public RelNode trimUnusedFields(boolean ordered, RelNode rootRel) {
// Trim fields that are not used by their consumer.
if (isTrimUnusedFields()) {
final RelFieldTrimmer trimmer = newFieldTrimmer();
final List<RelCollation> collations =
rootRel.getTraitSet().getTraits(RelCollationTraitDef.INSTANCE);
rootRel = trimmer.trim(rootRel);
if (!ordered
&& collations != null
&& !collations.isEmpty()
&& !collations.equals(ImmutableList.of(RelCollations.EMPTY))) {
final RelTraitSet traitSet = rootRel.getTraitSet()
.replace(RelCollationTraitDef.INSTANCE, collations);
rootRel = rootRel.copy(traitSet, rootRel.getInputs());
}
if (SQL2REL_LOGGER.isDebugEnabled()) {
SQL2REL_LOGGER.debug(
RelOptUtil.dumpPlan("Plan after trimming unused fields", rootRel,
SqlExplainFormat.TEXT, SqlExplainLevel.EXPPLAN_ATTRIBUTES));
}
}
return rootRel;
}
开发者ID:axbaretto,项目名称:flink,代码行数:43,代码来源:SqlToRelConverter.java
示例3: trimUnusedFields
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
/**
* Walks over a tree of relational expressions, replacing each
* {@link RelNode} with a 'slimmed down' relational expression that projects
* only the fields required by its consumer.
*
* <p>This may make things easier for the optimizer, by removing crud that
* would expand the search space, but is difficult for the optimizer itself
* to do it, because optimizer rules must preserve the number and type of
* fields. Hence, this transform that operates on the entire tree, similar
* to the {@link RelStructuredTypeFlattener type-flattening transform}.
*
* <p>Currently this functionality is disabled in farrago/luciddb; the
* default implementation of this method does nothing.
*
* @param ordered Whether the relational expression must produce results in
* a particular order (typically because it has an ORDER BY at top level)
* @param rootRel Relational expression that is at the root of the tree
* @return Trimmed relational expression
*/
public RelNode trimUnusedFields(boolean ordered, RelNode rootRel) {
// Trim fields that are not used by their consumer.
if (isTrimUnusedFields()) {
final RelFieldTrimmer trimmer = newFieldTrimmer();
final List<RelCollation> collations =
rootRel.getTraitSet().getTraits(RelCollationTraitDef.INSTANCE);
rootRel = trimmer.trim(rootRel);
if (!ordered
&& collations != null
&& !collations.isEmpty()
&& !collations.equals(ImmutableList.of(RelCollations.EMPTY))) {
final RelTraitSet traitSet = rootRel.getTraitSet()
.replace(RelCollationTraitDef.INSTANCE, collations);
rootRel = rootRel.copy(traitSet, rootRel.getInputs());
}
if (SQL2REL_LOGGER.isDebugEnabled()) {
SQL2REL_LOGGER.debug(
RelOptUtil.dumpPlan("Plan after trimming unused fields", rootRel,
SqlExplainFormat.TEXT, SqlExplainLevel.EXPPLAN_ATTRIBUTES));
}
}
return rootRel;
}
开发者ID:apache,项目名称:kylin,代码行数:43,代码来源:SqlToRelConverter.java
示例4: getImplicitCollation
import org.apache.calcite.rel.RelCollations; //导入依赖的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
示例5: getCollation
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
public static RelCollation getCollation(
final List<RexFieldCollation> collations) {
return RelCollations.of(
new AbstractList<RelFieldCollation>() {
public RelFieldCollation get(int index) {
final RexFieldCollation collation = collations.get(index);
return new RelFieldCollation(
((RexLocalRef) collation.left).getIndex(),
collation.getDirection(),
collation.getNullDirection());
}
public int size() {
return collations.size();
}
});
}
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:Window.java
示例6: deduceMonotonicity
import org.apache.calcite.rel.RelCollations; //导入依赖的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;
}
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:SqlToRelTestBase.java
示例7: deduceMonotonicity
import org.apache.calcite.rel.RelCollations; //导入依赖的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;
}
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:MockCatalogReader.java
示例8: write
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
@Override
public void write(final Kryo kryo, final Output output, final T object) {
final boolean isKnown = collationSet.contains(object);
kryo.writeObject(output, isKnown);
if (isKnown) {
kryo.writeObject(output, object.equals(RelCollations.EMPTY) ? 0 : 1);
return;
}
super.write(kryo, output, object);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:12,代码来源:RelTraitSerializers.java
示例9: read
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
@Override
public T read(final Kryo kryo, final Input input, final Class<T> type) {
final boolean isKnown = kryo.readObject(input, Boolean.class);
final T result;
if (isKnown) {
final Integer pos = kryo.readObject(input, Integer.class);
result = (T) (pos == 0 ? RelCollations.EMPTY:RelCollations.PRESERVE);
} else {
result = super.read(kryo, input, type);
}
final T normalized = (T) result.getTraitDef().canonize(result);
kryo.reference(normalized);
return normalized;
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:16,代码来源:RelTraitSerializers.java
示例10: getCollation
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
private static RelCollation getCollation(RelTraitSet set, List<Integer> keys) {
return set.canonize(RelCollations.of(FluentIterable.from(keys)
.transform(new Function<Integer, RelFieldCollation>() {
@Override
public RelFieldCollation apply(Integer input) {
return new RelFieldCollation(input);
}
}).toList()));
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:10,代码来源:WriterUpdater.java
示例11: getCollation
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
/**
* Create a RelCollation that has partition-by as the leading keys followed by order-by keys
* @param window The window specification
* @return a RelCollation with {partition-by keys, order-by keys}
*/
private RelCollation getCollation(Window.Group window) {
List<RelFieldCollation> fields = Lists.newArrayList();
for (int group : BitSets.toIter(window.keys)) {
fields.add(new RelFieldCollation(group));
}
fields.addAll(window.orderKeys.getFieldCollations());
return RelCollations.of(fields);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:16,代码来源:WindowPrule.java
示例12: visitChild
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
@Override
protected RelNode visitChild(RelNode parent, int i, RelNode child) {
RelNode newParent = parent;
if (parent.getConvention() instanceof JdbcConventionIndicator) {
transformer.setTraitSet(parent.getTraitSet().plus(DistributionTrait.ANY).plus(RelCollations.EMPTY));
newParent = parent.accept(transformer);
}
return super.visitChild(newParent, i, newParent.getInput(i));
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:10,代码来源:RexSubQueryUtils.java
示例13: buildStatistic
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
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)));
}
开发者ID:hortonworks,项目名称:streamline,代码行数:10,代码来源:CompilerUtil.java
示例14: convert
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
public RelNode convert(Sort sort, CassandraFilter filter) {
final RelTraitSet traitSet =
sort.getTraitSet().replace(CassandraRel.CONVENTION)
.replace(sort.getCollation());
return new CassandraSort(sort.getCluster(), traitSet,
convert(sort.getInput(), traitSet.replace(RelCollations.EMPTY)),
sort.getCollation());
}
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:CassandraRules.java
示例15: convert
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
public RelNode convert(RelNode rel) {
final Sort sort = (Sort) rel;
final RelTraitSet traitSet =
sort.getTraitSet().replace(out)
.replace(sort.getCollation());
return new MongoSort(rel.getCluster(), traitSet,
convert(sort.getInput(), traitSet.replace(RelCollations.EMPTY)),
sort.getCollation(), sort.offset, sort.fetch);
}
开发者ID:apache,项目名称:calcite,代码行数:10,代码来源:MongoRules.java
示例16: toCollation
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
public RelCollation toCollation(
List<Map<String, Object>> jsonFieldCollations) {
final List<RelFieldCollation> fieldCollations =
new ArrayList<RelFieldCollation>();
for (Map<String, Object> map : jsonFieldCollations) {
fieldCollations.add(toFieldCollation(map));
}
return RelCollations.of(fieldCollations);
}
开发者ID:apache,项目名称:calcite,代码行数:10,代码来源:RelJson.java
示例17: LogicalProject
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
@Deprecated // to be removed before 2.0
public LogicalProject(RelOptCluster cluster, RelNode input,
List<RexNode> projects, List<String> fieldNames, int flags) {
this(cluster, cluster.traitSetOf(RelCollations.EMPTY),
input, projects,
RexUtil.createStructType(cluster.getTypeFactory(), projects,
fieldNames, null));
Util.discard(flags);
}
开发者ID:apache,项目名称:calcite,代码行数:10,代码来源:LogicalProject.java
示例18: values
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
/** Helper method to determine a
* {@link org.apache.calcite.rel.core.Values}'s collation.
*
* <p>We actually under-report the collations. A Values with 0 or 1 rows - an
* edge case, but legitimate and very common - is ordered by every permutation
* of every subset of the columns.
*
* <p>So, our algorithm aims to:<ul>
* <li>produce at most N collations (where N is the number of columns);
* <li>make each collation as long as possible;
* <li>do not repeat combinations already emitted -
* if we've emitted {@code (a, b)} do not later emit {@code (b, a)};
* <li>probe the actual values and make sure that each collation is
* consistent with the data
* </ul>
*
* <p>So, for an empty Values with 4 columns, we would emit
* {@code (a, b, c, d), (b, c, d), (c, d), (d)}. */
public static List<RelCollation> values(RelMetadataQuery mq,
RelDataType rowType, ImmutableList<ImmutableList<RexLiteral>> tuples) {
Util.discard(mq); // for future use
final List<RelCollation> list = Lists.newArrayList();
final int n = rowType.getFieldCount();
final List<Pair<RelFieldCollation, Ordering<List<RexLiteral>>>> pairs =
Lists.newArrayList();
outer:
for (int i = 0; i < n; i++) {
pairs.clear();
for (int j = i; j < n; j++) {
final RelFieldCollation fieldCollation = new RelFieldCollation(j);
Ordering<List<RexLiteral>> comparator = comparator(fieldCollation);
Ordering<List<RexLiteral>> ordering;
if (pairs.isEmpty()) {
ordering = comparator;
} else {
ordering = Util.last(pairs).right.compound(comparator);
}
pairs.add(Pair.of(fieldCollation, ordering));
if (!ordering.isOrdered(tuples)) {
if (j == i) {
continue outer;
}
pairs.remove(pairs.size() - 1);
}
}
if (!pairs.isEmpty()) {
list.add(RelCollations.of(Pair.left(pairs)));
}
}
return list;
}
开发者ID:apache,项目名称:calcite,代码行数:52,代码来源:RelMdCollation.java
示例19: createCloneTable
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
public static <T> Table createCloneTable(final JavaTypeFactory typeFactory,
final RelProtoDataType protoRowType, final List<RelCollation> collations,
final List<ColumnMetaData.Rep> repList, final Enumerable<T> source) {
final Type elementType;
if (source instanceof QueryableTable) {
elementType = ((QueryableTable) source).getElementType();
} else if (protoRowType.apply(typeFactory).getFieldCount() == 1) {
if (repList != null) {
elementType = repList.get(0).clazz;
} else {
elementType = Object.class;
}
} else {
elementType = Object[].class;
}
return new ArrayTable(
elementType,
protoRowType,
Suppliers.memoize(
new Supplier<ArrayTable.Content>() {
public ArrayTable.Content get() {
final ColumnLoader loader =
new ColumnLoader<>(typeFactory, source, protoRowType,
repList);
final List<RelCollation> collation2 =
collations.isEmpty()
&& loader.sortField >= 0
? RelCollations.createSingleton(loader.sortField)
: collations;
return new ArrayTable.Content(loader.representationValues,
loader.size(), collation2);
}
}));
}
开发者ID:apache,项目名称:calcite,代码行数:35,代码来源:CloneSchema.java
示例20: Content
import org.apache.calcite.rel.RelCollations; //导入依赖的package包/类
@Deprecated // to be removed before 2.0
Content(List<? extends Column> columns, int size, int sortField) {
this(columns, size,
sortField >= 0
? RelCollations.createSingleton(sortField)
: ImmutableList.<RelCollation>of());
}
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:ArrayTable.java
注:本文中的org.apache.calcite.rel.RelCollations类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论