public FunctionRegistry(DrillConfig config) { try { Set<Class<? extends CallProvider>> providerClasses = PathScanner.scanForImplementations( CallProvider.class, config.getStringList(CommonConstants.LOGICAL_FUNCTION_SCAN_PACKAGES)); Map<String, FunctionDefinition> funcs = new HashMap<String, FunctionDefinition>(); for (Class<? extends CallProvider> c : providerClasses) { CallProvider p = c.newInstance(); FunctionDefinition[] defs = p.getFunctionDefintions(); for (FunctionDefinition d : defs) { for (String rn : d.getRegisteredNames()) { FunctionDefinition d2 = funcs.put(rn, d); // logger.debug("Registering function {}", d); if (d2 != null) { throw new ExceptionInInitializerError( String.format( "Failure while registering functions. The function %s tried to register with the name %s but the function %s already registered with that name.", d.getName(), rn, d2.getName())); } } } } funcMap = funcs; } catch (Exception e) { throw new RuntimeException("Failure while setting up FunctionRegistry.", e); } }