本文整理汇总了Java中org.apache.calcite.adapter.java.JavaTypeFactory类的典型用法代码示例。如果您正苦于以下问题:Java JavaTypeFactory类的具体用法?Java JavaTypeFactory怎么用?Java JavaTypeFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavaTypeFactory类属于org.apache.calcite.adapter.java包,在下文中一共展示了JavaTypeFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JdbcPrel
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
public JdbcPrel(RelOptCluster cluster, RelTraitSet traitSet, JdbcIntermediatePrel prel) {
super(cluster, traitSet);
final RelNode input = prel.getInput();
rows = input.getRows();
convention = (DrillJdbcConvention) input.getTraitSet().getTrait(ConventionTraitDef.INSTANCE);
// generate sql for tree.
final SqlDialect dialect = convention.getPlugin().getDialect();
final JdbcImplementor jdbcImplementor = new JdbcImplementor(
dialect,
(JavaTypeFactory) getCluster().getTypeFactory());
final JdbcImplementor.Result result =
jdbcImplementor.visitChild(0, input.accept(new SubsetRemover()));
sql = result.asQuery().toSqlString(dialect).getSql();
rowType = input.getRowType();
}
示例2: populateInputDAG
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
@Override
public RelInfo populateInputDAG(DAG dag, JavaTypeFactory typeFactory)
{
KafkaSinglePortInputOperator kafkaInput = dag.addOperator(OperatorUtils.getUniqueOperatorName("KafkaInput"),
KafkaSinglePortInputOperator.class);
kafkaInput.setTopics((String)operands.get(KAFKA_TOPICS));
kafkaInput.setInitialOffset("EARLIEST");
Properties props = new Properties();
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, operands.get(KAFKA_SERVERS));
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, KEY_DESERIALIZER);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, VALUE_DESERIALIZER);
kafkaInput.setConsumerProps(props);
kafkaInput.setClusters((String)operands.get(KAFKA_SERVERS));
RelInfo spec = messageFormat.populateInputDAG(dag, typeFactory);
dag.addStream(OperatorUtils.getUniqueStreamName("Kafka", "Parser"), kafkaInput.outputPort,
spec.getInputPorts().get(0));
return new RelInfo("Input", Lists.<Operator.InputPort>newArrayList(), spec.getOperator(), spec.getOutPort(),
messageFormat.getRowType(typeFactory));
}
示例3: populateOutputDAG
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
@Override
public RelInfo populateOutputDAG(DAG dag, JavaTypeFactory typeFactory)
{
RelInfo spec = messageFormat.populateOutputDAG(dag, typeFactory);
KafkaSinglePortOutputOperator kafkaOutput = dag.addOperator(OperatorUtils.getUniqueOperatorName("KafkaOutput"),
KafkaSinglePortOutputOperator.class);
kafkaOutput.setTopic((String)operands.get(KAFKA_TOPICS));
Properties props = new Properties();
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, VALUE_SERIALIZER);
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, KEY_SERIALIZER);
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, operands.get(KAFKA_SERVERS));
kafkaOutput.setProperties(props);
dag.addStream(OperatorUtils.getUniqueStreamName("Formatter", "Kafka"), spec.getOutPort(), kafkaOutput.inputPort);
return new RelInfo("Output", spec.getInputPorts(), spec.getOperator(), null, messageFormat.getRowType(typeFactory));
}
示例4: connect
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
/**
* Creates an internal connection.
*/
CalciteConnection connect(CalciteSchema rootSchema,
JavaTypeFactory typeFactory) {
/*
return (CalciteConnection) ((CalciteFactory) factory)
.newConnection(this, factory, CONNECT_STRING_PREFIX, new Properties(),
rootSchema, typeFactory);
*/
System.out.println("********************************************************************");
System.out.println("********************************************************************");
System.out.println("********************************************************************");
System.out.println("********************************************************************");
System.out.println("********************************************************************");
return (CalciteConnection) ((CalciteFactory) factory)
.newConnection(this, factory, CONNECT_STRING_PREFIX, new Properties(),
(CalciteSchema) SchemaManager.getSingletonInstance(null).getCurrentSchema(),
typeFactory);
}
示例5: CalciteConnectionImpl
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
/**
* Creates a CalciteConnectionImpl.
* <p/>
* <p>Not public; method is called only from the driver.</p>
*
* @param driver Driver
* @param factory Factory for JDBC objects
* @param url Server URL
* @param info Other connection properties
* @param rootSchema Root schema, or null
* @param typeFactory Type factory, or null
*/
protected CalciteConnectionImpl(Driver driver, AvaticaFactory factory,
String url, Properties info, CalciteSchema rootSchema,
JavaTypeFactory typeFactory) {
super(driver, factory, url, info);
CalciteConnectionConfig cfg = new CalciteConnectionConfigImpl(info);
this.prepareFactory = driver.getPrepareFactory();
if (typeFactory != null) {
this.typeFactory = typeFactory;
} else {
final RelDataTypeSystem typeSystem =
cfg.typeSystem(RelDataTypeSystem.class, RelDataTypeSystem.DEFAULT);
this.typeFactory = new JavaTypeFactoryImpl(typeSystem);
}
this.rootSchema =
Preconditions.checkNotNull(rootSchema != null
? rootSchema
: CalciteSchema.createRootSchema(true));
Preconditions.checkArgument(this.rootSchema.isRoot(), "must be root schema");
this.properties.put(InternalProperty.CASE_SENSITIVE, cfg.caseSensitive());
this.properties.put(InternalProperty.UNQUOTED_CASING, cfg.unquotedCasing());
this.properties.put(InternalProperty.QUOTED_CASING, cfg.quotedCasing());
this.properties.put(InternalProperty.QUOTING, cfg.quoting());
}
示例6: QuarkConnectionImpl
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
protected QuarkConnectionImpl(QuarkDriver driver, AvaticaFactory factory, String url,
Properties info, CalciteRootSchema rootSchema,
JavaTypeFactory typeFactory) throws SQLException {
super(driver, factory, url, info);
CalciteConnectionConfig cfg = new CalciteConnectionConfigImpl(info);
if (typeFactory != null) {
this.typeFactory = typeFactory;
} else {
final RelDataTypeSystem typeSystem =
cfg.typeSystem(RelDataTypeSystem.class, RelDataTypeSystem.DEFAULT);
this.typeFactory = new JavaTypeFactoryImpl(typeSystem);
}
this.properties.put(InternalProperty.CASE_SENSITIVE, cfg.caseSensitive());
this.properties.put(InternalProperty.UNQUOTED_CASING, cfg.unquotedCasing());
this.properties.put(InternalProperty.QUOTED_CASING, cfg.quotedCasing());
this.properties.put(InternalProperty.QUOTING, cfg.quoting());
}
示例7: populateMaterializationsAndLattice
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
private void populateMaterializationsAndLattice(
QuarkMaterializeCluster.RelOptPlannerHolder plannerHolder,
CalciteSchema rootSchema) {
if (materializations == null) {
materializations =
MaterializationService.instance().query(rootSchema);
}
Materializer materializer = new Materializer(materializations);
materializer.populateMaterializations(context.getPrepareContext(), plannerHolder);
List<CalciteSchema.LatticeEntry> lattices = Schemas.getLatticeEntries(rootSchema);
for (CalciteSchema.LatticeEntry lattice : lattices) {
final CalciteSchema.TableEntry starTable = lattice.getStarTable();
final JavaTypeFactory typeFactory = context.getTypeFactory();
final RelOptTableImpl starRelOptTable =
RelOptTableImpl.create(catalogReader,
starTable.getTable().getRowType(typeFactory), starTable, null);
plannerHolder.getPlanner().addLattice(
new RelOptLattice(lattice.getLattice(), starRelOptTable));
}
}
示例8: parse_
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
/** Shared implementation for {@link #parse}, {@link #convert} and
* {@link #analyzeView}. */
private ParseResult parse_(Context context, String sql, boolean convert,
boolean analyze, boolean fail) {
final JavaTypeFactory typeFactory = context.getTypeFactory();
CalciteCatalogReader catalogReader =
new CalciteCatalogReader(
context.getRootSchema(),
context.config().caseSensitive(),
context.getDefaultSchemaPath(),
typeFactory);
SqlParser parser = createParser(sql);
SqlNode sqlNode;
try {
sqlNode = parser.parseStmt();
} catch (SqlParseException e) {
throw new RuntimeException("parse failed", e);
}
final SqlValidator validator = createSqlValidator(context, catalogReader);
SqlNode sqlNode1 = validator.validate(sqlNode);
if (convert) {
return convert_(
context, sql, analyze, fail, catalogReader, validator, sqlNode1);
}
return new ParseResult(this, validator, sql, sqlNode1,
validator.getValidatedNodeType(sqlNode1));
}
示例9: perform
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
/** Executes a prepare action. */
public <R> R perform(CalciteServerStatement statement,
Frameworks.PrepareAction<R> action) {
final CalcitePrepare.Context prepareContext =
statement.createPrepareContext();
final JavaTypeFactory typeFactory = prepareContext.getTypeFactory();
final CalciteSchema schema =
action.getConfig().getDefaultSchema() != null
? CalciteSchema.from(action.getConfig().getDefaultSchema())
: prepareContext.getRootSchema();
CalciteCatalogReader catalogReader =
new CalciteCatalogReader(schema.root(),
prepareContext.config().caseSensitive(),
schema.path(null),
typeFactory);
final RexBuilder rexBuilder = new RexBuilder(typeFactory);
final RelOptPlanner planner =
createPlanner(prepareContext,
action.getConfig().getContext(),
action.getConfig().getCostFactory());
final RelOptCluster cluster = createCluster(planner, rexBuilder);
return action.apply(cluster, catalogReader,
prepareContext.getRootSchema().plus(), statement);
}
示例10: implement
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
public void implement(Implementor implementor) {
implementor.visitChild(0, getInput());
final MongoRules.RexToMongoTranslator translator =
new MongoRules.RexToMongoTranslator(
(JavaTypeFactory) getCluster().getTypeFactory(),
MongoRules.mongoFieldNames(getInput().getRowType()));
final List<String> items = new ArrayList<String>();
for (Pair<RexNode, String> pair : getNamedProjects()) {
final String name = pair.right;
final String expr = pair.left.accept(translator);
items.add(expr.equals("'$" + name + "'")
? MongoRules.maybeQuote(name) + ": 1"
: MongoRules.maybeQuote(name) + ": " + expr);
}
final String findString = Util.toString(items, "{", ", ", "}");
final String aggregateString = "{$project: " + findString + "}";
final Pair<String, String> op = Pair.of(findString, aggregateString);
implementor.add(op.left, op.right);
}
示例11: CalciteConnectionImpl
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
/**
* Creates a CalciteConnectionImpl.
*
* <p>Not public; method is called only from the driver.</p>
*
* @param driver Driver
* @param factory Factory for JDBC objects
* @param url Server URL
* @param info Other connection properties
* @param rootSchema Root schema, or null
* @param typeFactory Type factory, or null
*/
protected CalciteConnectionImpl(Driver driver, AvaticaFactory factory,
String url, Properties info, CalciteSchema rootSchema,
JavaTypeFactory typeFactory) {
super(driver, factory, url, info);
CalciteConnectionConfig cfg = new CalciteConnectionConfigImpl(info);
this.prepareFactory = driver.prepareFactory;
if (typeFactory != null) {
this.typeFactory = typeFactory;
} else {
final RelDataTypeSystem typeSystem =
cfg.typeSystem(RelDataTypeSystem.class, RelDataTypeSystem.DEFAULT);
this.typeFactory = new JavaTypeFactoryImpl(typeSystem);
}
this.rootSchema =
Preconditions.checkNotNull(rootSchema != null
? rootSchema
: CalciteSchema.createRootSchema(true));
Preconditions.checkArgument(this.rootSchema.isRoot(), "must be root schema");
this.properties.put(InternalProperty.CASE_SENSITIVE, cfg.caseSensitive());
this.properties.put(InternalProperty.UNQUOTED_CASING, cfg.unquotedCasing());
this.properties.put(InternalProperty.QUOTED_CASING, cfg.quotedCasing());
this.properties.put(InternalProperty.QUOTING, cfg.quoting());
}
示例12: parse_
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
/** Shared implementation for {@link #parse}, {@link #convert} and
* {@link #analyzeView}. */
private ParseResult parse_(Context context, String sql, boolean convert,
boolean analyze, boolean fail) {
final JavaTypeFactory typeFactory = context.getTypeFactory();
CalciteCatalogReader catalogReader =
new CalciteCatalogReader(
context.getRootSchema(),
context.getDefaultSchemaPath(),
typeFactory,
context.config());
SqlParser parser = createParser(sql);
SqlNode sqlNode;
try {
sqlNode = parser.parseStmt();
} catch (SqlParseException e) {
throw new RuntimeException("parse failed", e);
}
final SqlValidator validator = createSqlValidator(context, catalogReader);
SqlNode sqlNode1 = validator.validate(sqlNode);
if (convert) {
return convert_(
context, sql, analyze, fail, catalogReader, validator, sqlNode1);
}
return new ParseResult(this, validator, sql, sqlNode1,
validator.getValidatedNodeType(sqlNode1));
}
示例13: perform
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
/** Executes a prepare action. */
public <R> R perform(CalciteServerStatement statement,
Frameworks.PrepareAction<R> action) {
final CalcitePrepare.Context prepareContext =
statement.createPrepareContext();
final JavaTypeFactory typeFactory = prepareContext.getTypeFactory();
final CalciteSchema schema =
action.getConfig().getDefaultSchema() != null
? CalciteSchema.from(action.getConfig().getDefaultSchema())
: prepareContext.getRootSchema();
CalciteCatalogReader catalogReader =
new CalciteCatalogReader(schema.root(),
schema.path(null),
typeFactory,
prepareContext.config());
final RexBuilder rexBuilder = new RexBuilder(typeFactory);
final RelOptPlanner planner =
createPlanner(prepareContext,
action.getConfig().getContext(),
action.getConfig().getCostFactory());
final RelOptCluster cluster = createCluster(planner, rexBuilder);
return action.apply(cluster, catalogReader,
prepareContext.getRootSchema().plus(), statement);
}
示例14: ColumnLoader
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
/** Creates a column loader, and performs the load.
*
* @param typeFactory Type factory
* @param sourceTable Source data
* @param protoRowType Logical row type
* @param repList Physical row types, or null if not known */
ColumnLoader(JavaTypeFactory typeFactory,
Enumerable<T> sourceTable,
RelProtoDataType protoRowType,
List<ColumnMetaData.Rep> repList) {
this.typeFactory = typeFactory;
final RelDataType rowType = protoRowType.apply(typeFactory);
if (repList == null) {
repList =
Collections.nCopies(rowType.getFieldCount(),
ColumnMetaData.Rep.OBJECT);
}
sourceTable.into(list);
final int[] sorts = {-1};
load(rowType, repList, sorts);
this.sortField = sorts[0];
}
示例15: RexToLixTranslator
import org.apache.calcite.adapter.java.JavaTypeFactory; //导入依赖的package包/类
private RexToLixTranslator(
RexProgram program,
JavaTypeFactory typeFactory,
Expression root,
InputGetter inputGetter,
BlockBuilder list,
Map<? extends RexNode, Boolean> exprNullableMap,
RexBuilder builder,
RexToLixTranslator parent,
Function1<String, InputGetter> correlates) {
this.program = program;
this.typeFactory = typeFactory;
this.root = root;
this.inputGetter = inputGetter;
this.list = list;
this.exprNullableMap = exprNullableMap;
this.builder = builder;
this.parent = parent;
this.correlates = correlates;
}