Skip to content

Commit

Permalink
Remove setFunctionAndTypeManager from TypeRegistry
Browse files Browse the repository at this point in the history
Move FunctionAndTypeManager to constructor
  • Loading branch information
rongrong authored and Rongrong Zhong committed Oct 13, 2020
1 parent ac735db commit f1fb2e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ public FunctionAndTypeManager(
this.functionNamespaceManagers.put(DEFAULT_NAMESPACE.getCatalogName(), builtInFunctionNamespaceManager);
this.functionInvokerProvider = new FunctionInvokerProvider(this);
this.handleResolver = requireNonNull(handleResolver, "handleResolver is null");
this.builtInTypeRegistry = new TypeRegistry(types, featuresConfig);
builtInTypeRegistry.setFunctionManager(this);
this.builtInTypeRegistry = new TypeRegistry(types, featuresConfig, this);
// TODO: Provide a more encapsulated way for TransactionManager to register FunctionNamespaceManager
transactionManager.registerFunctionNamespaceManager(DEFAULT_NAMESPACE.getCatalogName(), builtInFunctionNamespaceManager);
this.functionCache = CacheBuilder.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ public final class TypeRegistry
private final ConcurrentMap<String, ParametricType> parametricTypes = new ConcurrentHashMap<>();
private final FeaturesConfig featuresConfig;

private FunctionAndTypeManager functionAndTypeManager;
private final FunctionAndTypeManager functionAndTypeManager;

private final LoadingCache<TypeSignature, Type> parametricTypeCache;

public TypeRegistry(Set<Type> types, FeaturesConfig featuresConfig)
public TypeRegistry(Set<Type> types, FeaturesConfig featuresConfig, FunctionAndTypeManager functionAndTypeManager)
{
requireNonNull(types, "types is null");
this.featuresConfig = requireNonNull(featuresConfig, "featuresConfig is null");
this.functionAndTypeManager = requireNonNull(functionAndTypeManager, "functionAndTypeManager is null");

// Manually register UNKNOWN type without a verifyTypeClass call since it is a special type that can not be used by functions
this.types.put(UNKNOWN.getTypeSignature(), UNKNOWN);
Expand Down Expand Up @@ -157,12 +158,6 @@ public TypeRegistry(Set<Type> types, FeaturesConfig featuresConfig)
.build(CacheLoader.from(this::instantiateParametricType));
}

public void setFunctionManager(FunctionAndTypeManager functionAndTypeManager)
{
checkState(this.functionAndTypeManager == null, "TypeRegistry can only be associated with a single FunctionManager");
this.functionAndTypeManager = requireNonNull(functionAndTypeManager, "functionManager is null");
}

public Type getType(TypeSignature signature)
{
Type type = types.get(signature);
Expand Down

0 comments on commit f1fb2e0

Please sign in to comment.