Search in sources :

Example 1 with SimpleAddressSelectorConfig

use of com.facebook.drift.client.address.SimpleAddressSelectorConfig 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

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