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());
}
Aggregations