Search in sources :

Example 1 with ParametricType

use of io.prestosql.spi.type.ParametricType in project hetu-core by openlookeng.

the class PluginManager method installPlugin.

public void installPlugin(Plugin plugin) {
    for (BlockEncoding blockEncoding : plugin.getBlockEncodings()) {
        log.info("Registering block encoding %s", blockEncoding.getName());
        metadataManager.getFunctionAndTypeManager().addBlockEncoding(blockEncoding);
    }
    for (Type type : plugin.getTypes()) {
        log.info("Registering type %s", type.getTypeSignature());
        metadataManager.getFunctionAndTypeManager().addType(type);
    }
    for (ParametricType parametricType : plugin.getParametricTypes()) {
        log.info("Registering parametric type %s", parametricType.getName());
        metadataManager.getFunctionAndTypeManager().addParametricType(parametricType);
    }
    for (ConnectorFactory connectorFactory : plugin.getConnectorFactories()) {
        log.info("Registering connector %s", connectorFactory.getName());
        connectorManager.addConnectorFactory(connectorFactory);
        ConnectorCache.addCatalogConfig(plugin, connectorFactory.getName());
    }
    for (SessionPropertyConfigurationManagerFactory sessionConfigFactory : plugin.getSessionPropertyConfigurationManagerFactories()) {
        log.info("Registering session property configuration manager %s", sessionConfigFactory.getName());
        sessionPropertyDefaults.addConfigurationManagerFactory(sessionConfigFactory);
    }
    for (FunctionNamespaceManagerFactory functionNamespaceManagerFactory : plugin.getFunctionNamespaceManagerFactories()) {
        log.info("Registering function namespace manager %s", functionNamespaceManagerFactory.getName());
        metadataManager.getFunctionAndTypeManager().addFunctionNamespaceFactory(functionNamespaceManagerFactory);
    }
    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 (PasswordAuthenticatorFactory authenticatorFactory : plugin.getPasswordAuthenticatorFactories()) {
        log.info("Registering password authenticator %s", authenticatorFactory.getName());
        passwordAuthenticatorManager.addPasswordAuthenticatorFactory(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);
    }
    // Install StateStorePlugin
    for (StateStoreBootstrapper bootstrapper : plugin.getStateStoreBootstrappers()) {
        log.info("Registering  state store bootstrapper");
        stateStoreLauncher.addStateStoreBootstrapper(bootstrapper);
    }
    for (StateStoreFactory stateStoreFactory : plugin.getStateStoreFactories()) {
        log.info("Registering state store %s", stateStoreFactory.getName());
        localStateStoreProvider.addStateStoreFactory(stateStoreFactory);
    }
    for (SeedStoreFactory seedStoreFactory : plugin.getSeedStoreFactories()) {
        log.info("Registering seed store %s", seedStoreFactory.getName());
        seedStoreManager.addSeedStoreFactory(seedStoreFactory);
    }
    for (CubeProvider cubeProvider : plugin.getCubeProviders()) {
        log.info("Registering cube provider %s", cubeProvider.getName());
        cubeManager.addCubeProvider(cubeProvider);
    }
    for (HetuFileSystemClientFactory fileSystemClientFactory : plugin.getFileSystemClientFactory()) {
        log.info("Registering file system provider %s", fileSystemClientFactory.getName());
        fileSystemClientManager.addFileSystemClientFactories(fileSystemClientFactory);
    }
    for (HetuMetaStoreFactory hetuMetaStoreFactory : plugin.getHetuMetaStoreFactories()) {
        log.info("Registering hetu metastore %s", hetuMetaStoreFactory.getName());
        hetuMetaStoreManager.addHetuMetaStoreFactory(hetuMetaStoreFactory);
    }
    for (IndexFactory indexFactory : plugin.getIndexFactories()) {
        log.info("Loading index factory");
        heuristicIndexerManager.loadIndexFactories(indexFactory);
    }
    installFunctionsPlugin(plugin);
}
Also used : ResourceGroupConfigurationManagerFactory(io.prestosql.spi.resourcegroups.ResourceGroupConfigurationManagerFactory) EventListenerFactory(io.prestosql.spi.eventlistener.EventListenerFactory) HetuFileSystemClientFactory(io.prestosql.spi.filesystem.HetuFileSystemClientFactory) SeedStoreFactory(io.prestosql.spi.seedstore.SeedStoreFactory) SystemAccessControlFactory(io.prestosql.spi.security.SystemAccessControlFactory) ParametricType(io.prestosql.spi.type.ParametricType) Type(io.prestosql.spi.type.Type) PasswordAuthenticatorFactory(io.prestosql.spi.security.PasswordAuthenticatorFactory) ConnectorFactory(io.prestosql.spi.connector.ConnectorFactory) IndexFactory(io.prestosql.spi.heuristicindex.IndexFactory) HetuMetaStoreFactory(io.prestosql.spi.metastore.HetuMetaStoreFactory) ParametricType(io.prestosql.spi.type.ParametricType) CubeProvider(io.prestosql.spi.cube.CubeProvider) FunctionNamespaceManagerFactory(io.prestosql.spi.function.FunctionNamespaceManagerFactory) SessionPropertyConfigurationManagerFactory(io.prestosql.spi.session.SessionPropertyConfigurationManagerFactory) BlockEncoding(io.prestosql.spi.block.BlockEncoding) GroupProviderFactory(io.prestosql.spi.security.GroupProviderFactory) StateStoreBootstrapper(io.prestosql.spi.statestore.StateStoreBootstrapper) StateStoreFactory(io.prestosql.spi.statestore.StateStoreFactory)

Example 2 with ParametricType

use of io.prestosql.spi.type.ParametricType in project hetu-core by openlookeng.

the class BuiltInTypeRegistry method instantiateParametricType.

private Type instantiateParametricType(TypeManager typeManager, 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);
    }
    // TODO: reimplement this check? Currently "varchar(Integer.MAX_VALUE)" fails with "varchar"
    return instantiatedType;
}
Also used : TypeParameter(io.prestosql.spi.type.TypeParameter) Re2JRegexpType(io.prestosql.type.Re2JRegexpType) DecimalType(io.prestosql.spi.type.DecimalType) ColorType(io.prestosql.type.ColorType) ParametricType(io.prestosql.spi.type.ParametricType) RowType(io.prestosql.spi.type.RowType) Type(io.prestosql.spi.type.Type) DecimalType.createDecimalType(io.prestosql.spi.type.DecimalType.createDecimalType) LikePatternType(io.prestosql.spi.type.LikePatternType) ArrayType(io.prestosql.spi.type.ArrayType) CharType.createCharType(io.prestosql.spi.type.CharType.createCharType) VarcharType.createVarcharType(io.prestosql.spi.type.VarcharType.createVarcharType) VarcharType.createUnboundedVarcharType(io.prestosql.spi.type.VarcharType.createUnboundedVarcharType) CharParametricType(io.prestosql.spi.type.CharParametricType) VarcharParametricType(io.prestosql.spi.type.VarcharParametricType) UnknownType(io.prestosql.spi.type.UnknownType) CharType(io.prestosql.spi.type.CharType) JoniRegexpType(io.prestosql.type.JoniRegexpType) CodePointsType(io.prestosql.type.CodePointsType) MapType(io.prestosql.spi.type.MapType) JsonPathType(io.prestosql.type.JsonPathType) SetDigestType(io.prestosql.type.setdigest.SetDigestType) DecimalParametricType(io.prestosql.spi.type.DecimalParametricType) VarcharType(io.prestosql.spi.type.VarcharType) TypeSignatureParameter(io.prestosql.spi.type.TypeSignatureParameter) TypeNotFoundException(io.prestosql.spi.type.TypeNotFoundException) ArrayList(java.util.ArrayList) ParametricType(io.prestosql.spi.type.ParametricType) CharParametricType(io.prestosql.spi.type.CharParametricType) VarcharParametricType(io.prestosql.spi.type.VarcharParametricType) DecimalParametricType(io.prestosql.spi.type.DecimalParametricType)

Example 3 with ParametricType

use of io.prestosql.spi.type.ParametricType in project hetu-core by openlookeng.

the class TypeUtil method parametricType.

private static Type parametricType(TypeManager typeManager, TypeSignature typeSignature) {
    String typeName = typeSignature.getBase().toLowerCase(Locale.ENGLISH);
    ParametricType parametricType = PARAMETRIC_TYPE_MAP.get(typeName);
    if (parametricType != null) {
        List<TypeParameter> parameters = new ArrayList<>();
        for (TypeSignatureParameter parameter : typeSignature.getParameters()) {
            TypeParameter typeParameter = TypeParameter.of(parameter, typeManager);
            parameters.add(typeParameter);
        }
        return parametricType.createType(typeManager, parameters);
    }
    return null;
}
Also used : TypeParameter(io.prestosql.spi.type.TypeParameter) TypeSignatureParameter(io.prestosql.spi.type.TypeSignatureParameter) ArrayList(java.util.ArrayList) ParametricType(io.prestosql.spi.type.ParametricType)

Example 4 with ParametricType

use of io.prestosql.spi.type.ParametricType in project hetu-core by openlookeng.

the class TypeUtil method parseType.

/**
 * Parse type type.
 *
 * @param typeManager the type manager.
 * @param typeName the type name
 * @return the type
 */
public static Type parseType(TypeManager typeManager, String typeName) {
    Type hetuType = null;
    Matcher matcher = DESCRIBE_TYPE_PATTERN.matcher(typeName);
    if (matcher.matches()) {
        String type = matcher.group("type");
        hetuType = typeMapping(type);
    }
    if (hetuType == null) {
        TypeSignature typeSignature = TypeSignature.parseTypeSignature(typeName);
        hetuType = parametricType(typeManager, typeSignature);
    }
    if (hetuType == null) {
        throw new IllegalArgumentException("Type " + typeName + " is not supported");
    }
    return hetuType;
}
Also used : ParametricType(io.prestosql.spi.type.ParametricType) Type(io.prestosql.spi.type.Type) TypeSignature(io.prestosql.spi.type.TypeSignature) Matcher(java.util.regex.Matcher)

Aggregations

ParametricType (io.prestosql.spi.type.ParametricType)4 Type (io.prestosql.spi.type.Type)3 TypeParameter (io.prestosql.spi.type.TypeParameter)2 TypeSignatureParameter (io.prestosql.spi.type.TypeSignatureParameter)2 BlockEncoding (io.prestosql.spi.block.BlockEncoding)1 ConnectorFactory (io.prestosql.spi.connector.ConnectorFactory)1 CubeProvider (io.prestosql.spi.cube.CubeProvider)1 EventListenerFactory (io.prestosql.spi.eventlistener.EventListenerFactory)1 HetuFileSystemClientFactory (io.prestosql.spi.filesystem.HetuFileSystemClientFactory)1 FunctionNamespaceManagerFactory (io.prestosql.spi.function.FunctionNamespaceManagerFactory)1 IndexFactory (io.prestosql.spi.heuristicindex.IndexFactory)1 HetuMetaStoreFactory (io.prestosql.spi.metastore.HetuMetaStoreFactory)1 ResourceGroupConfigurationManagerFactory (io.prestosql.spi.resourcegroups.ResourceGroupConfigurationManagerFactory)1 GroupProviderFactory (io.prestosql.spi.security.GroupProviderFactory)1 PasswordAuthenticatorFactory (io.prestosql.spi.security.PasswordAuthenticatorFactory)1 SystemAccessControlFactory (io.prestosql.spi.security.SystemAccessControlFactory)1 SeedStoreFactory (io.prestosql.spi.seedstore.SeedStoreFactory)1 SessionPropertyConfigurationManagerFactory (io.prestosql.spi.session.SessionPropertyConfigurationManagerFactory)1 StateStoreBootstrapper (io.prestosql.spi.statestore.StateStoreBootstrapper)1 StateStoreFactory (io.prestosql.spi.statestore.StateStoreFactory)1