use of com.alibaba.alink.common.mapper.ComboMapper in project Alink by alibaba.
the class ModelExporterUtils method createMapperFromStage.
// not open and load.
public static Mapper createMapperFromStage(PipelineStageBase<?> stage, TableSchema modelSchema, TableSchema inputSchema, List<Row> data) {
Mapper mapper = null;
if (stage instanceof MapModel) {
MapModel<?> mapModel = (MapModel<?>) stage;
mapper = mapModel.mapperBuilder.apply(modelSchema, inputSchema, mapModel.getParams());
if (data != null) {
((ModelMapper) mapper).loadModel(data);
}
} else if (stage instanceof BaseRecommender) {
mapper = RecommenderUtil.createRecommMapper((BaseRecommender<?>) stage, modelSchema, inputSchema, data);
} else if (stage instanceof MapTransformer) {
MapTransformer<?> mapTransformer = (MapTransformer<?>) stage;
mapper = mapTransformer.mapperBuilder.apply(inputSchema, mapTransformer.getParams());
} else {
throw new RuntimeException("not support yet.");
}
if (mapper instanceof ComboModelMapper) {
((ComboModelMapper) mapper).newMapperList();
}
if (mapper instanceof ComboMapper) {
((ComboMapper) mapper).newMapperList();
}
return mapper;
}
Aggregations