本文整理汇总了Java中org.apache.calcite.tools.Programs类的典型用法代码示例。如果您正苦于以下问题:Java Programs类的具体用法?Java Programs怎么用?Java Programs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Programs类属于org.apache.calcite.tools包,在下文中一共展示了Programs类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: GremlinCompiler
import org.apache.calcite.tools.Programs; //导入依赖的package包/类
public GremlinCompiler(Graph graph, SchemaConfig schemaConfig) {
this.graph = graph;
this.schemaConfig = schemaConfig;
final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
final List<RelTraitDef> traitDefs = new ArrayList<>();
traitDefs.add(ConventionTraitDef.INSTANCE);
traitDefs.add(RelCollationTraitDef.INSTANCE);
final SqlParser.Config parserConfig =
SqlParser.configBuilder().setLex(Lex.MYSQL).build();
frameworkConfig = Frameworks.newConfigBuilder()
.parserConfig(parserConfig)
.defaultSchema(rootSchema.add("gremlin", new GremlinSchema(graph, schemaConfig)))
.traitDefs(traitDefs)
.programs(Programs.sequence(Programs.ofRules(Programs.RULE_SET), Programs.CALC_PROGRAM))
.build();
}
开发者ID:twilmes,项目名称:sql-gremlin,代码行数:19,代码来源:GremlinCompiler.java
示例2: config
import org.apache.calcite.tools.Programs; //导入依赖的package包/类
public Frameworks.ConfigBuilder config() throws Exception {
final Holder<SchemaPlus> root = Holder.of(null);
CalciteAssert.model(TPCDS_MODEL)
.doWithConnection(
new Function<CalciteConnection, Object>() {
public Object apply(CalciteConnection input) {
root.set(input.getRootSchema().getSubSchema("TPCDS"));
return null;
}
});
return Frameworks.newConfigBuilder()
.parserConfig(SqlParser.Config.DEFAULT)
.defaultSchema(root.get())
.traitDefs((List<RelTraitDef>) null)
.programs(Programs.heuristicJoinOrder(Programs.RULE_SET, true, 2));
}
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:TpcdsTest.java
示例3: toLeafJoinForm
import org.apache.calcite.tools.Programs; //导入依赖的package包/类
/**
* Converts a relational expression to a form where
* {@link org.apache.calcite.rel.logical.LogicalJoin}s are
* as close to leaves as possible.
*/
public static RelNode toLeafJoinForm(RelNode rel) {
final Program program = Programs.hep(
ImmutableList.of(
JoinProjectTransposeRule.RIGHT_PROJECT,
JoinProjectTransposeRule.LEFT_PROJECT,
FilterJoinRule.FilterIntoJoinRule.FILTER_ON_JOIN,
ProjectRemoveRule.INSTANCE,
ProjectMergeRule.INSTANCE),
false,
DefaultRelMetadataProvider.INSTANCE);
if (CalcitePrepareImpl.DEBUG) {
System.out.println(
RelOptUtil.dumpPlan("before", rel, SqlExplainFormat.TEXT,
SqlExplainLevel.DIGEST_ATTRIBUTES));
}
final RelNode rel2 = program.run(null, rel, null,
ImmutableList.<RelOptMaterialization>of(),
ImmutableList.<RelOptLattice>of());
if (CalcitePrepareImpl.DEBUG) {
System.out.println(
RelOptUtil.dumpPlan("after", rel2, SqlExplainFormat.TEXT,
SqlExplainLevel.DIGEST_ATTRIBUTES));
}
return rel2;
}
开发者ID:apache,项目名称:calcite,代码行数:31,代码来源:RelOptMaterialization.java
示例4: runProjectQueryWithLex
import org.apache.calcite.tools.Programs; //导入依赖的package包/类
private static void runProjectQueryWithLex(Lex lex, String sql)
throws SqlParseException, ValidationException, RelConversionException {
Config javaLex = SqlParser.configBuilder().setLex(lex).build();
Planner planner = getPlanner(null, javaLex, Programs.ofRules(Programs.RULE_SET));
SqlNode parse = planner.parse(sql);
SqlNode validate = planner.validate(parse);
RelNode convert = planner.rel(validate).rel;
RelTraitSet traitSet =
planner.getEmptyTraitSet().replace(EnumerableConvention.INSTANCE);
RelNode transform = planner.transform(0, traitSet, convert);
assertThat(transform, instanceOf(EnumerableProject.class));
List<String> fieldNames = transform.getRowType().getFieldNames();
assertThat(fieldNames.size(), is(2));
if (lex.caseSensitive) {
assertThat(fieldNames.get(0), is("EMPID"));
assertThat(fieldNames.get(1), is("empid"));
} else {
assertThat(fieldNames.get(0) + "-" + fieldNames.get(1),
anyOf(is("EMPID-empid0"), is("EMPID0-empid")));
}
}
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:LexCaseSensitiveTest.java
示例5: prepend
import org.apache.calcite.tools.Programs; //导入依赖的package包/类
@SuppressWarnings("Guava") // Must conform to Calcite's API
public static Function<Holder<Program>, Void> prepend(Program program) {
return (holder) -> {
if (holder == null) {
throw new IllegalStateException("No program holder");
}
Program chain = holder.get();
if (chain == null) {
chain = Programs.standard();
}
holder.set(new SequenceProgram(program, chain));
return null;
};
}
开发者ID:tzolov,项目名称:calcite-sql-rewriter,代码行数:15,代码来源:SequenceProgram.java
示例6: getBuilder
import org.apache.calcite.tools.Programs; //导入依赖的package包/类
/**
* Creates a {@link RelBuilder} with the given schema.
*
* @param dataSource The dataSource for the jdbc schema.
* @param schemaName The name of the schema used for the database.
*
* @return the relbuilder from Calcite.
*
* @throws SQLException if can't readSqlResultSet from database.
*/
public static RelBuilder getBuilder(DataSource dataSource, String schemaName) throws SQLException {
SchemaPlus rootSchema = Frameworks.createRootSchema(true);
return RelBuilder.create(
Frameworks.newConfigBuilder()
.parserConfig(SqlParser.Config.DEFAULT)
.defaultSchema(addSchema(rootSchema, dataSource, schemaName))
.traitDefs((List<RelTraitDef>) null)
.programs(Programs.heuristicJoinOrder(Programs.RULE_SET, true, 2))
.build()
);
}
开发者ID:yahoo,项目名称:fili,代码行数:22,代码来源:CalciteHelper.java
示例7: getPrograms
import org.apache.calcite.tools.Programs; //导入依赖的package包/类
private List<Program> getPrograms() {
ImmutableList.Builder<Program> builder
= ImmutableList.builder();
for (RuleSet ruleSet: getRules()) {
builder.add(Programs.sequence(
new EnumerableProgram(ruleSet, this.context, this.plannerHolder),
Programs.CALC_PROGRAM));
}
return builder.build();
}
开发者ID:qubole,项目名称:quark,代码行数:11,代码来源:SqlWorker.java
示例8: handler
import org.apache.calcite.tools.Programs; //导入依赖的package包/类
private static Function<Pair<List<Prepare.Materialization>, Holder<Program>>, Void> handler(
final boolean bushy, final int minJoinCount) {
return new Function<Pair<List<Prepare.Materialization>, Holder<Program>>,
Void>() {
public Void apply(
Pair<List<Prepare.Materialization>, Holder<Program>> pair) {
pair.right.set(
Programs.sequence(
Programs.heuristicJoinOrder(Programs.RULE_SET, bushy,
minJoinCount),
Programs.CALC_PROGRAM));
return null;
}
};
}
开发者ID:apache,项目名称:calcite,代码行数:16,代码来源:TpcdsTest.java
示例9: getProgram
import org.apache.calcite.tools.Programs; //导入依赖的package包/类
protected Program getProgram() {
// Allow a test to override the default program.
final Holder<Program> holder = Holder.of(null);
Hook.PROGRAM.run(holder);
if (holder.get() != null) {
return holder.get();
}
return Programs.standard();
}
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:Prepare.java
示例10: optimize
import org.apache.calcite.tools.Programs; //导入依赖的package包/类
Sql optimize(final RuleSet ruleSet, final RelOptPlanner relOptPlanner) {
return new Sql(schemaSpec, sql, dialect, config,
FlatLists.append(transforms, new Function<RelNode, RelNode>() {
public RelNode apply(RelNode r) {
Program program = Programs.of(ruleSet);
return program.run(relOptPlanner, r, r.getTraitSet(),
ImmutableList.<RelOptMaterialization>of(),
ImmutableList.<RelOptLattice>of());
}
}));
}
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:RelToSqlConverterTest.java
示例11: config
import org.apache.calcite.tools.Programs; //导入依赖的package包/类
/** Creates a config based on the "scott" schema. */
public static Frameworks.ConfigBuilder config() {
final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
return Frameworks.newConfigBuilder()
.parserConfig(SqlParser.Config.DEFAULT)
.defaultSchema(
CalciteAssert.addSchema(rootSchema, CalciteAssert.SchemaSpec.SCOTT))
.traitDefs((List<RelTraitDef>) null)
.programs(Programs.heuristicJoinOrder(Programs.RULE_SET, true, 2));
}
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:RelBuilderTest.java
示例12: runPlanner
import org.apache.calcite.tools.Programs; //导入依赖的package包/类
private PlannerResult runPlanner(String defaultTableSpace, String query) throws RelConversionException,
SqlParseException, ValidationException, MetadataStorageManagerException {
SchemaPlus subSchema = getSchemaForTableSpace(defaultTableSpace);
if (subSchema == null) {
TableSpaceManager tableSpaceManager = manager.getTableSpaceManager(defaultTableSpace);
clearCache();
throw new StatementExecutionException("internal error,"
+ "Calcite subSchema for " + defaultTableSpace + " is null,"
+ "tableSpaceManager is " + tableSpaceManager + ","
+ "maybe table space " + defaultTableSpace + " is not yet started on this node");
}
final FrameworkConfig config = Frameworks.newConfigBuilder()
.parserConfig(SQL_PARSER_CONFIG)
.defaultSchema(subSchema)
.traitDefs(TRAITS)
// define the rules you want to apply
.programs(Programs.ofRules(Programs.RULE_SET))
.build();
Planner planner = Frameworks.getPlanner(config);
if (LOG.isLoggable(Level.FINER)) {
LOG.log(Level.FINER, "Query: {0}", query);
}
SqlNode n = planner.parse(query);
n = planner.validate(n);
RelNode logicalPlan = planner.rel(n).project();
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Query: {0} {1}", new Object[]{query,
RelOptUtil.dumpPlan("-- Logical Plan", logicalPlan, SqlExplainFormat.TEXT,
SqlExplainLevel.ALL_ATTRIBUTES)});
}
RelDataType originalRowType = logicalPlan.getRowType();
RelOptCluster cluster = logicalPlan.getCluster();
final RelOptPlanner optPlanner = cluster.getPlanner();
RelTraitSet desiredTraits
= cluster.traitSet().replace(EnumerableConvention.INSTANCE);
final RelNode newRoot = optPlanner.changeTraits(logicalPlan, desiredTraits);
optPlanner.setRoot(newRoot);
RelNode bestExp = optPlanner.findBestExp();
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Query: {0} {1}", new Object[]{query,
RelOptUtil.dumpPlan("-- Best Plan", bestExp, SqlExplainFormat.TEXT,
SqlExplainLevel.ALL_ATTRIBUTES)});
}
// System.out.println("Query: "+query+"\n"+
// RelOptUtil.dumpPlan("-- Best Plan", bestExp, SqlExplainFormat.TEXT,
// SqlExplainLevel.ALL_ATTRIBUTES));
return new PlannerResult(bestExp, originalRowType, logicalPlan);
}
开发者ID:diennea,项目名称:herddb,代码行数:51,代码来源:CalcitePlanner.java
注:本文中的org.apache.calcite.tools.Programs类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论