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