use of com.facebook.presto.spi.type.ParametricType in project presto by prestodb.
the class PluginManager method installPlugin.
public void installPlugin(Plugin plugin) {
for (BlockEncodingFactory<?> blockEncodingFactory : plugin.getBlockEncodingFactories(blockEncodingManager)) {
log.info("Registering block encoding %s", blockEncodingFactory.getName());
blockEncodingManager.addBlockEncodingFactory(blockEncodingFactory);
}
for (Type type : plugin.getTypes()) {
log.info("Registering type %s", type.getTypeSignature());
typeRegistry.addType(type);
}
for (ParametricType parametricType : plugin.getParametricTypes()) {
log.info("Registering parametric type %s", parametricType.getName());
typeRegistry.addParametricType(parametricType);
}
for (ConnectorFactory connectorFactory : plugin.getConnectorFactories()) {
log.info("Registering connector %s", connectorFactory.getName());
connectorManager.addConnectorFactory(connectorFactory);
}
for (Class<?> functionClass : plugin.getFunctions()) {
log.info("Registering functions from %s", functionClass.getName());
metadata.addFunctions(extractFunctions(functionClass));
}
for (ResourceGroupConfigurationManagerFactory configurationManagerFactory : plugin.getResourceGroupConfigurationManagerFactories()) {
log.info("Registering resource group configuration manager %s", configurationManagerFactory.getName());
resourceGroupManager.addConfigurationManagerFactory(configurationManagerFactory);
}
for (SystemAccessControlFactory accessControlFactory : plugin.getSystemAccessControlFactories()) {
log.info("Registering system access control %s", accessControlFactory.getName());
accessControlManager.addSystemAccessControlFactory(accessControlFactory);
}
for (EventListenerFactory eventListenerFactory : plugin.getEventListenerFactories()) {
log.info("Registering event listener %s", eventListenerFactory.getName());
eventListenerManager.addEventListenerFactory(eventListenerFactory);
}
}
use of com.facebook.presto.spi.type.ParametricType in project presto by prestodb.
the class TestMLQueries method createLocalQueryRunner.
private static LocalQueryRunner createLocalQueryRunner() {
Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).build();
LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
// add the tpch catalog
// local queries run directly against the generator
localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
MLPlugin plugin = new MLPlugin();
for (Type type : plugin.getTypes()) {
localQueryRunner.getTypeManager().addType(type);
}
for (ParametricType parametricType : plugin.getParametricTypes()) {
localQueryRunner.getTypeManager().addParametricType(parametricType);
}
localQueryRunner.getMetadata().addFunctions(extractFunctions(new MLPlugin().getFunctions()));
return localQueryRunner;
}
use of com.facebook.presto.spi.type.ParametricType in project presto by prestodb.
the class TypesJdbcTable method addParametricTypeRows.
private static void addParametricTypeRows(Builder builder, Collection<ParametricType> types) {
for (ParametricType type : types) {
String typeName = type.getName();
builder.addRow(typeName, typeName.equalsIgnoreCase("array") ? Types.ARRAY : Types.JAVA_OBJECT, null, null, null, null, DatabaseMetaData.typeNullable, false, DatabaseMetaData.typePredNone, null, false, null, null, 0, 0, null, null, null);
}
}
use of com.facebook.presto.spi.type.ParametricType in project presto by prestodb.
the class TypeRegistry method instantiateParametricType.
private Type instantiateParametricType(TypeSignature signature) {
List<TypeParameter> parameters = new ArrayList<>();
for (TypeSignatureParameter parameter : signature.getParameters()) {
TypeParameter typeParameter = TypeParameter.of(parameter, this);
if (typeParameter == null) {
return null;
}
parameters.add(typeParameter);
}
ParametricType parametricType = parametricTypes.get(signature.getBase().toLowerCase(Locale.ENGLISH));
if (parametricType == null) {
return null;
}
try {
Type instantiatedType = parametricType.createType(parameters);
//checkState(instantiatedType.equalsSignature(signature), "Instantiated parametric type name (%s) does not match expected name (%s)", instantiatedType, signature);
return instantiatedType;
} catch (IllegalArgumentException e) {
// TODO: check whether a type constructor actually exists rather than failing when it doesn't. This will be possible in the next version of the type system
return null;
}
}
Aggregations