====== 批量数据接口调用 ====== 当前批量数据调用仅支持针对oracle、mysql数据库的批量调用,hive的批量调用 建议采用udf方式进行 ===== 获取批量调用任务包 ===== 需要使用eppdev-mlib-batch任务包,具体所需文件为两个: - eppdev-mlib-batch.jar: 主要执行文件 - application.properties:相应的配置文件 > 上述两个文件需要在统一目录 ===== 前提准备 ===== 需要准备模型计算所需数据宽表和结果回填表两个表,其中宽表数据中需要有唯一主键, 输出结果表需要有主键和create_time字段,便于进行库表数据对应,示例格式如下 -- -------------------------------------- -- tableName:test_model_input -- author: jinlong.hao -- date: 2019-11-24 -- desc: -- 1. 模型输入库表 -- 2. 主键为id -- 3. 用于进行模型测试 -- --------------------------------------- create table test_model_input( id char(32) comment '主键' ,sepal_width double comment 'sepal.width' ,sepal_height double comment 'sepal.height' ,petal_width double comment 'petal.width' ,petal_height double comment 'petal.height' ,create_time double comment '创建时间,用于进行增量计算' ) comment '模型测试输入表'; -- -------------------------------------- -- tableName:test_model_output -- author: jinlong.hao -- date: 2019-11-24 -- desc: -- 1. 模型输出结果表 -- 2. 主键为id -- --------------------------------------- create table test_model_output( id varchar(32) comment '唯一主键' ,probability_setosa double comment 'Setosa概率' ,probability_virginica double comment 'Virginica概率' ,probability_versicolor double comment 'Versicolor概率' ,variety varchar(20) comment '模型预测结果' ,create_time datetime comment '模型计算时间' ) comment '模型测试输出表'; ~~~ ===== 环境配置 ===== 修改application.properties文件,主要修改以下内容: * spring.datasource.* : 数据库相关配置 * eppdev.mlib.consumer.basic-url: 服务网关的基础地址 * eppdev.mlib.batch.model-code: 模型编码 * eppdev.mlib.batch.input-table.name: 输出表的表名 * eppdev.mlib.batch.input-table.key: 输入表主键 * eppdev.mlib.batch.input-table.columns: 输出表需要查询的字段列表 * eppdev.mlib.batch.input-table.where: 定制查询条件,可以包括参数,用于命令传参数 * eppdev.mlib.batch.fetch-size: 每次读取的数据量,避免一次性加载过量数据 * eppdev.mlib.batch.output-table.name: 输出库表表名 * eppdev.mlib.batch.output-table.key: 输出表的主键名称 * eppdev.mlib.batch.output-table.column-maps: 输出字段的映射 > 其中spring.datasource.*配置模式同普通springboot工程, eppdev.mlib相关配置示例如下: eppdev.mlib.consumer.basic-url = http://localhost:11524/consumer eppdev.mlib.batch.model-code = test-01 eppdev.mlib.batch.input-table.name = test_model_input eppdev.mlib.batch.input-table.key = id eppdev.mlib.batch.input-table.columns = id, sepal_width as `sepal.width`, sepal_height as `sepal.height`, petal_width as `petal.width`, petal_height as `petal.height` eppdev.mlib.batch.input-table.where = create_time >= ${begin_time} and create_time <= ${end_time} eppdev.mlib.batch.fetch-size = 1000 eppdev.mlib.batch.output-table.name = test_model_output eppdev.mlib.batch.output-table.key = id eppdev.mlib.batch.output-table.column-maps = probability(Setosa) as probability_setosa, probability(Virginica) as probability_virginica, probability(Versicolor) as probability_versicolor, variety as variety ===== 执行调用 ===== ./eppdev-mlib-sdk-batch.jar -Dbegin_time="2019-11-20 11:24:32" -Dend_time="2019-11-21 12:23:24"