From 4ed601227d1a2d3aa8df887ada8cb6e3aba1caae Mon Sep 17 00:00:00 2001 From: Pratik Joseph Dabre Date: Fri, 22 Nov 2024 13:40:40 -0800 Subject: [PATCH 1/2] Add native types manager --- ...uiltInTypeAndFunctionNamespaceManager.java | 95 +---------- .../metadata/FunctionAndTypeManager.java | 54 ++++++- .../facebook/presto/server/PluginManager.java | 6 + .../facebook/presto/server/PrestoServer.java | 2 + .../facebook/presto/testing/QueryRunner.java | 5 + .../presto/sidecar/NativeSidecarPlugin.java | 8 + .../sidecar/type/NativeTypeManager.java | 153 ++++++++++++++++++ .../type/NativeTypeManagerFactory.java | 45 ++++++ .../sidecar/type/NativeTypeManagerModule.java | 49 ++++++ .../NativeSidecarPluginQueryRunnerUtils.java | 2 + .../presto/spi/CoordinatorPlugin.java | 6 + .../presto/spi/ExactTypeSignature.java | 106 ++++++++++++ .../spi/function/FunctionMetadataManager.java | 4 + .../presto/spi/type/TypeManagerContext.java | 35 ++++ .../presto/spi/type/TypeManagerFactory.java | 21 +++ .../presto/spi/type/TypeManagerInterface.java | 28 ++++ .../presto/tests/DistributedQueryRunner.java | 8 + 17 files changed, 538 insertions(+), 89 deletions(-) create mode 100644 presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManager.java create mode 100644 presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerFactory.java create mode 100644 presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerModule.java create mode 100644 presto-spi/src/main/java/com/facebook/presto/spi/ExactTypeSignature.java create mode 100644 presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerContext.java create mode 100644 presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerFactory.java create mode 100644 presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerInterface.java diff --git a/presto-main/src/main/java/com/facebook/presto/metadata/BuiltInTypeAndFunctionNamespaceManager.java b/presto-main/src/main/java/com/facebook/presto/metadata/BuiltInTypeAndFunctionNamespaceManager.java index ae76fd532db6..76397a5c7d8a 100644 --- a/presto-main/src/main/java/com/facebook/presto/metadata/BuiltInTypeAndFunctionNamespaceManager.java +++ b/presto-main/src/main/java/com/facebook/presto/metadata/BuiltInTypeAndFunctionNamespaceManager.java @@ -21,7 +21,6 @@ import com.facebook.presto.common.block.BlockSerdeUtil; import com.facebook.presto.common.function.OperatorType; import com.facebook.presto.common.function.SqlFunctionResult; -import com.facebook.presto.common.type.DistinctTypeInfo; import com.facebook.presto.common.type.ParametricType; import com.facebook.presto.common.type.Type; import com.facebook.presto.common.type.TypeManager; @@ -221,6 +220,7 @@ import com.facebook.presto.operator.window.RowNumberFunction; import com.facebook.presto.operator.window.SqlWindowFunction; import com.facebook.presto.operator.window.WindowFunctionSupplier; +import com.facebook.presto.spi.ExactTypeSignature; import com.facebook.presto.spi.PrestoException; import com.facebook.presto.spi.function.AggregationFunctionImplementation; import com.facebook.presto.spi.function.AlterRoutineCharacteristics; @@ -307,7 +307,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -1305,6 +1304,12 @@ public Collection getParametricTypes() } private Type instantiateParametricType(ExactTypeSignature exactSignature) + { + return instantiateParametricType(exactSignature, functionAndTypeManager, parametricTypes); + } + + public Type instantiateParametricType(ExactTypeSignature exactSignature, + FunctionAndTypeManager functionAndTypeManager, Map parametricTypes) { TypeSignature signature = exactSignature.getTypeSignature(); List parameters = new ArrayList<>(); @@ -1453,92 +1458,6 @@ public Collection get(QualifiedObjectName name) } } - /** - * TypeSignature but has overridden equals(). Here, we compare exact signature of any underlying distinct - * types. Some distinct types may have extra information on their lazily loaded parents, and same parent - * information is compared in equals(). This is needed to cache types in parametricTypesCache. - */ - private static class ExactTypeSignature - { - private final TypeSignature typeSignature; - - public ExactTypeSignature(TypeSignature typeSignature) - { - this.typeSignature = typeSignature; - } - - public TypeSignature getTypeSignature() - { - return typeSignature; - } - - @Override - public int hashCode() - { - return Objects.hash(typeSignature); - } - - @Override - public boolean equals(Object o) - { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - ExactTypeSignature other = (ExactTypeSignature) o; - return equals(typeSignature, other.typeSignature); - } - - private static boolean equals(TypeSignature left, TypeSignature right) - { - if (!left.equals(right)) { - return false; - } - - if (left.isDistinctType() && right.isDistinctType()) { - return equals(left.getDistinctTypeInfo(), right.getDistinctTypeInfo()); - } - int index = 0; - for (TypeSignatureParameter leftParameter : left.getParameters()) { - TypeSignatureParameter rightParameter = right.getParameters().get(index++); - if (!leftParameter.getKind().equals(rightParameter.getKind())) { - return false; - } - - switch (leftParameter.getKind()) { - case TYPE: - if (!equals(leftParameter.getTypeSignature(), rightParameter.getTypeSignature())) { - return false; - } - break; - case NAMED_TYPE: - if (!equals(leftParameter.getNamedTypeSignature().getTypeSignature(), rightParameter.getNamedTypeSignature().getTypeSignature())) { - return false; - } - break; - case DISTINCT_TYPE: - if (!equals(leftParameter.getDistinctTypeInfo(), rightParameter.getDistinctTypeInfo())) { - return false; - } - break; - } - } - return true; - } - - private static boolean equals(DistinctTypeInfo left, DistinctTypeInfo right) - { - return Objects.equals(left.getName(), right.getName()) && - Objects.equals(left.getBaseType(), right.getBaseType()) && - Objects.equals(left.isOrderable(), right.isOrderable()) && - Objects.equals(left.getTopMostAncestor(), right.getTopMostAncestor()) && - Objects.equals(left.getOtherAncestors(), right.getOtherAncestors()); - } - } - private static class MagicLiteralFunction extends SqlScalarFunction { diff --git a/presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java b/presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java index 55dcbdd2a619..889eeaa39e6c 100644 --- a/presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java +++ b/presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java @@ -33,6 +33,7 @@ import com.facebook.presto.common.type.TypeWithName; import com.facebook.presto.common.type.UserDefinedType; import com.facebook.presto.operator.window.WindowFunctionSupplier; +import com.facebook.presto.spi.ExactTypeSignature; import com.facebook.presto.spi.PrestoException; import com.facebook.presto.spi.function.AggregationFunctionImplementation; import com.facebook.presto.spi.function.AlterRoutineCharacteristics; @@ -50,6 +51,9 @@ import com.facebook.presto.spi.function.SqlFunction; import com.facebook.presto.spi.function.SqlFunctionId; import com.facebook.presto.spi.function.SqlInvokedFunction; +import com.facebook.presto.spi.type.TypeManagerContext; +import com.facebook.presto.spi.type.TypeManagerFactory; +import com.facebook.presto.spi.type.TypeManagerInterface; import com.facebook.presto.sql.analyzer.FeaturesConfig; import com.facebook.presto.sql.analyzer.FunctionAndTypeResolver; import com.facebook.presto.sql.analyzer.FunctionsConfig; @@ -122,8 +126,10 @@ public class FunctionAndTypeManager private final BuiltInTypeAndFunctionNamespaceManager builtInTypeAndFunctionNamespaceManager; private final FunctionInvokerProvider functionInvokerProvider; private final Map functionNamespaceManagerFactories = new ConcurrentHashMap<>(); + private final Map typeManagerFactories = new ConcurrentHashMap<>(); private final HandleResolver handleResolver; private final Map> functionNamespaceManagers = new ConcurrentHashMap<>(); + private final Map typeManagers = new ConcurrentHashMap<>(); private final FunctionSignatureMatcher functionSignatureMatcher; private final TypeCoercer typeCoercer; private final LoadingCache functionCache; @@ -220,6 +226,12 @@ public FunctionMetadata getFunctionMetadata(FunctionHandle functionHandle) return FunctionAndTypeManager.this.getFunctionMetadata(functionHandle); } + @Override + public Type instantiateParametricType(ExactTypeSignature exactSignature) + { + return FunctionAndTypeManager.this.instantiateParametricType(exactSignature); + } + @Override public Collection listBuiltInFunctions() { @@ -290,6 +302,14 @@ public FunctionMetadata getFunctionMetadata(FunctionHandle functionHandle) return functionNamespaceManager.get().getFunctionMetadata(functionHandle); } + @Override + public Type instantiateParametricType(ExactTypeSignature exactSignature) + { + checkState(!typeManagers.isEmpty()); + return builtInTypeAndFunctionNamespaceManager.instantiateParametricType(exactSignature, this, + typeManagers.get("native").getParametricTypes()); + } + @Override public Type getType(TypeSignature signature) { @@ -298,7 +318,13 @@ public Type getType(TypeSignature signature) if (signature.isDistinctType()) { return getDistinctType(signature.getParameters().get(0).getDistinctTypeInfo()); } - Optional type = builtInTypeAndFunctionNamespaceManager.getType(signature.getStandardTypeSignature()); + Optional type; + if (typeManagers.isEmpty()) { + type = builtInTypeAndFunctionNamespaceManager.getType(signature.getStandardTypeSignature()); + } + else { + type = typeManagers.get("native").getType(signature.getStandardTypeSignature()); + } if (type.isPresent()) { if (signature.getTypeSignatureBase().hasTypeName()) { return new TypeWithName(signature.getTypeSignatureBase().getTypeName(), type.get()); @@ -335,6 +361,32 @@ public void addFunctionNamespaceFactory(FunctionNamespaceManagerFactory factory) handleResolver.addFunctionNamespace(factory.getName(), factory.getHandleResolver()); } + public void loadTypeManager(String typeManagerName) + { + requireNonNull(typeManagerName, "typeManagerName is null"); + TypeManagerFactory factory = typeManagerFactories.get(typeManagerName); + checkState(factory != null, "No factory for type manager %s", typeManagerName); + TypeManagerInterface typeManager = factory.create(new TypeManagerContext(Optional.of(this))); + + if (typeManagers.putIfAbsent(typeManagerName, typeManager) != null) { + throw new IllegalArgumentException(format("Type manager [%s] is already registered", typeManager)); + } + } + + public void loadTypeManagers() + { + for (String typeManagerName : typeManagerFactories.keySet()) { + loadTypeManager(typeManagerName); + } + } + + public void addTypeManagerFactory(TypeManagerFactory factory) + { + if (typeManagerFactories.putIfAbsent(factory.getName(), factory) != null) { + throw new IllegalArgumentException(format("Type manager '%s' is already registered", factory.getName())); + } + } + public void registerBuiltInFunctions(List functions) { builtInTypeAndFunctionNamespaceManager.registerBuiltInFunctions(functions); diff --git a/presto-main/src/main/java/com/facebook/presto/server/PluginManager.java b/presto-main/src/main/java/com/facebook/presto/server/PluginManager.java index e71d1ee56199..6e1322245d8b 100644 --- a/presto-main/src/main/java/com/facebook/presto/server/PluginManager.java +++ b/presto-main/src/main/java/com/facebook/presto/server/PluginManager.java @@ -48,6 +48,7 @@ import com.facebook.presto.spi.tracing.TracerProvider; import com.facebook.presto.spi.ttl.ClusterTtlProviderFactory; import com.facebook.presto.spi.ttl.NodeTtlFetcherFactory; +import com.facebook.presto.spi.type.TypeManagerFactory; import com.facebook.presto.sql.analyzer.AnalyzerProviderManager; import com.facebook.presto.sql.analyzer.QueryPreparerProviderManager; import com.facebook.presto.sql.planner.sanity.PlanCheckerProviderManager; @@ -372,6 +373,11 @@ public void installCoordinatorPlugin(CoordinatorPlugin plugin) log.info("Registering system session property provider factory %s", providerFactory.getName()); metadata.getSessionPropertyManager().addSessionPropertyProviderFactory(providerFactory); } + + for (TypeManagerFactory typeManagerFactory : plugin.getTypeManagerFactories()) { + log.info("Registering type manager factory %s", typeManagerFactory.getName()); + metadata.getFunctionAndTypeManager().addTypeManagerFactory(typeManagerFactory); + } } private URLClassLoader buildClassLoader(String plugin) diff --git a/presto-main/src/main/java/com/facebook/presto/server/PrestoServer.java b/presto-main/src/main/java/com/facebook/presto/server/PrestoServer.java index 5d681d829ffa..955c24452567 100644 --- a/presto-main/src/main/java/com/facebook/presto/server/PrestoServer.java +++ b/presto-main/src/main/java/com/facebook/presto/server/PrestoServer.java @@ -39,6 +39,7 @@ import com.facebook.presto.execution.warnings.WarningCollectorModule; import com.facebook.presto.metadata.Catalog; import com.facebook.presto.metadata.CatalogManager; +import com.facebook.presto.metadata.FunctionAndTypeManager; import com.facebook.presto.metadata.SessionPropertyManager; import com.facebook.presto.metadata.StaticCatalogStore; import com.facebook.presto.metadata.StaticFunctionNamespaceStore; @@ -181,6 +182,7 @@ public void run() injector.getInstance(GracefulShutdownHandler.class).loadNodeStatusNotification(); injector.getInstance(PlanCheckerProviderManager.class).loadPlanCheckerProviders(); injector.getInstance(SessionPropertyManager.class).loadSessionPropertyProviders(); + injector.getInstance(FunctionAndTypeManager.class).loadTypeManagers(); startAssociatedProcesses(injector); injector.getInstance(Announcer.class).start(); diff --git a/presto-main/src/main/java/com/facebook/presto/testing/QueryRunner.java b/presto-main/src/main/java/com/facebook/presto/testing/QueryRunner.java index d2121ce335f8..841ea0c9fa77 100644 --- a/presto-main/src/main/java/com/facebook/presto/testing/QueryRunner.java +++ b/presto-main/src/main/java/com/facebook/presto/testing/QueryRunner.java @@ -102,6 +102,11 @@ default void loadSessionPropertyProvider(String sessionPropertyProviderName) throw new UnsupportedOperationException(); } + default void loadTypeManager(String typeManagerName) + { + throw new UnsupportedOperationException(); + } + Lock getExclusiveLock(); class MaterializedResultWithPlan diff --git a/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/NativeSidecarPlugin.java b/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/NativeSidecarPlugin.java index 4c11cfa9b34d..269664f5e04c 100644 --- a/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/NativeSidecarPlugin.java +++ b/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/NativeSidecarPlugin.java @@ -14,8 +14,10 @@ package com.facebook.presto.sidecar; import com.facebook.presto.sidecar.sessionpropertyproviders.NativeSystemSessionPropertyProviderFactory; +import com.facebook.presto.sidecar.type.NativeTypeManagerFactory; import com.facebook.presto.spi.CoordinatorPlugin; import com.facebook.presto.spi.session.WorkerSessionPropertyProviderFactory; +import com.facebook.presto.spi.type.TypeManagerFactory; import com.google.common.collect.ImmutableList; public class NativeSidecarPlugin @@ -26,4 +28,10 @@ public Iterable getWorkerSessionPropertyPr { return ImmutableList.of(new NativeSystemSessionPropertyProviderFactory()); } + + @Override + public Iterable getTypeManagerFactories() + { + return ImmutableList.of(new NativeTypeManagerFactory()); + } } diff --git a/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManager.java b/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManager.java new file mode 100644 index 000000000000..9fa369e7ffd3 --- /dev/null +++ b/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManager.java @@ -0,0 +1,153 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.facebook.presto.sidecar.type; + +import com.facebook.airlift.log.Logger; +import com.facebook.presto.common.type.ParametricType; +import com.facebook.presto.common.type.Type; +import com.facebook.presto.common.type.TypeSignature; +import com.facebook.presto.spi.ExactTypeSignature; +import com.facebook.presto.spi.function.FunctionMetadataManager; +import com.facebook.presto.spi.type.TypeManagerInterface; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableList; +import com.google.common.util.concurrent.UncheckedExecutionException; +import com.google.inject.Inject; + +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import static com.facebook.presto.common.type.BigintEnumParametricType.BIGINT_ENUM; +import static com.facebook.presto.common.type.BigintType.BIGINT; +import static com.facebook.presto.common.type.BooleanType.BOOLEAN; +import static com.facebook.presto.common.type.DateType.DATE; +import static com.facebook.presto.common.type.DoubleType.DOUBLE; +import static com.facebook.presto.common.type.HyperLogLogType.HYPER_LOG_LOG; +import static com.facebook.presto.common.type.IntegerType.INTEGER; +import static com.facebook.presto.common.type.JsonType.JSON; +import static com.facebook.presto.common.type.RealType.REAL; +import static com.facebook.presto.common.type.SmallintType.SMALLINT; +import static com.facebook.presto.common.type.TimestampType.TIMESTAMP; +import static com.facebook.presto.common.type.TimestampWithTimeZoneType.TIMESTAMP_WITH_TIME_ZONE; +import static com.facebook.presto.common.type.TinyintType.TINYINT; +import static com.facebook.presto.common.type.UnknownType.UNKNOWN; +import static com.facebook.presto.common.type.UuidType.UUID; +import static com.facebook.presto.common.type.VarbinaryType.VARBINARY; +import static com.facebook.presto.common.type.VarcharType.VARCHAR; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.base.Throwables.throwIfUnchecked; +import static java.util.Objects.requireNonNull; +import static java.util.concurrent.TimeUnit.HOURS; + +public class NativeTypeManager + implements TypeManagerInterface +{ + private static final Logger log = Logger.get(NativeTypeManager.class); + + private static final List TYPES = + ImmutableList.of( + BIGINT, + UNKNOWN, + REAL, + VARBINARY, + TIMESTAMP, + TINYINT, + VARCHAR, + BOOLEAN, + DATE, + INTEGER, + DOUBLE, + SMALLINT, + HYPER_LOG_LOG, + JSON, + TIMESTAMP_WITH_TIME_ZONE, + UUID); + + private static final List PARAMETRIC_TYPES = ImmutableList.of(BIGINT_ENUM); + + private final FunctionMetadataManager functionMetadataManager; + private final LoadingCache parametricTypeCache; + private final ConcurrentMap types = new ConcurrentHashMap<>(); + private final ConcurrentMap parametricTypes = new ConcurrentHashMap<>(); + + @Inject + public NativeTypeManager(FunctionMetadataManager functionMetadataManager) + { + this.functionMetadataManager = requireNonNull(functionMetadataManager, "functionMetadataManager is null"); + parametricTypeCache = CacheBuilder.newBuilder() + .maximumSize(1000) + .expireAfterWrite(1, HOURS) + .build(CacheLoader.from(this::instantiateParametricType)); + addAllTypes(); + } + + @Override + public Optional getType(TypeSignature typeSignature) + { + Type type = types.get(typeSignature); + if (type != null) { + return Optional.of(type); + } + try { + return Optional.ofNullable(parametricTypeCache.getUnchecked(new ExactTypeSignature(typeSignature))); + } + catch (UncheckedExecutionException e) { + throwIfUnchecked(e.getCause()); + throw new RuntimeException(e.getCause()); + } + } + + @Override + public Map getParametricTypes() + { + return parametricTypes; + } + + private Type instantiateParametricType(ExactTypeSignature exactTypeSignature) + { + return functionMetadataManager.instantiateParametricType(exactTypeSignature); + } + + private void addAllTypes() + { + for (Type type : TYPES) { + addType(type); + } + + for (ParametricType type : PARAMETRIC_TYPES) { + addParametricType(type); + } + } + + private void addType(Type type) + { + requireNonNull(type, "type is null"); + Type existingType = types.putIfAbsent(type.getTypeSignature(), type); + checkState(existingType == null || existingType.equals(type), "Type %s is already registered", type); + } + + public void addParametricType(ParametricType parametricType) + { + String name = parametricType.getName().toLowerCase(Locale.ENGLISH); + checkArgument(!parametricTypes.containsKey(name), "Parametric type already registered: %s", name); + parametricTypes.putIfAbsent(name, parametricType); + } +} diff --git a/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerFactory.java b/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerFactory.java new file mode 100644 index 000000000000..cfd7a4a35cad --- /dev/null +++ b/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerFactory.java @@ -0,0 +1,45 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.facebook.presto.sidecar.type; + +import com.facebook.airlift.bootstrap.Bootstrap; +import com.facebook.presto.spi.type.TypeManagerContext; +import com.facebook.presto.spi.type.TypeManagerFactory; +import com.facebook.presto.spi.type.TypeManagerInterface; +import com.google.inject.Injector; + +public class NativeTypeManagerFactory + implements TypeManagerFactory +{ + public static final String NAME = "native"; + + @Override + public String getName() + { + return NAME; + } + + @Override + public TypeManagerInterface create(TypeManagerContext context) + { + Bootstrap app = new Bootstrap( + new NativeTypeManagerModule(context.getFunctionMetadataManager())); + + Injector injector = app + .doNotInitializeLogging() + .noStrictConfig() + .initialize(); + return injector.getInstance(NativeTypeManager.class); + } +} diff --git a/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerModule.java b/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerModule.java new file mode 100644 index 000000000000..042ea9113b93 --- /dev/null +++ b/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerModule.java @@ -0,0 +1,49 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.facebook.presto.sidecar.type; + +import com.facebook.airlift.json.JsonCodec; +import com.facebook.airlift.json.JsonCodecFactory; +import com.facebook.presto.spi.function.FunctionMetadataManager; +import com.facebook.presto.spi.session.SessionPropertyMetadata; +import com.facebook.presto.spi.type.TypeManagerInterface; +import com.google.inject.Binder; +import com.google.inject.Module; +import com.google.inject.Scopes; +import com.google.inject.TypeLiteral; + +import java.util.List; + +import static java.util.Objects.requireNonNull; + +public class NativeTypeManagerModule + implements Module +{ + private final FunctionMetadataManager functionMetadataManager; + + public NativeTypeManagerModule(FunctionMetadataManager functionMetadataManager) + { + this.functionMetadataManager = requireNonNull(functionMetadataManager, "functionMetadataManager is null"); + } + + @Override + public void configure(Binder binder) + { + binder.bind(new TypeLiteral>>() {}) + .toInstance(new JsonCodecFactory().listJsonCodec(SessionPropertyMetadata.class)); + binder.bind(FunctionMetadataManager.class).toInstance(functionMetadataManager); + binder.bind(NativeTypeManager.class).in(Scopes.SINGLETON); + binder.bind(TypeManagerInterface.class).to(NativeTypeManager.class).in(Scopes.SINGLETON); + } +} diff --git a/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/NativeSidecarPluginQueryRunnerUtils.java b/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/NativeSidecarPluginQueryRunnerUtils.java index 4ac96f6f837f..571b50c6ced4 100644 --- a/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/NativeSidecarPluginQueryRunnerUtils.java +++ b/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/NativeSidecarPluginQueryRunnerUtils.java @@ -13,6 +13,7 @@ */ package com.facebook.presto.sidecar; import com.facebook.presto.sidecar.sessionpropertyproviders.NativeSystemSessionPropertyProviderFactory; +import com.facebook.presto.sidecar.type.NativeTypeManagerFactory; import com.facebook.presto.testing.QueryRunner; public class NativeSidecarPluginQueryRunnerUtils @@ -23,5 +24,6 @@ public static void setupNativeSidecarPlugin(QueryRunner queryRunner) { queryRunner.installCoordinatorPlugin(new NativeSidecarPlugin()); queryRunner.loadSessionPropertyProvider(NativeSystemSessionPropertyProviderFactory.NAME); + queryRunner.loadTypeManager(NativeTypeManagerFactory.NAME); } } diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/CoordinatorPlugin.java b/presto-spi/src/main/java/com/facebook/presto/spi/CoordinatorPlugin.java index 81e57f7e1235..7ad8c91830ed 100644 --- a/presto-spi/src/main/java/com/facebook/presto/spi/CoordinatorPlugin.java +++ b/presto-spi/src/main/java/com/facebook/presto/spi/CoordinatorPlugin.java @@ -15,6 +15,7 @@ import com.facebook.presto.spi.function.FunctionNamespaceManagerFactory; import com.facebook.presto.spi.session.WorkerSessionPropertyProviderFactory; +import com.facebook.presto.spi.type.TypeManagerFactory; import static java.util.Collections.emptyList; @@ -36,4 +37,9 @@ default Iterable getWorkerSessionPropertyP { return emptyList(); } + + default Iterable getTypeManagerFactories() + { + return emptyList(); + } } diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/ExactTypeSignature.java b/presto-spi/src/main/java/com/facebook/presto/spi/ExactTypeSignature.java new file mode 100644 index 000000000000..23d25a387199 --- /dev/null +++ b/presto-spi/src/main/java/com/facebook/presto/spi/ExactTypeSignature.java @@ -0,0 +1,106 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.facebook.presto.spi; + +import com.facebook.presto.common.type.DistinctTypeInfo; +import com.facebook.presto.common.type.TypeSignature; +import com.facebook.presto.common.type.TypeSignatureParameter; + +import java.util.Objects; + +/** + * TypeSignature but has overridden equals(). Here, we compare exact signature of any underlying distinct + * types. Some distinct types may have extra information on their lazily loaded parents, and same parent + * information is compared in equals(). This is needed to cache types in parametricTypesCache. + */ +public class ExactTypeSignature +{ + private final TypeSignature typeSignature; + + public ExactTypeSignature(TypeSignature typeSignature) + { + this.typeSignature = typeSignature; + } + + public TypeSignature getTypeSignature() + { + return typeSignature; + } + + @Override + public int hashCode() + { + return Objects.hash(typeSignature); + } + + @Override + public boolean equals(Object o) + { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + ExactTypeSignature other = (ExactTypeSignature) o; + return equals(typeSignature, other.typeSignature); + } + + private static boolean equals(TypeSignature left, TypeSignature right) + { + if (!left.equals(right)) { + return false; + } + + if (left.isDistinctType() && right.isDistinctType()) { + return equals(left.getDistinctTypeInfo(), right.getDistinctTypeInfo()); + } + int index = 0; + for (TypeSignatureParameter leftParameter : left.getParameters()) { + TypeSignatureParameter rightParameter = right.getParameters().get(index++); + if (!leftParameter.getKind().equals(rightParameter.getKind())) { + return false; + } + + switch (leftParameter.getKind()) { + case TYPE: + if (!equals(leftParameter.getTypeSignature(), rightParameter.getTypeSignature())) { + return false; + } + break; + case NAMED_TYPE: + if (!equals(leftParameter.getNamedTypeSignature().getTypeSignature(), rightParameter.getNamedTypeSignature().getTypeSignature())) { + return false; + } + break; + case DISTINCT_TYPE: + if (!equals(leftParameter.getDistinctTypeInfo(), rightParameter.getDistinctTypeInfo())) { + return false; + } + break; + } + } + return true; + } + + private static boolean equals(DistinctTypeInfo left, DistinctTypeInfo right) + { + return Objects.equals(left.getName(), right.getName()) && + Objects.equals(left.getBaseType(), right.getBaseType()) && + Objects.equals(left.isOrderable(), right.isOrderable()) && + Objects.equals(left.getTopMostAncestor(), right.getTopMostAncestor()) && + Objects.equals(left.getOtherAncestors(), right.getOtherAncestors()); + } +} diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/function/FunctionMetadataManager.java b/presto-spi/src/main/java/com/facebook/presto/spi/function/FunctionMetadataManager.java index 04231b2c1555..353ecaa45324 100644 --- a/presto-spi/src/main/java/com/facebook/presto/spi/function/FunctionMetadataManager.java +++ b/presto-spi/src/main/java/com/facebook/presto/spi/function/FunctionMetadataManager.java @@ -13,7 +13,11 @@ */ package com.facebook.presto.spi.function; +import com.facebook.presto.common.type.Type; +import com.facebook.presto.spi.ExactTypeSignature; + public interface FunctionMetadataManager { FunctionMetadata getFunctionMetadata(FunctionHandle functionHandle); + public Type instantiateParametricType(ExactTypeSignature exactSignature); } diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerContext.java b/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerContext.java new file mode 100644 index 000000000000..3afab98d0818 --- /dev/null +++ b/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerContext.java @@ -0,0 +1,35 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.facebook.presto.spi.type; + +import com.facebook.presto.spi.function.FunctionMetadataManager; + +import java.util.Optional; + +import static java.util.Objects.requireNonNull; + +public class TypeManagerContext +{ + private final Optional functionMetadataManager; + + public TypeManagerContext(Optional functionMetadataManager) + { + this.functionMetadataManager = requireNonNull(functionMetadataManager, "functionMetadataManager is null"); + } + + public FunctionMetadataManager getFunctionMetadataManager() + { + return functionMetadataManager.orElseThrow(() -> new IllegalArgumentException("functionMetadataManager is not present")); + } +} diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerFactory.java b/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerFactory.java new file mode 100644 index 000000000000..e89ddd7c618e --- /dev/null +++ b/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerFactory.java @@ -0,0 +1,21 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.facebook.presto.spi.type; + +public interface TypeManagerFactory +{ + String getName(); + + TypeManagerInterface create(TypeManagerContext context); +} diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerInterface.java b/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerInterface.java new file mode 100644 index 000000000000..81045f086a22 --- /dev/null +++ b/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerInterface.java @@ -0,0 +1,28 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.facebook.presto.spi.type; + +import com.facebook.presto.common.type.ParametricType; +import com.facebook.presto.common.type.Type; +import com.facebook.presto.common.type.TypeSignature; + +import java.util.Map; +import java.util.Optional; + +public interface TypeManagerInterface +{ + Optional getType(TypeSignature signature); + + Map getParametricTypes(); +} diff --git a/presto-tests/src/main/java/com/facebook/presto/tests/DistributedQueryRunner.java b/presto-tests/src/main/java/com/facebook/presto/tests/DistributedQueryRunner.java index 5ad1d9885335..126a9c015dd7 100644 --- a/presto-tests/src/main/java/com/facebook/presto/tests/DistributedQueryRunner.java +++ b/presto-tests/src/main/java/com/facebook/presto/tests/DistributedQueryRunner.java @@ -943,6 +943,14 @@ public void loadSessionPropertyProvider(String sessionPropertyProviderName) } } + @Override + public void loadTypeManager(String typeManagerName) + { + for (TestingPrestoServer server : servers) { + server.getMetadata().getFunctionAndTypeManager().loadTypeManager(typeManagerName); + } + } + private static void closeUnchecked(AutoCloseable closeable) { try { From 83ba7548c7c3cdf7b9da26ef309a59c4d17e483f Mon Sep 17 00:00:00 2001 From: Pratik Joseph Dabre Date: Fri, 22 Nov 2024 15:39:26 -0800 Subject: [PATCH 2/2] Renamed and cleaned some code --- ...uiltInTypeAndFunctionNamespaceManager.java | 9 +++-- .../metadata/FunctionAndTypeManager.java | 37 ++++++++++++------- .../sidecar/type/NativeTypeManager.java | 4 +- .../type/NativeTypeManagerFactory.java | 4 +- .../sidecar/type/NativeTypeManagerModule.java | 4 +- .../presto/spi/type/TypeManagerFactory.java | 2 +- ...nterface.java => TypeManagerProvider.java} | 2 +- 7 files changed, 38 insertions(+), 24 deletions(-) rename presto-spi/src/main/java/com/facebook/presto/spi/type/{TypeManagerInterface.java => TypeManagerProvider.java} (96%) diff --git a/presto-main/src/main/java/com/facebook/presto/metadata/BuiltInTypeAndFunctionNamespaceManager.java b/presto-main/src/main/java/com/facebook/presto/metadata/BuiltInTypeAndFunctionNamespaceManager.java index 76397a5c7d8a..20d1fb564675 100644 --- a/presto-main/src/main/java/com/facebook/presto/metadata/BuiltInTypeAndFunctionNamespaceManager.java +++ b/presto-main/src/main/java/com/facebook/presto/metadata/BuiltInTypeAndFunctionNamespaceManager.java @@ -235,6 +235,7 @@ import com.facebook.presto.spi.function.SqlFunctionVisibility; import com.facebook.presto.spi.function.SqlInvokedFunction; import com.facebook.presto.spi.function.SqlInvokedScalarFunctionImplementation; +import com.facebook.presto.spi.type.TypeManagerProvider; import com.facebook.presto.sql.analyzer.FunctionsConfig; import com.facebook.presto.sql.analyzer.TypeSignatureProvider; import com.facebook.presto.type.BigintOperators; @@ -534,7 +535,7 @@ @ThreadSafe public class BuiltInTypeAndFunctionNamespaceManager - implements FunctionNamespaceManager + implements FunctionNamespaceManager, TypeManagerProvider { public static final CatalogSchemaName DEFAULT_NAMESPACE = new CatalogSchemaName("presto", "default"); public static final String ID = "builtin"; @@ -1264,6 +1265,7 @@ public ScalarFunctionImplementation getScalarFunctionImplementation(Signature si } } + @Override public Optional getType(TypeSignature typeSignature) { Type type = types.get(typeSignature); @@ -1298,9 +1300,10 @@ public void addParametricType(ParametricType parametricType) parametricTypes.putIfAbsent(name, parametricType); } - public Collection getParametricTypes() + @Override + public Map getParametricTypes() { - return parametricTypes.values(); + return parametricTypes; } private Type instantiateParametricType(ExactTypeSignature exactSignature) diff --git a/presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java b/presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java index 889eeaa39e6c..06723850560a 100644 --- a/presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java +++ b/presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java @@ -53,7 +53,7 @@ import com.facebook.presto.spi.function.SqlInvokedFunction; import com.facebook.presto.spi.type.TypeManagerContext; import com.facebook.presto.spi.type.TypeManagerFactory; -import com.facebook.presto.spi.type.TypeManagerInterface; +import com.facebook.presto.spi.type.TypeManagerProvider; import com.facebook.presto.sql.analyzer.FeaturesConfig; import com.facebook.presto.sql.analyzer.FunctionAndTypeResolver; import com.facebook.presto.sql.analyzer.FunctionsConfig; @@ -129,7 +129,7 @@ public class FunctionAndTypeManager private final Map typeManagerFactories = new ConcurrentHashMap<>(); private final HandleResolver handleResolver; private final Map> functionNamespaceManagers = new ConcurrentHashMap<>(); - private final Map typeManagers = new ConcurrentHashMap<>(); + private final Map typeManagers = new ConcurrentHashMap<>(); private final FunctionSignatureMatcher functionSignatureMatcher; private final TypeCoercer typeCoercer; private final LoadingCache functionCache; @@ -305,9 +305,12 @@ public FunctionMetadata getFunctionMetadata(FunctionHandle functionHandle) @Override public Type instantiateParametricType(ExactTypeSignature exactSignature) { + // This method is only used by nativeTypeManager, so check if typeManagers is empty first checkState(!typeManagers.isEmpty()); - return builtInTypeAndFunctionNamespaceManager.instantiateParametricType(exactSignature, this, - typeManagers.get("native").getParametricTypes()); + return builtInTypeAndFunctionNamespaceManager.instantiateParametricType( + exactSignature, + this, + getServingTypeManagerProvider().getParametricTypes()); } @Override @@ -318,13 +321,7 @@ public Type getType(TypeSignature signature) if (signature.isDistinctType()) { return getDistinctType(signature.getParameters().get(0).getDistinctTypeInfo()); } - Optional type; - if (typeManagers.isEmpty()) { - type = builtInTypeAndFunctionNamespaceManager.getType(signature.getStandardTypeSignature()); - } - else { - type = typeManagers.get("native").getType(signature.getStandardTypeSignature()); - } + Optional type = getServingTypeManagerProvider().getType(signature.getStandardTypeSignature()); if (type.isPresent()) { if (signature.getTypeSignatureBase().hasTypeName()) { return new TypeWithName(signature.getTypeSignatureBase().getTypeName(), type.get()); @@ -366,7 +363,7 @@ public void loadTypeManager(String typeManagerName) requireNonNull(typeManagerName, "typeManagerName is null"); TypeManagerFactory factory = typeManagerFactories.get(typeManagerName); checkState(factory != null, "No factory for type manager %s", typeManagerName); - TypeManagerInterface typeManager = factory.create(new TypeManagerContext(Optional.of(this))); + TypeManagerProvider typeManager = factory.create(new TypeManagerContext(Optional.of(this))); if (typeManagers.putIfAbsent(typeManagerName, typeManager) != null) { throw new IllegalArgumentException(format("Type manager [%s] is already registered", typeManager)); @@ -540,7 +537,7 @@ public List getTypes() public Collection getParametricTypes() { - return ImmutableList.copyOf(builtInTypeAndFunctionNamespaceManager.getParametricTypes()); + return ImmutableList.copyOf(builtInTypeAndFunctionNamespaceManager.getParametricTypes().values()); } public Optional getCommonSuperType(Type firstType, Type secondType) @@ -778,6 +775,20 @@ private Optional> getServingFunc return Optional.ofNullable(functionNamespaceManagers.get(typeSignatureBase.getTypeName().getCatalogName())); } + private TypeManagerProvider getServingTypeManagerProvider() + { + TypeManagerProvider typeManagerProvider = builtInTypeAndFunctionNamespaceManager; + for (Map.Entry entry : typeManagerFactories.entrySet()) { + TypeManagerFactory typeManagerFactory = entry.getValue(); + // Get the type manager name from the factory + String name = typeManagerFactory.getName(); + + // Check if the type manager exists in typeManagers else use builtInTypeAndFunctionNamespaceManager + typeManagerProvider = typeManagers.getOrDefault(name, typeManagerProvider); + } + return typeManagerProvider; + } + private static class FunctionResolutionCacheKey { private final QualifiedObjectName functionName; diff --git a/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManager.java b/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManager.java index 9fa369e7ffd3..a3247e12ae78 100644 --- a/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManager.java +++ b/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManager.java @@ -19,7 +19,7 @@ import com.facebook.presto.common.type.TypeSignature; import com.facebook.presto.spi.ExactTypeSignature; import com.facebook.presto.spi.function.FunctionMetadataManager; -import com.facebook.presto.spi.type.TypeManagerInterface; +import com.facebook.presto.spi.type.TypeManagerProvider; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -58,7 +58,7 @@ import static java.util.concurrent.TimeUnit.HOURS; public class NativeTypeManager - implements TypeManagerInterface + implements TypeManagerProvider { private static final Logger log = Logger.get(NativeTypeManager.class); diff --git a/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerFactory.java b/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerFactory.java index cfd7a4a35cad..45f1f9b308f7 100644 --- a/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerFactory.java +++ b/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerFactory.java @@ -16,7 +16,7 @@ import com.facebook.airlift.bootstrap.Bootstrap; import com.facebook.presto.spi.type.TypeManagerContext; import com.facebook.presto.spi.type.TypeManagerFactory; -import com.facebook.presto.spi.type.TypeManagerInterface; +import com.facebook.presto.spi.type.TypeManagerProvider; import com.google.inject.Injector; public class NativeTypeManagerFactory @@ -31,7 +31,7 @@ public String getName() } @Override - public TypeManagerInterface create(TypeManagerContext context) + public TypeManagerProvider create(TypeManagerContext context) { Bootstrap app = new Bootstrap( new NativeTypeManagerModule(context.getFunctionMetadataManager())); diff --git a/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerModule.java b/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerModule.java index 042ea9113b93..5172c0ba107d 100644 --- a/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerModule.java +++ b/presto-native-sidecar-plugin/src/main/java/com/facebook/presto/sidecar/type/NativeTypeManagerModule.java @@ -17,7 +17,7 @@ import com.facebook.airlift.json.JsonCodecFactory; import com.facebook.presto.spi.function.FunctionMetadataManager; import com.facebook.presto.spi.session.SessionPropertyMetadata; -import com.facebook.presto.spi.type.TypeManagerInterface; +import com.facebook.presto.spi.type.TypeManagerProvider; import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.Scopes; @@ -44,6 +44,6 @@ public void configure(Binder binder) .toInstance(new JsonCodecFactory().listJsonCodec(SessionPropertyMetadata.class)); binder.bind(FunctionMetadataManager.class).toInstance(functionMetadataManager); binder.bind(NativeTypeManager.class).in(Scopes.SINGLETON); - binder.bind(TypeManagerInterface.class).to(NativeTypeManager.class).in(Scopes.SINGLETON); + binder.bind(TypeManagerProvider.class).to(NativeTypeManager.class).in(Scopes.SINGLETON); } } diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerFactory.java b/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerFactory.java index e89ddd7c618e..9ba964174cf3 100644 --- a/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerFactory.java +++ b/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerFactory.java @@ -17,5 +17,5 @@ public interface TypeManagerFactory { String getName(); - TypeManagerInterface create(TypeManagerContext context); + TypeManagerProvider create(TypeManagerContext context); } diff --git a/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerInterface.java b/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerProvider.java similarity index 96% rename from presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerInterface.java rename to presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerProvider.java index 81045f086a22..c4cc3b4fa649 100644 --- a/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerInterface.java +++ b/presto-spi/src/main/java/com/facebook/presto/spi/type/TypeManagerProvider.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.Optional; -public interface TypeManagerInterface +public interface TypeManagerProvider { Optional getType(TypeSignature signature);