Search in sources :

Example 1 with Language

use of com.facebook.presto.spi.function.RoutineCharacteristics.Language in project presto by prestodb.

the class GrpcSqlFunctionExecutionModule method setup.

@Override
protected void setup(Binder binder) {
    ImmutableMap.Builder<Language, GrpcSqlFunctionExecutionConfig> grpcUdfConfigBuilder = ImmutableMap.builder();
    for (Map.Entry<String, FunctionImplementationType> entry : supportedLanguages.entrySet()) {
        String languageName = entry.getKey();
        Language language = new Language(languageName);
        FunctionImplementationType implementationType = entry.getValue();
        if (implementationType.equals(GRPC)) {
            grpcUdfConfigBuilder.put(language, buildConfigObject(GrpcSqlFunctionExecutionConfig.class, languageName));
        }
    }
    Map<Language, GrpcSqlFunctionExecutionConfig> grpcUdfConfigs = grpcUdfConfigBuilder.build();
    if (grpcUdfConfigs.isEmpty()) {
        binder.bind(SqlFunctionExecutor.class).to(NoopSqlFunctionExecutor.class).in(Scopes.SINGLETON);
        return;
    }
    binder.bind(SqlFunctionExecutor.class).to(GrpcSqlFunctionExecutor.class).in(Scopes.SINGLETON);
    binder.bind(new TypeLiteral<Map<Language, GrpcSqlFunctionExecutionConfig>>() {
    }).toInstance(grpcUdfConfigs);
}
Also used : Language(com.facebook.presto.spi.function.RoutineCharacteristics.Language) NoopSqlFunctionExecutor(com.facebook.presto.functionNamespace.execution.NoopSqlFunctionExecutor) TypeLiteral(com.google.inject.TypeLiteral) FunctionImplementationType(com.facebook.presto.spi.function.FunctionImplementationType) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with Language

use of com.facebook.presto.spi.function.RoutineCharacteristics.Language in project presto by prestodb.

the class SimpleAddressSqlFunctionExecutorsModule method setup.

@Override
protected void setup(Binder binder) {
    SqlInvokedFunctionNamespaceManagerConfig config = buildConfigObject(SqlInvokedFunctionNamespaceManagerConfig.class);
    ImmutableMap.Builder<Language, FunctionImplementationType> languageImplementationTypeMap = ImmutableMap.builder();
    ImmutableMap.Builder<String, FunctionImplementationType> supportedLanguages = ImmutableMap.builder();
    for (String languageName : config.getSupportedFunctionLanguages()) {
        Language language = new Language(languageName);
        FunctionImplementationType implementationType = buildConfigObject(SqlFunctionLanguageConfig.class, languageName).getFunctionImplementationType();
        languageImplementationTypeMap.put(language, implementationType);
        supportedLanguages.put(languageName, implementationType);
    }
    // for SqlFunctionExecutor
    sqlFunctionExecutorModule.setSupportedLanguages(supportedLanguages.build());
    install(sqlFunctionExecutorModule);
    // for SqlFunctionExecutors
    binder.bind(SqlFunctionExecutors.class).in(SINGLETON);
    binder.bind(new TypeLiteral<Map<Language, FunctionImplementationType>>() {
    }).toInstance(languageImplementationTypeMap.build());
}
Also used : Language(com.facebook.presto.spi.function.RoutineCharacteristics.Language) TypeLiteral(com.google.inject.TypeLiteral) FunctionImplementationType(com.facebook.presto.spi.function.FunctionImplementationType) SqlInvokedFunctionNamespaceManagerConfig(com.facebook.presto.functionNamespace.SqlInvokedFunctionNamespaceManagerConfig) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 3 with Language

use of com.facebook.presto.spi.function.RoutineCharacteristics.Language in project presto by prestodb.

the class SimpleAddressThriftSqlFunctionExecutionModule method setup.

@Override
protected void setup(Binder binder) {
    ImmutableMap.Builder<Language, SimpleAddressSelectorConfig> thriftConfigBuilder = ImmutableMap.builder();
    ImmutableMap.Builder<Language, ThriftSqlFunctionExecutionConfig> thriftExecutionConfigs = ImmutableMap.builder();
    for (Map.Entry<String, FunctionImplementationType> entry : supportedLanguages.entrySet()) {
        String languageName = entry.getKey();
        Language language = new Language(languageName);
        FunctionImplementationType implementationType = entry.getValue();
        if (implementationType.equals(THRIFT)) {
            thriftConfigBuilder.put(language, buildConfigObject(SimpleAddressSelectorConfig.class, languageName));
            thriftExecutionConfigs.put(language, buildConfigObject(ThriftSqlFunctionExecutionConfig.class, languageName));
        }
    }
    Map<Language, SimpleAddressSelectorConfig> thriftConfigs = thriftConfigBuilder.build();
    if (thriftConfigs.isEmpty()) {
        binder.bind(SqlFunctionExecutor.class).to(NoopSqlFunctionExecutor.class).in(Scopes.SINGLETON);
        return;
    }
    binder.bind(SqlFunctionExecutor.class).to(ThriftSqlFunctionExecutor.class).in(Scopes.SINGLETON);
    driftClientBinder(binder).bindDriftClient(ThriftUdfService.class).withAddressSelector(contextualSimpleAddressSelector(thriftConfigs.entrySet().stream().collect(toImmutableMap(entry -> entry.getKey().getLanguage(), Map.Entry::getValue))));
    binder.bind(new TypeLiteral<Map<Language, ThriftSqlFunctionExecutionConfig>>() {
    }).toInstance(thriftExecutionConfigs.build());
}
Also used : DriftClientBinder.driftClientBinder(com.facebook.drift.client.guice.DriftClientBinder.driftClientBinder) ThriftUdfService(com.facebook.presto.thrift.api.udf.ThriftUdfService) SqlFunctionExecutionModule(com.facebook.presto.functionNamespace.execution.SqlFunctionExecutionModule) SqlFunctionExecutor(com.facebook.presto.spi.function.SqlFunctionExecutor) ImmutableMap(com.google.common.collect.ImmutableMap) FunctionImplementationType(com.facebook.presto.spi.function.FunctionImplementationType) Language(com.facebook.presto.spi.function.RoutineCharacteristics.Language) Scopes(com.google.inject.Scopes) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) ContextualSimpleAddressSelectorBinder.contextualSimpleAddressSelector(com.facebook.presto.functionNamespace.execution.thrift.ContextualSimpleAddressSelectorBinder.contextualSimpleAddressSelector) Binder(com.google.inject.Binder) Map(java.util.Map) NoopSqlFunctionExecutor(com.facebook.presto.functionNamespace.execution.NoopSqlFunctionExecutor) TypeLiteral(com.google.inject.TypeLiteral) THRIFT(com.facebook.presto.spi.function.FunctionImplementationType.THRIFT) SimpleAddressSelectorConfig(com.facebook.drift.client.address.SimpleAddressSelectorConfig) NoopSqlFunctionExecutor(com.facebook.presto.functionNamespace.execution.NoopSqlFunctionExecutor) SimpleAddressSelectorConfig(com.facebook.drift.client.address.SimpleAddressSelectorConfig) ThriftUdfService(com.facebook.presto.thrift.api.udf.ThriftUdfService) ImmutableMap(com.google.common.collect.ImmutableMap) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) Language(com.facebook.presto.spi.function.RoutineCharacteristics.Language) TypeLiteral(com.google.inject.TypeLiteral) FunctionImplementationType(com.facebook.presto.spi.function.FunctionImplementationType) ImmutableMap(com.google.common.collect.ImmutableMap) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) Map(java.util.Map)

Aggregations

FunctionImplementationType (com.facebook.presto.spi.function.FunctionImplementationType)3 Language (com.facebook.presto.spi.function.RoutineCharacteristics.Language)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 TypeLiteral (com.google.inject.TypeLiteral)3 NoopSqlFunctionExecutor (com.facebook.presto.functionNamespace.execution.NoopSqlFunctionExecutor)2 Map (java.util.Map)2 SimpleAddressSelectorConfig (com.facebook.drift.client.address.SimpleAddressSelectorConfig)1 DriftClientBinder.driftClientBinder (com.facebook.drift.client.guice.DriftClientBinder.driftClientBinder)1 SqlInvokedFunctionNamespaceManagerConfig (com.facebook.presto.functionNamespace.SqlInvokedFunctionNamespaceManagerConfig)1 SqlFunctionExecutionModule (com.facebook.presto.functionNamespace.execution.SqlFunctionExecutionModule)1 ContextualSimpleAddressSelectorBinder.contextualSimpleAddressSelector (com.facebook.presto.functionNamespace.execution.thrift.ContextualSimpleAddressSelectorBinder.contextualSimpleAddressSelector)1 THRIFT (com.facebook.presto.spi.function.FunctionImplementationType.THRIFT)1 SqlFunctionExecutor (com.facebook.presto.spi.function.SqlFunctionExecutor)1 ThriftUdfService (com.facebook.presto.thrift.api.udf.ThriftUdfService)1 ImmutableMap.toImmutableMap (com.google.common.collect.ImmutableMap.toImmutableMap)1 Binder (com.google.inject.Binder)1 Scopes (com.google.inject.Scopes)1