本文整理汇总了Java中org.apache.calcite.avatica.AvaticaUtils.instantiatePlugin方法的典型用法代码示例。如果您正苦于以下问题:Java AvaticaUtils.instantiatePlugin方法的具体用法?Java AvaticaUtils.instantiatePlugin怎么用?Java AvaticaUtils.instantiatePlugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.avatica.AvaticaUtils
的用法示例。
在下文中一共展示了AvaticaUtils.instantiatePlugin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseDataSource
import org.apache.calcite.avatica.AvaticaUtils; //导入方法依赖的package包/类
private static DataSource parseDataSource(Map<String, Object> operand) throws IOException {
final String connection = (String) operand.get("connection");
Map<String, Object> jdbcConfig;
if (connection != null) {
try (InputStream connConfig = ClassLoader.getSystemResourceAsStream(connection)) {
jdbcConfig = new ObjectMapper().readValue(
connConfig,
new TypeReference<Map<String, Object>>(){}
);
}
} else {
jdbcConfig = operand;
}
final String dataSourceName = (String) jdbcConfig.get("dataSource");
if (dataSourceName != null) {
return AvaticaUtils.instantiatePlugin(DataSource.class, dataSourceName);
}
final String jdbcUrl = (String) jdbcConfig.get("jdbcUrl");
final String jdbcDriver = (String) jdbcConfig.get("jdbcDriver");
final String jdbcUser = (String) jdbcConfig.get("jdbcUser");
final String jdbcPassword = (String) jdbcConfig.get("jdbcPassword");
return dataSource(jdbcUrl, jdbcDriver, jdbcUser, jdbcPassword);
}
示例2: toOp
import org.apache.calcite.avatica.AvaticaUtils; //导入方法依赖的package包/类
private SqlOperator toOp(String op, Map<String, Object> map) {
// TODO: build a map, for more efficient lookup
// TODO: look up based on SqlKind
final List<SqlOperator> operatorList =
SqlStdOperatorTable.instance().getOperatorList();
for (SqlOperator operator : operatorList) {
if (operator.getName().equals(op)) {
return operator;
}
}
String class_ = (String) map.get("class");
if (class_ != null) {
return AvaticaUtils.instantiatePlugin(SqlOperator.class, class_);
}
return null;
}
示例3: visit
import org.apache.calcite.avatica.AvaticaUtils; //导入方法依赖的package包/类
public void visit(JsonCustomSchema jsonSchema) {
try {
final SchemaPlus parentSchema = currentMutableSchema("sub-schema");
checkRequiredAttributes(jsonSchema, "name", "factory");
final SchemaFactory schemaFactory =
AvaticaUtils.instantiatePlugin(SchemaFactory.class,
jsonSchema.factory);
final Schema schema =
schemaFactory.create(
parentSchema, jsonSchema.name, operandMap(jsonSchema, jsonSchema.operand));
final SchemaPlus schemaPlus = parentSchema.add(jsonSchema.name, schema);
populateSchema(jsonSchema, schemaPlus);
} catch (Exception e) {
throw new RuntimeException("Error instantiating " + jsonSchema, e);
}
}
示例4: build
import org.apache.calcite.avatica.AvaticaUtils; //导入方法依赖的package包/类
/** Builds a lattice. */
public Lattice build() {
LatticeStatisticProvider.Factory statisticProvider =
this.statisticProvider != null
? AvaticaUtils.instantiatePlugin(
LatticeStatisticProvider.Factory.class,
this.statisticProvider)
: Lattices.CACHED_SQL;
Preconditions.checkArgument(rootSchema.isRoot(), "must be root schema");
return new Lattice(rootSchema, ImmutableList.copyOf(nodes), auto,
algorithm, algorithmMaxMillis, statisticProvider, rowCountEstimate,
columns, defaultMeasureListBuilder.build(), tileListBuilder.build());
}
示例5: create
import org.apache.calcite.avatica.AvaticaUtils; //导入方法依赖的package包/类
/**
* Creates a JdbcSchema, taking credentials from a map.
*
* @param parentSchema Parent schema
* @param name Name
* @param operand Map of property/value pairs
* @return A JdbcSchema
*/
public static JdbcSchema create(
SchemaPlus parentSchema,
String name,
Map<String, Object> operand) {
DataSource dataSource;
try {
final String dataSourceName = (String) operand.get("dataSource");
if (dataSourceName != null) {
dataSource =
AvaticaUtils.instantiatePlugin(DataSource.class, dataSourceName);
} else {
final String jdbcUrl = (String) operand.get("jdbcUrl");
final String jdbcDriver = (String) operand.get("jdbcDriver");
final String jdbcUser = (String) operand.get("jdbcUser");
final String jdbcPassword = (String) operand.get("jdbcPassword");
dataSource = dataSource(jdbcUrl, jdbcDriver, jdbcUser, jdbcPassword);
}
} catch (Exception e) {
throw new RuntimeException("Error while reading dataSource", e);
}
String jdbcCatalog = (String) operand.get("jdbcCatalog");
String jdbcSchema = (String) operand.get("jdbcSchema");
String sqlDialectFactory = (String) operand.get("sqlDialectFactory");
if (sqlDialectFactory == null || sqlDialectFactory.isEmpty()) {
return JdbcSchema.create(
parentSchema, name, dataSource, jdbcCatalog, jdbcSchema);
} else {
SqlDialectFactory factory = AvaticaUtils.instantiatePlugin(
SqlDialectFactory.class, sqlDialectFactory);
return JdbcSchema.create(
parentSchema, name, dataSource, factory, jdbcCatalog, jdbcSchema);
}
}