FunctionRegistry { public void registerUDF(String shortName, Class< ? > clazz, Map<String, String> functionProperties) throws CQLException { if (functions.containsKey(shortName)) { FunctionInfo fInfo = functions.get(shortName); if (fInfo.isNative()) { SemanticAnalyzerException exception = new SemanticAnalyzerException(ErrorCode.FUNCTION_OVERWRITE_NATIVE, shortName); LOG.error("User define function will overwritten native function.", exception); throw exception; } } FunctionInfo functionInfo = FunctionInfo.createUDFFunctionInfo(shortName, clazz, NativeFunctionRegistry.getUdfMethodName(), false, FunctionType.UDF); functionInfo.setProperteis(functionProperties); functions.put(shortName, functionInfo); } FunctionRegistry(); void registerUDF(String shortName, Class< ? > clazz, Map<String, String> functionProperties); void unRegisterUDF(String shortName); void registerUDAF(String shortName, Class< ? > clazz); String getFunctionNameByClass(String clazz); FunctionInfo changeCastFunctionInfo(Class< ? > type); FunctionInfo getFunctionInfoByFunctionClass(Class< ? extends UDF > clazz); FunctionInfo getFunctionInfoByFunctionName(String functionName);  }
@Test public void testRegisterUDF() throws CQLException { functionRegistry.registerUDF("udftest", TestUDF.class, null); assertTrue(functionRegistry.getFunctionInfoByFunctionName("udftest").getName().equals("udftest")); assertFalse(functionRegistry.getFunctionInfoByFunctionName("udftest").isNative()); assertTrue(functionRegistry.getFunctionInfoByFunctionName("udftest").getClazz() == TestUDF.class); }