本文整理汇总了Java中org.apache.calcite.plan.MaterializedViewSubstitutionVisitor类的典型用法代码示例。如果您正苦于以下问题:Java MaterializedViewSubstitutionVisitor类的具体用法?Java MaterializedViewSubstitutionVisitor怎么用?Java MaterializedViewSubstitutionVisitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MaterializedViewSubstitutionVisitor类属于org.apache.calcite.plan包,在下文中一共展示了MaterializedViewSubstitutionVisitor类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: substitute
import org.apache.calcite.plan.MaterializedViewSubstitutionVisitor; //导入依赖的package包/类
/**
* Finds substitutions for the given query and target such that each satisfiable instance of
* target is replaced with replacement.
*
* @param query incoming query
* @param target target to replace
* @param replacement replacement that is computationally equivalent to target
* @return list of substitutions
*/
protected List<Substitution> substitute(
final RelNode query, final RelNode target, final RelNode replacement) {
return Lists.transform(new MaterializedViewSubstitutionVisitor(target, query).go(replacement), new Function<RelNode, Substitution>() {
@Override
public Substitution apply(RelNode input) {
return new Substitution(input, null);
}
});
}
示例2: apply
import org.apache.calcite.plan.MaterializedViewSubstitutionVisitor; //导入依赖的package包/类
protected void apply(RelOptRuleCall call, Filter filter, TableScan scan) {
//Avoid optimizing already optimized scan
if (scan instanceof QuarkViewScan || scan instanceof QuarkTileScan) {
return;
}
RelNode root = filter.copy(filter.getTraitSet(),
Collections.singletonList((RelNode) scan));
RelOptPlanner planner = call.getPlanner();
if (planner instanceof VolcanoPlanner) {
List<RelOptMaterialization> materializations
= ((VolcanoPlanner) planner).getMaterializations();
for (RelOptMaterialization materialization : materializations) {
if (scan.getRowType().equals(materialization.queryRel.getRowType())) {
RelNode target = materialization.queryRel;
final HepPlanner hepPlanner =
new HepPlanner(program, planner.getContext());
hepPlanner.setRoot(target);
target = hepPlanner.findBestExp();
List<RelNode> subs = new MaterializedViewSubstitutionVisitor(target, root)
.go(materialization.tableRel);
for (RelNode s : subs) {
call.transformTo(s);
}
}
}
}
}
示例3: apply
import org.apache.calcite.plan.MaterializedViewSubstitutionVisitor; //导入依赖的package包/类
protected void apply(RelOptRuleCall call, Filter filter, TableScan scan) {
RelOptPlanner planner = call.getPlanner();
List<RelOptMaterialization> materializations =
(planner instanceof VolcanoPlanner)
? ((VolcanoPlanner) planner).getMaterializations()
: ImmutableList.<RelOptMaterialization>of();
if (!materializations.isEmpty()) {
RelNode root = filter.copy(filter.getTraitSet(),
Collections.singletonList((RelNode) scan));
List<RelOptMaterialization> applicableMaterializations =
RelOptMaterializations.getApplicableMaterializations(root, materializations);
for (RelOptMaterialization materialization : applicableMaterializations) {
if (RelOptUtil.areRowTypesEqual(scan.getRowType(),
materialization.queryRel.getRowType(), false)) {
RelNode target = materialization.queryRel;
final HepPlanner hepPlanner =
new HepPlanner(program, planner.getContext());
hepPlanner.setRoot(target);
target = hepPlanner.findBestExp();
List<RelNode> subs = new MaterializedViewSubstitutionVisitor(target, root)
.go(materialization.tableRel);
for (RelNode s : subs) {
call.transformTo(s);
}
}
}
}
}