use of org.opensearch.ml.common.annotation.MLAlgoOutput in project ml-commons by opensearch-project.
the class MLCommonsClassLoader method loadMLAlgoParameterClassMapping.
/**
* Load ML algorithm parameter and ML output class.
*/
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);
}
}
}
Aggregations