本文整理了Java中org.apache.calcite.tools.Frameworks.withPrepare()
方法的一些代码示例,展示了Frameworks.withPrepare()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Frameworks.withPrepare()
方法的具体详情如下:
包路径:org.apache.calcite.tools.Frameworks
类名称:Frameworks
方法名:withPrepare
[英]Initializes a container then calls user-specified code with a planner and statement.
[中]
代码示例来源:origin: apache/hive
/** Creates a RelBuilder. */
public static HiveSubQRemoveRelBuilder create(FrameworkConfig config) {
final RelOptCluster[] clusters = {null};
final RelOptSchema[] relOptSchemas = {null};
Frameworks.withPrepare(
new Frameworks.PrepareAction<Void>(config) {
public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
SchemaPlus rootSchema, CalciteServerStatement statement) {
clusters[0] = cluster;
relOptSchemas[0] = relOptSchema;
return null;
}
});
return new HiveSubQRemoveRelBuilder(config.getContext(), clusters[0], relOptSchemas[0]);
}
代码示例来源:origin: apache/hive
/** Creates a RelBuilder. */
public static RelBuilder create(FrameworkConfig config) {
final RelOptCluster[] clusters = {null};
final RelOptSchema[] relOptSchemas = {null};
Frameworks.withPrepare(
new Frameworks.PrepareAction<Void>(config) {
public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
SchemaPlus rootSchema, CalciteServerStatement statement) {
clusters[0] = cluster;
relOptSchemas[0] = relOptSchema;
return null;
}
});
return new HiveRelBuilder(config.getContext(), clusters[0], relOptSchemas[0]);
}
代码示例来源:origin: apache/drill
/** Creates a RelBuilder. */
public static HiveSubQRemoveRelBuilder create(FrameworkConfig config) {
final RelOptCluster[] clusters = {null};
final RelOptSchema[] relOptSchemas = {null};
Frameworks.withPrepare(
new Frameworks.PrepareAction<Void>(config) {
public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
SchemaPlus rootSchema, CalciteServerStatement statement) {
clusters[0] = cluster;
relOptSchemas[0] = relOptSchema;
return null;
}
});
return new HiveSubQRemoveRelBuilder(config.getContext(), clusters[0], relOptSchemas[0]);
}
代码示例来源:origin: apache/drill
/** Creates a RelBuilder. */
public static RelBuilder create(FrameworkConfig config) {
final RelOptCluster[] clusters = {null};
final RelOptSchema[] relOptSchemas = {null};
Frameworks.withPrepare(
new Frameworks.PrepareAction<Void>(config) {
public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
SchemaPlus rootSchema, CalciteServerStatement statement) {
clusters[0] = cluster;
relOptSchemas[0] = relOptSchema;
return null;
}
});
return new HiveRelBuilder(config.getContext(), clusters[0], relOptSchemas[0]);
}
代码示例来源:origin: Qihoo360/Quicksql
/**
* Initializes a container then calls user-specified code with a planner.
*
* @param action Callback containing user-specified code
* @param config FrameworkConfig to use for planner action.
* @return Return value from action
*/
public static <R> R withPlanner(final PlannerAction<R> action, //
final FrameworkConfig config) {
return withPrepare(
new Frameworks.PrepareAction<R>(config) {
public R apply(RelOptCluster cluster, RelOptSchema relOptSchema,
SchemaPlus rootSchema, CalciteServerStatement statement) {
final CalciteSchema schema =
CalciteSchema.from(
Util.first(config.getDefaultSchema(), rootSchema));
return action.apply(cluster, relOptSchema, schema.root().plus());
}
});
}
代码示例来源:origin: org.apache.calcite/calcite-core
/**
* Initializes a container then calls user-specified code with a planner.
*
* @param action Callback containing user-specified code
* @param config FrameworkConfig to use for planner action.
* @return Return value from action
*/
public static <R> R withPlanner(final PlannerAction<R> action, //
final FrameworkConfig config) {
return withPrepare(
new Frameworks.PrepareAction<R>(config) {
public R apply(RelOptCluster cluster, RelOptSchema relOptSchema,
SchemaPlus rootSchema, CalciteServerStatement statement) {
final CalciteSchema schema =
CalciteSchema.from(
Util.first(config.getDefaultSchema(), rootSchema));
return action.apply(cluster, relOptSchema, schema.root().plus());
}
});
}
代码示例来源:origin: org.apache.calcite/calcite-core
protected void check(final Action action) throws Exception {
Frameworks.withPrepare(
new Frameworks.PrepareAction<Void>() {
public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
SchemaPlus rootSchema, CalciteServerStatement statement) {
final RexBuilder rexBuilder = cluster.getRexBuilder();
DataContext dataContext =
Schemas.createDataContext(statement.getConnection(), rootSchema);
final RexExecutorImpl executor = new RexExecutorImpl(dataContext);
action.check(rexBuilder, executor);
return null;
}
});
}
代码示例来源:origin: Qihoo360/Quicksql
protected void check(final Action action) throws Exception {
Frameworks.withPrepare(
new Frameworks.PrepareAction<Void>() {
public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
SchemaPlus rootSchema, CalciteServerStatement statement) {
final RexBuilder rexBuilder = cluster.getRexBuilder();
DataContext dataContext =
Schemas.createDataContext(statement.getConnection(), rootSchema);
final RexExecutorImpl executor = new RexExecutorImpl(dataContext);
action.check(rexBuilder, executor);
return null;
}
});
}
代码示例来源:origin: Qihoo360/Quicksql
private void checkTypeSystem(final int expected, FrameworkConfig config) {
Frameworks.withPrepare(
new Frameworks.PrepareAction<Void>(config) {
@Override public Void apply(RelOptCluster cluster,
RelOptSchema relOptSchema, SchemaPlus rootSchema,
CalciteServerStatement statement) {
final RelDataType type =
cluster.getTypeFactory()
.createSqlType(SqlTypeName.DECIMAL, 30, 2);
final RexLiteral literal =
cluster.getRexBuilder().makeExactLiteral(BigDecimal.ONE, type);
final RexNode call =
cluster.getRexBuilder().makeCall(SqlStdOperatorTable.PLUS,
literal,
literal);
assertEquals(expected, call.getType().getPrecision());
return null;
}
});
}
代码示例来源:origin: org.apache.calcite/calcite-core
private void checkTypeSystem(final int expected, FrameworkConfig config) {
Frameworks.withPrepare(
new Frameworks.PrepareAction<Void>(config) {
@Override public Void apply(RelOptCluster cluster,
RelOptSchema relOptSchema, SchemaPlus rootSchema,
CalciteServerStatement statement) {
final RelDataType type =
cluster.getTypeFactory()
.createSqlType(SqlTypeName.DECIMAL, 30, 2);
final RexLiteral literal =
cluster.getRexBuilder().makeExactLiteral(BigDecimal.ONE, type);
final RexNode call =
cluster.getRexBuilder().makeCall(SqlStdOperatorTable.PLUS,
literal,
literal);
assertEquals(expected, call.getType().getPrecision());
return null;
}
});
}
代码示例来源:origin: Qihoo360/Quicksql
/** Creates a RelBuilder. */
public static RelBuilder create(FrameworkConfig config) {
final RelOptCluster[] clusters = {null};
final RelOptSchema[] relOptSchemas = {null};
Frameworks.withPrepare(
new Frameworks.PrepareAction<Void>(config) {
public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
SchemaPlus rootSchema, CalciteServerStatement statement) {
clusters[0] = cluster;
relOptSchemas[0] = relOptSchema;
return null;
}
});
return new RelBuilder(config.getContext(), clusters[0], relOptSchemas[0]);
}
代码示例来源:origin: org.apache.calcite/calcite-core
/** Creates a RelBuilder. */
public static RelBuilder create(FrameworkConfig config) {
final RelOptCluster[] clusters = {null};
final RelOptSchema[] relOptSchemas = {null};
Frameworks.withPrepare(
new Frameworks.PrepareAction<Void>(config) {
public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
SchemaPlus rootSchema, CalciteServerStatement statement) {
clusters[0] = cluster;
relOptSchemas[0] = relOptSchema;
return null;
}
});
return new RelBuilder(config.getContext(), clusters[0], relOptSchemas[0]);
}
代码示例来源:origin: org.apache.calcite/calcite-core
Frameworks.withPrepare(
new Frameworks.PrepareAction<Void>() {
public Void apply(RelOptCluster cluster,
代码示例来源:origin: Qihoo360/Quicksql
Frameworks.withPrepare(
new Frameworks.PrepareAction<Void>() {
public Void apply(RelOptCluster cluster,
内容来源于网络,如有侵权,请联系作者删除!