本文整理汇总了Java中org.apache.calcite.rel.RelCollation类的典型用法代码示例。如果您正苦于以下问题:Java RelCollation类的具体用法?Java RelCollation怎么用?Java RelCollation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RelCollation类属于org.apache.calcite.rel包,在下文中一共展示了RelCollation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onMatch
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final DrillWriterRel writer = call.rel(0);
final RelNode input = call.rel(1);
final List<Integer> keys = writer.getPartitionKeys();
final RelCollation collation = getCollation(keys);
final boolean hashDistribute = PrelUtil.getPlannerSettings(call.getPlanner()).getOptions().getOption(ExecConstants.CTAS_PARTITIONING_HASH_DISTRIBUTE_VALIDATOR);
final RelTraitSet traits = hashDistribute ?
input.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(collation).plus(getDistribution(keys)) :
input.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(collation);
final RelNode convertedInput = convert(input, traits);
if (!new WriteTraitPull(call).go(writer, convertedInput)) {
DrillWriterRelBase newWriter = new WriterPrel(writer.getCluster(), convertedInput.getTraitSet(),
convertedInput, writer.getCreateTableEntry());
call.transformTo(newWriter);
}
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:22,代码来源:WriterPrule.java
示例2: planSort
import org.apache.calcite.rel.RelCollation; //导入依赖的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);
}
开发者ID:diennea,项目名称:herddb,代码行数:18,代码来源:CalcitePlanner.java
示例3: trimUnusedFields
import org.apache.calcite.rel.RelCollation; //导入依赖的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
示例4: create
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
/** Creates an DirPrunedEnumerableTableScan. */
public static EnumerableTableScan create(RelOptCluster cluster,
RelOptTable relOptTable, String digestFromSelection) {
final Table table = relOptTable.unwrap(Table.class);
Class elementType = EnumerableTableScan.deduceElementType(table);
final RelTraitSet traitSet =
cluster.traitSetOf(EnumerableConvention.INSTANCE)
.replaceIfs(RelCollationTraitDef.INSTANCE,
new Supplier<List<RelCollation>>() {
public List<RelCollation> get() {
if (table != null) {
return table.getStatistic().getCollations();
}
return ImmutableList.of();
}
});
return new DirPrunedEnumerableTableScan(cluster, traitSet, relOptTable, elementType, digestFromSelection);
}
开发者ID:axbaretto,项目名称:drill,代码行数:19,代码来源:DirPrunedEnumerableTableScan.java
示例5: createResultSet
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
protected MetaResultSet createResultSet(
Map<String, Object> internalParameters, List<ColumnMetaData> columns,
CursorFactory cursorFactory, final Frame firstFrame) {
try {
final CalciteConnectionImpl connection = getConnection();
final AvaticaStatement statement = connection.createStatement();
final CalcitePrepare.CalciteSignature<Object> signature =
new CalcitePrepare.CalciteSignature<Object>("",
ImmutableList.<AvaticaParameter>of(), internalParameters, null,
columns, cursorFactory, ImmutableList.<RelCollation>of(), -1,
null, Meta.StatementType.SELECT) {
@Override
public Enumerable<Object> enumerable(
DataContext dataContext) {
return Linq4j.asEnumerable(firstFrame.rows);
}
};
return MetaResultSet.create(connection.id, statement.getId(), true,
signature, firstFrame);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
开发者ID:bitnine-oss,项目名称:octopus,代码行数:24,代码来源:CalciteMetaImpl.java
示例6: CalciteSignature
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
CalciteSignature(String sql,
List<AvaticaParameter> parameterList,
Map<String, Object> internalParameters,
RelDataType rowType,
List<ColumnMetaData> columns,
Meta.CursorFactory cursorFactory,
List<RelCollation> collationList,
long maxRowCount,
Bindable<T> bindable,
Meta.StatementType statementType) {
super(columns, sql, parameterList, internalParameters, cursorFactory,
statementType);
this.rowType = rowType;
this.collationList = collationList;
this.maxRowCount = maxRowCount;
this.bindable = bindable;
}
开发者ID:bitnine-oss,项目名称:octopus,代码行数:18,代码来源:CalcitePrepare.java
示例7: create
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
@Override
public ResultSet create(ColumnMetaData.AvaticaType elementType,
Iterable<Object> iterable) {
final List<ColumnMetaData> columnMetaDataList;
if (elementType instanceof ColumnMetaData.StructType) {
columnMetaDataList = ((ColumnMetaData.StructType) elementType).columns;
} else {
columnMetaDataList =
ImmutableList.of(ColumnMetaData.dummy(elementType, false));
}
final CalcitePrepare.CalciteSignature signature =
(CalcitePrepare.CalciteSignature) this.signature;
final CalcitePrepare.CalciteSignature<Object> newSignature =
new CalcitePrepare.CalciteSignature<>(signature.sql,
signature.parameters, signature.internalParameters,
signature.rowType, columnMetaDataList, Meta.CursorFactory.ARRAY,
ImmutableList.<RelCollation>of(), -1, null);
ResultSetMetaData subResultSetMetaData =
new AvaticaResultSetMetaData(statement, null, newSignature);
final CalciteResultSet resultSet =
new CalciteResultSet(statement, signature, subResultSetMetaData,
localCalendar.getTimeZone(), new Meta.Frame(0, true, iterable));
final Cursor cursor = resultSet.createCursor(elementType, iterable);
return resultSet.execute2(cursor, columnMetaDataList);
}
开发者ID:bitnine-oss,项目名称:octopus,代码行数:26,代码来源:CalciteResultSet.java
示例8: create
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
@Override
public ResultSet create(ColumnMetaData.AvaticaType elementType,
Iterable<Object> iterable) {
final List<ColumnMetaData> columnMetaDataList;
if (elementType instanceof ColumnMetaData.StructType) {
columnMetaDataList = ((ColumnMetaData.StructType) elementType).columns;
} else {
columnMetaDataList =
ImmutableList.of(ColumnMetaData.dummy(elementType, false));
}
final CalcitePrepare.CalciteSignature signature =
(CalcitePrepare.CalciteSignature) this.signature;
final CalcitePrepare.CalciteSignature<Object> newSignature =
new CalcitePrepare.CalciteSignature<>(signature.sql,
signature.parameters, signature.internalParameters,
signature.rowType, columnMetaDataList, Meta.CursorFactory.ARRAY,
signature.rootSchema, ImmutableList.<RelCollation>of(), -1, null);
ResultSetMetaData subResultSetMetaData =
new AvaticaResultSetMetaData(statement, null, newSignature);
final QuarkResultSet resultSet =
new QuarkResultSet(statement, signature, subResultSetMetaData,
localCalendar.getTimeZone(), new Meta.Frame(0, true, iterable));
final Cursor cursor = resultSet.createCursor(elementType, iterable);
return resultSet.execute2(cursor, columnMetaDataList);
}
开发者ID:qubole,项目名称:quark,代码行数:26,代码来源:QuarkResultSet.java
示例9: createResultSet
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
protected MetaResultSet createResultSet(
Map<String, Object> internalParameters, List<ColumnMetaData> columns,
CursorFactory cursorFactory, final Frame firstFrame) {
try {
final QuarkConnectionImpl connection = getConnection();
final AvaticaStatement statement = connection.createStatement();
final CalcitePrepare.CalciteSignature<Object> signature =
new CalcitePrepare.CalciteSignature<Object>("",
ImmutableList.<AvaticaParameter>of(), internalParameters, null,
columns, cursorFactory, null, ImmutableList.<RelCollation>of(), -1,
null, Meta.StatementType.SELECT) {
@Override public Enumerable<Object> enumerable(
DataContext dataContext) {
return Linq4j.asEnumerable(firstFrame.rows);
}
};
return MetaResultSet.create(connection.id, statement.getId(), true,
signature, firstFrame);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
开发者ID:qubole,项目名称:quark,代码行数:23,代码来源:QuarkMetaImpl.java
示例10: trimUnusedFields
import org.apache.calcite.rel.RelCollation; //导入依赖的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
示例11: getImplicitCollation
import org.apache.calcite.rel.RelCollation; //导入依赖的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
示例12: create
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
/** Creates a LogicalProject, specifying row type rather than field names. */
public static LogicalProject create(final RelNode input,
final List<? extends RexNode> projects, RelDataType rowType) {
final RelOptCluster cluster = input.getCluster();
final RelMetadataQuery mq = cluster.getMetadataQuery();
final RelTraitSet traitSet =
cluster.traitSet().replace(Convention.NONE)
.replaceIfs(
RelCollationTraitDef.INSTANCE,
new Supplier<List<RelCollation>>() {
public List<RelCollation> get() {
return RelMdCollation.project(mq, input, projects);
}
});
return new LogicalProject(cluster, traitSet, input, projects, rowType);
}
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:LogicalProject.java
示例13: create
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
/** Creates a LogicalFilter. */
public static LogicalFilter create(final RelNode input, RexNode condition,
ImmutableSet<CorrelationId> variablesSet) {
final RelOptCluster cluster = input.getCluster();
final RelMetadataQuery mq = cluster.getMetadataQuery();
final RelTraitSet traitSet = cluster.traitSetOf(Convention.NONE)
.replaceIfs(RelCollationTraitDef.INSTANCE,
new Supplier<List<RelCollation>>() {
public List<RelCollation> get() {
return RelMdCollation.filter(mq, input);
}
})
.replaceIf(RelDistributionTraitDef.INSTANCE,
new Supplier<RelDistribution>() {
public RelDistribution get() {
return RelMdDistribution.filter(mq, input);
}
});
return new LogicalFilter(cluster, traitSet, input, condition, variablesSet);
}
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:LogicalFilter.java
示例14: create
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
/** Creates a LogicalTableScan.
*
* @param cluster Cluster
* @param relOptTable Table
*/
public static LogicalTableScan create(RelOptCluster cluster,
final RelOptTable relOptTable) {
final Table table = relOptTable.unwrap(Table.class);
final RelTraitSet traitSet =
cluster.traitSetOf(Convention.NONE)
.replaceIfs(RelCollationTraitDef.INSTANCE,
new Supplier<List<RelCollation>>() {
public List<RelCollation> get() {
if (table != null) {
return table.getStatistic().getCollations();
}
return ImmutableList.of();
}
});
return new LogicalTableScan(cluster, traitSet, relOptTable);
}
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:LogicalTableScan.java
示例15: checkInputForCollationAndLimit
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
/** Returns whether a relational expression is already sorted and has fewer
* rows than the sum of offset and limit.
*
* <p>If this is the case, it is safe to push down a
* {@link org.apache.calcite.rel.core.Sort} with limit and optional offset. */
public static boolean checkInputForCollationAndLimit(RelMetadataQuery mq,
RelNode input, RelCollation collation, RexNode offset, RexNode fetch) {
// Check if the input is already sorted
boolean alreadySorted = collation.getFieldCollations().isEmpty();
for (RelCollation inputCollation : mq.collations(input)) {
if (inputCollation.satisfies(collation)) {
alreadySorted = true;
break;
}
}
// Check if we are not reducing the number of tuples
boolean alreadySmaller = true;
final Double rowCount = mq.getMaxRowCount(input);
if (rowCount != null && fetch != null) {
final int offsetVal = offset == null ? 0 : RexLiteral.intValue(offset);
final int limit = RexLiteral.intValue(fetch);
if ((double) offsetVal + (double) limit < rowCount) {
alreadySmaller = false;
}
}
return alreadySorted && alreadySmaller;
}
开发者ID:apache,项目名称:calcite,代码行数:28,代码来源:RelMdUtil.java
示例16: getStatistic
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
public Statistic getStatistic() {
return new Statistic() {
public Double getRowCount() {
return table.rowCount;
}
public boolean isKey(ImmutableBitSet columns) {
return table.isKey(columns);
}
public List<RelReferentialConstraint> getReferentialConstraints() {
return table.getReferentialConstraints();
}
public List<RelCollation> getCollations() {
return table.collationList;
}
public RelDistribution getDistribution() {
return table.getDistribution();
}
};
}
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:MockCatalogReader.java
示例17: getTableForMember
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
public RelOptTable getTableForMember(List<String> names) {
final SqlValidatorTable table =
catalogReader.getTable(names);
final RelDataType rowType = table.getRowType();
final List<RelCollation> collationList = deduceMonotonicity(table);
if (names.size() < 3) {
String[] newNames2 = {"CATALOG", "SALES", ""};
List<String> newNames = new ArrayList<>();
int i = 0;
while (newNames.size() < newNames2.length) {
newNames.add(i, newNames2[i]);
++i;
}
names = newNames;
}
return createColumnSet(table, names, rowType, collationList);
}
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:SqlToRelTestBase.java
示例18: fields
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
/** Returns references to fields for a given collation. */
public ImmutableList<RexNode> fields(RelCollation collation) {
final ImmutableList.Builder<RexNode> nodes = ImmutableList.builder();
for (RelFieldCollation fieldCollation : collation.getFieldCollations()) {
RexNode node = field(fieldCollation.getFieldIndex());
switch (fieldCollation.direction) {
case DESCENDING:
node = desc(node);
}
switch (fieldCollation.nullDirection) {
case FIRST:
node = nullsFirst(node);
break;
case LAST:
node = nullsLast(node);
break;
}
nodes.add(node);
}
return nodes.build();
}
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:RelBuilder.java
示例19: Sort
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
/**
* Creates a Sort.
*
* @param cluster Cluster this relational expression belongs to
* @param traits Traits
* @param child input relational expression
* @param collation array of sort specifications
* @param offset Expression for number of rows to discard before returning
* first row
* @param fetch Expression for number of rows to fetch
*/
public Sort(
RelOptCluster cluster,
RelTraitSet traits,
RelNode child,
RelCollation collation,
RexNode offset,
RexNode fetch) {
super(cluster, traits, child);
this.collation = collation;
this.offset = offset;
this.fetch = fetch;
assert traits.containsIfApplicable(collation)
: "traits=" + traits + ", collation=" + collation;
assert !(fetch == null
&& offset == null
&& collation.getFieldCollations().isEmpty())
: "trivial sort";
ImmutableList.Builder<RexNode> builder = ImmutableList.builder();
for (RelFieldCollation field : collation.getFieldCollations()) {
int index = field.getFieldIndex();
builder.add(cluster.getRexBuilder().makeInputRef(child, index));
}
fieldExps = builder.build();
}
开发者ID:apache,项目名称:calcite,代码行数:37,代码来源:Sort.java
示例20: Group
import org.apache.calcite.rel.RelCollation; //导入依赖的package包/类
public Group(
ImmutableBitSet keys,
boolean isRows,
RexWindowBound lowerBound,
RexWindowBound upperBound,
RelCollation orderKeys,
List<RexWinAggCall> aggCalls) {
assert orderKeys != null : "precondition: ordinals != null";
assert keys != null;
this.keys = keys;
this.isRows = isRows;
this.lowerBound = lowerBound;
this.upperBound = upperBound;
this.orderKeys = orderKeys;
this.aggCalls = ImmutableList.copyOf(aggCalls);
this.digest = computeString();
}
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:Window.java
注:本文中的org.apache.calcite.rel.RelCollation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论