Search in sources :

Example 1 with ParametricType

use of io.trino.spi.type.ParametricType in project trino by trinodb.

the class PluginManager method installPluginInternal.

private void installPluginInternal(Plugin plugin, Function<CatalogName, ClassLoader> duplicatePluginClassLoaderFactory) {
    for (BlockEncoding blockEncoding : plugin.getBlockEncodings()) {
        log.info("Registering block encoding %s", blockEncoding.getName());
        blockEncodingManager.addBlockEncoding(blockEncoding);
    }
    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, duplicatePluginClassLoaderFactory);
    }
    Set<Class<?>> functions = plugin.getFunctions();
    if (!functions.isEmpty()) {
        log.info("Registering functions from %s", plugin.getClass().getSimpleName());
        InternalFunctionBundleBuilder builder = InternalFunctionBundle.builder();
        functions.forEach(builder::functions);
        globalFunctionCatalog.addFunctions(builder.build());
    }
    for (SessionPropertyConfigurationManagerFactory sessionConfigFactory : plugin.getSessionPropertyConfigurationManagerFactories()) {
        log.info("Registering session property configuration manager %s", sessionConfigFactory.getName());
        sessionPropertyDefaults.addConfigurationManagerFactory(sessionConfigFactory);
    }
    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);
    }
    passwordAuthenticatorManager.ifPresent(authenticationManager -> {
        for (PasswordAuthenticatorFactory authenticatorFactory : plugin.getPasswordAuthenticatorFactories()) {
            log.info("Registering password authenticator %s", authenticatorFactory.getName());
            authenticationManager.addPasswordAuthenticatorFactory(authenticatorFactory);
        }
    });
    for (CertificateAuthenticatorFactory authenticatorFactory : plugin.getCertificateAuthenticatorFactories()) {
        log.info("Registering certificate authenticator %s", authenticatorFactory.getName());
        certificateAuthenticatorManager.addCertificateAuthenticatorFactory(authenticatorFactory);
    }
    headerAuthenticatorManager.ifPresent(authenticationManager -> {
        for (HeaderAuthenticatorFactory authenticatorFactory : plugin.getHeaderAuthenticatorFactories()) {
            log.info("Registering header authenticator %s", authenticatorFactory.getName());
            authenticationManager.addHeaderAuthenticatorFactory(authenticatorFactory);
        }
    });
    for (EventListenerFactory eventListenerFactory : plugin.getEventListenerFactories()) {
        log.info("Registering event listener %s", eventListenerFactory.getName());
        eventListenerManager.addEventListenerFactory(eventListenerFactory);
    }
    for (GroupProviderFactory groupProviderFactory : plugin.getGroupProviderFactories()) {
        log.info("Registering group provider %s", groupProviderFactory.getName());
        groupProviderManager.addGroupProviderFactory(groupProviderFactory);
    }
    for (ExchangeManagerFactory exchangeManagerFactory : plugin.getExchangeManagerFactories()) {
        log.info("Registering exchange manager %s", exchangeManagerFactory.getName());
        exchangeManagerRegistry.addExchangeManagerFactory(exchangeManagerFactory);
    }
}
Also used : ResourceGroupConfigurationManagerFactory(io.trino.spi.resourcegroups.ResourceGroupConfigurationManagerFactory) HeaderAuthenticatorFactory(io.trino.spi.security.HeaderAuthenticatorFactory) EventListenerFactory(io.trino.spi.eventlistener.EventListenerFactory) SystemAccessControlFactory(io.trino.spi.security.SystemAccessControlFactory) Type(io.trino.spi.type.Type) ParametricType(io.trino.spi.type.ParametricType) PasswordAuthenticatorFactory(io.trino.spi.security.PasswordAuthenticatorFactory) ConnectorFactory(io.trino.spi.connector.ConnectorFactory) InternalFunctionBundleBuilder(io.trino.metadata.InternalFunctionBundle.InternalFunctionBundleBuilder) ParametricType(io.trino.spi.type.ParametricType) SessionPropertyConfigurationManagerFactory(io.trino.spi.session.SessionPropertyConfigurationManagerFactory) BlockEncoding(io.trino.spi.block.BlockEncoding) CertificateAuthenticatorFactory(io.trino.spi.security.CertificateAuthenticatorFactory) GroupProviderFactory(io.trino.spi.security.GroupProviderFactory) ExchangeManagerFactory(io.trino.spi.exchange.ExchangeManagerFactory)

Example 2 with ParametricType

use of io.trino.spi.type.ParametricType in project trino by trinodb.

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, typeManager);
        parameters.add(typeParameter);
    }
    ParametricType parametricType = parametricTypes.get(signature.getBase().toLowerCase(Locale.ENGLISH));
    if (parametricType == null) {
        throw new TypeNotFoundException(signature);
    }
    Type instantiatedType;
    try {
        instantiatedType = parametricType.createType(typeManager, parameters);
    } catch (IllegalArgumentException e) {
        throw new TypeNotFoundException(signature, e);
    }
    // checkState(instantiatedType.equalsSignature(signature), "Instantiated parametric type name (%s) does not match expected name (%s)", instantiatedType, signature);
    return instantiatedType;
}
Also used : TypeParameter(io.trino.spi.type.TypeParameter) DecimalParametricType(io.trino.type.DecimalParametricType) VarcharParametricType(io.trino.type.VarcharParametricType) Re2JRegexpType(io.trino.type.Re2JRegexpType) ParametricType(io.trino.spi.type.ParametricType) Type(io.trino.spi.type.Type) CharParametricType(io.trino.type.CharParametricType) OperatorType(io.trino.spi.function.OperatorType) TypeSignatureParameter(io.trino.spi.type.TypeSignatureParameter) TypeNotFoundException(io.trino.spi.type.TypeNotFoundException) ArrayList(java.util.ArrayList) DecimalParametricType(io.trino.type.DecimalParametricType) VarcharParametricType(io.trino.type.VarcharParametricType) ParametricType(io.trino.spi.type.ParametricType) CharParametricType(io.trino.type.CharParametricType)

Aggregations

ParametricType (io.trino.spi.type.ParametricType)2 Type (io.trino.spi.type.Type)2 InternalFunctionBundleBuilder (io.trino.metadata.InternalFunctionBundle.InternalFunctionBundleBuilder)1 BlockEncoding (io.trino.spi.block.BlockEncoding)1 ConnectorFactory (io.trino.spi.connector.ConnectorFactory)1 EventListenerFactory (io.trino.spi.eventlistener.EventListenerFactory)1 ExchangeManagerFactory (io.trino.spi.exchange.ExchangeManagerFactory)1 OperatorType (io.trino.spi.function.OperatorType)1 ResourceGroupConfigurationManagerFactory (io.trino.spi.resourcegroups.ResourceGroupConfigurationManagerFactory)1 CertificateAuthenticatorFactory (io.trino.spi.security.CertificateAuthenticatorFactory)1 GroupProviderFactory (io.trino.spi.security.GroupProviderFactory)1 HeaderAuthenticatorFactory (io.trino.spi.security.HeaderAuthenticatorFactory)1 PasswordAuthenticatorFactory (io.trino.spi.security.PasswordAuthenticatorFactory)1 SystemAccessControlFactory (io.trino.spi.security.SystemAccessControlFactory)1 SessionPropertyConfigurationManagerFactory (io.trino.spi.session.SessionPropertyConfigurationManagerFactory)1 TypeNotFoundException (io.trino.spi.type.TypeNotFoundException)1 TypeParameter (io.trino.spi.type.TypeParameter)1 TypeSignatureParameter (io.trino.spi.type.TypeSignatureParameter)1 CharParametricType (io.trino.type.CharParametricType)1 DecimalParametricType (io.trino.type.DecimalParametricType)1