zoukankan      html  css  js  c++  java
  • 批量数据数据处理

    //防止数据量过大,分批批量插入
    int maxCount = 5000;
    for (int i = 0; i < serverInfoRecordVoList.size(); i += maxCount) {
    	if (i + maxCount > serverInfoRecordVoList.size()) {
    		// 批量处理操作
    		batchHandleForServerInfoRecord(serverInfoRecordVoList.subList(i,serverInfoRecordVoList.size()));
    	} else {
    		batchHandleForServerInfoRecord(serverInfoRecordVoList.subList(i, i + maxCount));
    	}
    }		
    
    /**
     * 分批处理服务器数据
     * @param serverInfoRecordVoList
     */
    private void batchHandleForServerInfoRecord(List<ServerInfoVo> serverInfoRecordVoList) {
    	Map<String, Object>[] paramMaps = new HashMap[serverInfoRecordVoList.size()];
    	for (int i = 0; i < serverInfoRecordVoList.size(); i++) {
    		Map<String, Object> paramMap = new HashMap<>();
    		paramMap.put("serverIp", serverInfoRecordVoList.get(i).getServerIp());
    		paramMap.put("serverName", serverInfoRecordVoList.get(i).getServerName());
    		paramMap.put("systemShortName", serverInfoRecordVoList.get(i).getSystemShortName());
    		paramMap.put("ldc", serverInfoRecordVoList.get(i).getLdc());
    		paramMap.put("envType", serverInfoRecordVoList.get(i).getEnvType());
    		paramMap.put("cpu", serverInfoRecordVoList.get(i).getCpu());
    		paramMap.put("memory", serverInfoRecordVoList.get(i).getMemory());
    		paramMap.put("diskSize", serverInfoRecordVoList.get(i).getDiskSize());
    		paramMap.put("dataDiskSize", serverInfoRecordVoList.get(i).getDataDiskSize());
    		paramMap.put("serverType", serverInfoRecordVoList.get(i).getServerType());
    		paramMap.put("softwareType", serverInfoRecordVoList.get(i).getSoftwareType());
    		paramMap.put("softwareName", serverInfoRecordVoList.get(i).getSoftwareName());
    		paramMap.put("useType", serverInfoRecordVoList.get(i).getUseType());
    		paramMap.put("hostIp", serverInfoRecordVoList.get(i).getHostIp());
    		paramMap.put("serverStatus", serverInfoRecordVoList.get(i).getServerStatus());
    		paramMap.put("osType", serverInfoRecordVoList.get(i).getOsType());
    		paramMap.put("osName", serverInfoRecordVoList.get(i).getOsName());
    		paramMaps[i] = paramMap;
    	}
    	// 数据插入处理操作
    	Long nowTime = System.currentTimeMillis();
    	serverInfoRecordDataDao.batchInsertServerInfoRecordData(paramMaps);
    	log.info("一次处理插入服务器记录表耗时:{}", System.currentTimeMillis() - nowTime);
    }
    每天一点点,惊喜不间断
  • 相关阅读:
    在ubuntu下递归追索一个包的所有必要依赖项apt_dep.sh
    龙芯系统下,GTK与OPENGL共舞
    Linux应用程序自行开启Core Dump生成功能
    Daliy Algorithm -- day 102
    Daliy Algorithm -- day 101
    Daliy Algorithm -- day 100
    Daliy Algorithm -- day 99
    Daliy Algorithm -- day 98
    Daliy Algorithm -- day 97
    使用R语言进行简单的线性回归
  • 原文地址:https://www.cnblogs.com/wszn-java/p/14832247.html
Copyright © 2011-2022 走看看