|
@@ -13,10 +13,6 @@ import java.util.Properties;
|
|
|
@Slf4j
|
|
|
public class BatchSinkHour extends RichSinkFunction<CostHourDM> {
|
|
|
|
|
|
- // 对象锁,防止MaxCompute的 Tunnel对象多次初始化
|
|
|
- private static final Object DUMMY_LOCK = new Object();
|
|
|
-
|
|
|
- private String sql;
|
|
|
private Connection connection = null;
|
|
|
|
|
|
public BatchSinkHour() {
|
|
@@ -129,7 +125,6 @@ public class BatchSinkHour extends RichSinkFunction<CostHourDM> {
|
|
|
"?,?,?,?,?,?,?,?,?,?,\n" +
|
|
|
"?,?,?,?,?,?,?,?,?,?,\n" +
|
|
|
"?,?,?,?,?,?,?,?)";
|
|
|
- log.error(costhour.toString());
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement(sql);
|
|
|
preparedStatement.setString(1, costhour.dt);
|
|
|
preparedStatement.setString(2, costhour.createTime);
|
|
@@ -220,11 +215,7 @@ public class BatchSinkHour extends RichSinkFunction<CostHourDM> {
|
|
|
preparedStatement.setDouble(87, costhour.webRegisterCostHour);
|
|
|
preparedStatement.setString(88, costhour.agencyAccountId);
|
|
|
preparedStatement.addBatch();
|
|
|
- long startTime = System.currentTimeMillis();
|
|
|
- int ints[] = preparedStatement.executeBatch();
|
|
|
connection.commit();
|
|
|
- long endTime = System.currentTimeMillis();
|
|
|
- log.info("批量插入耗时: " + (endTime - startTime) + "插入数据数量=" + ints.length);
|
|
|
//clickhouse 处理重复数据
|
|
|
//TODO:数据去重有问题,去除掉非最新的数据
|
|
|
// Statement statement_duplicate = connection.createStatement();
|
|
@@ -232,7 +223,6 @@ public class BatchSinkHour extends RichSinkFunction<CostHourDM> {
|
|
|
// statement_duplicate.executeQuery(sql_duplicate);
|
|
|
// connection.commit();
|
|
|
long endTime_dp = System.currentTimeMillis();
|
|
|
- log.info("数据清理耗时: " + (endTime_dp - endTime));
|
|
|
|
|
|
}
|
|
|
|