in common/src/main/java/org/opensearch/ml/common/MLCommonsClassLoader.java [51:75]
private static void loadMLAlgoParameterClassMapping() {
Reflections reflections = new Reflections("org.opensearch.ml.common.parameter");
Set<Class<?>> classes = reflections.getTypesAnnotatedWith(MLAlgoParameter.class);
// Load ML algorithm parameter class
for (Class<?> clazz : classes) {
MLAlgoParameter mlAlgoParameter = clazz.getAnnotation(MLAlgoParameter.class);
FunctionName[] algorithms = mlAlgoParameter.algorithms();
if (algorithms != null && algorithms.length > 0) {
for(FunctionName name : algorithms){
parameterClassMap.put(name, clazz);
}
}
}
// Load ML output class
classes = reflections.getTypesAnnotatedWith(MLAlgoOutput.class);
for (Class<?> clazz : classes) {
MLAlgoOutput mlAlgoOutput = clazz.getAnnotation(MLAlgoOutput.class);
MLOutputType mlOutputType = mlAlgoOutput.value();
if (mlOutputType != null) {
parameterClassMap.put(mlOutputType, clazz);
}
}
}