本文整理汇总了Java中org.apache.calcite.tools.Frameworks.withPlanner方法的典型用法代码示例。如果您正苦于以下问题:Java Frameworks.withPlanner方法的具体用法?Java Frameworks.withPlanner怎么用?Java Frameworks.withPlanner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.tools.Frameworks
的用法示例。
在下文中一共展示了Frameworks.withPlanner方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCollation
import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
/** Unit test for
* {@link org.apache.calcite.rel.metadata.RelMdCollation#project}
* and other helper functions for deducing collations. */
@Test public void testCollation() {
final Project rel = (Project) convertSql("select * from emp, dept");
final Join join = (Join) rel.getInput();
final RelOptTable empTable = join.getInput(0).getTable();
final RelOptTable deptTable = join.getInput(1).getTable();
Frameworks.withPlanner(
new Frameworks.PlannerAction<Void>() {
public Void apply(RelOptCluster cluster,
RelOptSchema relOptSchema,
SchemaPlus rootSchema) {
checkCollation(cluster, empTable, deptTable);
return null;
}
});
}
示例2: testAverageRowSize
import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
/** Unit test for
* {@link org.apache.calcite.rel.metadata.RelMetadataQuery#getAverageColumnSizes(org.apache.calcite.rel.RelNode)},
* {@link org.apache.calcite.rel.metadata.RelMetadataQuery#getAverageRowSize(org.apache.calcite.rel.RelNode)}. */
@Test public void testAverageRowSize() {
final Project rel = (Project) convertSql("select * from emp, dept");
final Join join = (Join) rel.getInput();
final RelOptTable empTable = join.getInput(0).getTable();
final RelOptTable deptTable = join.getInput(1).getTable();
Frameworks.withPlanner(
new Frameworks.PlannerAction<Void>() {
public Void apply(RelOptCluster cluster,
RelOptSchema relOptSchema,
SchemaPlus rootSchema) {
checkAverageRowSize(cluster, empTable, deptTable);
return null;
}
});
}
示例3: testPredicates
import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
/** Unit test for
* {@link org.apache.calcite.rel.metadata.RelMdPredicates#getPredicates(SemiJoin, RelMetadataQuery)}. */
@Test public void testPredicates() {
final Project rel = (Project) convertSql("select * from emp, dept");
final Join join = (Join) rel.getInput();
final RelOptTable empTable = join.getInput(0).getTable();
final RelOptTable deptTable = join.getInput(1).getTable();
Frameworks.withPlanner(
new Frameworks.PlannerAction<Void>() {
public Void apply(RelOptCluster cluster,
RelOptSchema relOptSchema,
SchemaPlus rootSchema) {
checkPredicates(cluster, empTable, deptTable);
return null;
}
});
}
示例4: ready
import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
private void ready() {
switch (state) {
case STATE_0_CLOSED:
reset();
}
ensure(State.STATE_1_RESET);
Frameworks.withPlanner(
new Frameworks.PlannerAction<Void>() {
public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
SchemaPlus rootSchema) {
Util.discard(rootSchema); // use our own defaultSchema
typeFactory = (JavaTypeFactory) cluster.getTypeFactory();
planner = cluster.getPlanner();
planner.setExecutor(executor);
return null;
}
},
config);
state = State.STATE_2_READY;
// If user specify own traitDef, instead of default default trait,
// first, clear the default trait def registered with planner
// then, register the trait def specified in traitDefs.
if (this.traitDefs != null) {
planner.clearRelTraitDefs();
for (RelTraitDef def : this.traitDefs) {
planner.addRelTraitDef(def);
}
}
}
示例5: testAllPredicates
import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
@Test public void testAllPredicates() {
final Project rel = (Project) convertSql("select * from emp, dept");
final Join join = (Join) rel.getInput();
final RelOptTable empTable = join.getInput(0).getTable();
final RelOptTable deptTable = join.getInput(1).getTable();
Frameworks.withPlanner(
new Frameworks.PlannerAction<Void>() {
public Void apply(RelOptCluster cluster,
RelOptSchema relOptSchema,
SchemaPlus rootSchema) {
checkAllPredicates(cluster, empTable, deptTable);
return null;
}
});
}
示例6: foo
import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
public static void foo(RelNode rel) {
// Convert rel tree to JSON.
final RelJsonWriter writer = new RelJsonWriter();
rel.explain(writer);
final String json = writer.asString();
// Find the schema. If there are no tables in the plan, we won't need one.
final RelOptSchema[] schemas = {null};
rel.accept(new RelShuttleImpl() {
@Override public RelNode visit(TableScan scan) {
schemas[0] = scan.getTable().getRelOptSchema();
return super.visit(scan);
}
});
// Convert JSON back to rel tree.
Frameworks.withPlanner(
new Frameworks.PlannerAction<Object>() {
public Object apply(RelOptCluster cluster,
RelOptSchema relOptSchema, SchemaPlus rootSchema) {
final RelJsonReader reader = new RelJsonReader(
cluster,
schemas[0], rootSchema);
try {
RelNode x = reader.read(json);
} catch (IOException e) {
throw new RuntimeException(e);
}
return null;
}
});
}
示例7: testWriter
import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
/**
* Unit test for {@link org.apache.calcite.rel.externalize.RelJsonWriter} on
* a simple tree of relational expressions, consisting of a table, a filter
* and an aggregate node.
*/
@Test public void testWriter() {
String s =
Frameworks.withPlanner(
new Frameworks.PlannerAction<String>() {
public String apply(RelOptCluster cluster,
RelOptSchema relOptSchema, SchemaPlus rootSchema) {
rootSchema.add("hr",
new ReflectiveSchema(new JdbcTest.HrSchema()));
LogicalTableScan scan =
LogicalTableScan.create(cluster,
relOptSchema.getTableForMember(
Arrays.asList("hr", "emps")));
final RexBuilder rexBuilder = cluster.getRexBuilder();
LogicalFilter filter =
LogicalFilter.create(scan,
rexBuilder.makeCall(
SqlStdOperatorTable.EQUALS,
rexBuilder.makeFieldAccess(
rexBuilder.makeRangeReference(scan),
"deptno", true),
rexBuilder.makeExactLiteral(BigDecimal.TEN)));
final RelJsonWriter writer = new RelJsonWriter();
final RelDataType bigIntType =
cluster.getTypeFactory().createSqlType(SqlTypeName.BIGINT);
LogicalAggregate aggregate =
LogicalAggregate.create(filter, ImmutableBitSet.of(0), null,
ImmutableList.of(
AggregateCall.create(SqlStdOperatorTable.COUNT,
true, false, ImmutableList.of(1), -1,
bigIntType, "c"),
AggregateCall.create(SqlStdOperatorTable.COUNT,
false, false, ImmutableList.<Integer>of(), -1,
bigIntType, "d")));
aggregate.explain(writer);
return writer.asString();
}
});
assertThat(s, is(XX));
}
示例8: testReader
import org.apache.calcite.tools.Frameworks; //导入方法依赖的package包/类
/**
* Unit test for {@link org.apache.calcite.rel.externalize.RelJsonReader}.
*/
@Test public void testReader() {
String s =
Frameworks.withPlanner(
new Frameworks.PlannerAction<String>() {
public String apply(RelOptCluster cluster,
RelOptSchema relOptSchema, SchemaPlus rootSchema) {
SchemaPlus schema =
rootSchema.add("hr",
new ReflectiveSchema(new JdbcTest.HrSchema()));
final RelJsonReader reader =
new RelJsonReader(cluster, relOptSchema, schema);
RelNode node;
try {
node = reader.read(XX);
} catch (IOException e) {
throw new RuntimeException(e);
}
return RelOptUtil.dumpPlan("", node, SqlExplainFormat.TEXT,
SqlExplainLevel.EXPPLAN_ATTRIBUTES);
}
});
assertThat(Util.toLinux(s),
is(
"LogicalAggregate(group=[{0}], agg#0=[COUNT(DISTINCT $1)], agg#1=[COUNT()])\n"
+ " LogicalFilter(condition=[=($1, 10)])\n"
+ " LogicalTableScan(table=[[hr, emps]])\n"));
}