java.lang.OutOfMemoryError: Java heap space 에러로인한 배치로
This commit is contained in:
parent
821e6dec07
commit
b5b048e55c
@ -59,6 +59,7 @@ public class AddrServiceImpl extends EgovAbstractServiceImpl implements AddrSer
|
|||||||
private static final String PHONE_REGEX = "^(01[016789]-?\\d{3,4}-?\\d{4})$";
|
private static final String PHONE_REGEX = "^(01[016789]-?\\d{3,4}-?\\d{4})$";
|
||||||
private static final Pattern PHONE_PATTERN = Pattern.compile(PHONE_REGEX);
|
private static final Pattern PHONE_PATTERN = Pattern.compile(PHONE_REGEX);
|
||||||
private static final Charset EUC_KR = Charset.forName("EUC-KR");
|
private static final Charset EUC_KR = Charset.forName("EUC-KR");
|
||||||
|
private static final int BATCH_SIZE = 10000;
|
||||||
// private static final int MAX_ADDR_CNT = 500000;
|
// private static final int MAX_ADDR_CNT = 500000;
|
||||||
//임시 500만개
|
//임시 500만개
|
||||||
private static final int MAX_ADDR_CNT = 5000000;
|
private static final int MAX_ADDR_CNT = 5000000;
|
||||||
@ -471,7 +472,9 @@ public class AddrServiceImpl extends EgovAbstractServiceImpl implements AddrSer
|
|||||||
|
|
||||||
if(addrListVO.size() > 0) {
|
if(addrListVO.size() > 0) {
|
||||||
// 등록
|
// 등록
|
||||||
addrDAO.insertAddrList(addrListVO);
|
// Batch insert
|
||||||
|
batchInsertAddrList(addrListVO);
|
||||||
|
// addrDAO.insertAddrList(addrListVO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,6 +500,28 @@ public class AddrServiceImpl extends EgovAbstractServiceImpl implements AddrSer
|
|||||||
, LocalDateTime.now());
|
, LocalDateTime.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void batchInsertAddrList(List<AddrVO> addrListVO) throws Exception {
|
||||||
|
|
||||||
|
int totalSize = addrListVO.size();
|
||||||
|
int batchCount = (totalSize + BATCH_SIZE - 1) / BATCH_SIZE;
|
||||||
|
long startTime, endTime;
|
||||||
|
double executionTime;
|
||||||
|
|
||||||
|
for (int i = 0; i < batchCount; i++) {
|
||||||
|
int startIndex = i * BATCH_SIZE;
|
||||||
|
int endIndex = Math.min(startIndex + BATCH_SIZE, totalSize);
|
||||||
|
List<AddrVO> batchList = addrListVO.subList(startIndex, endIndex);
|
||||||
|
|
||||||
|
startTime = System.currentTimeMillis();
|
||||||
|
addrDAO.insertAddrList(batchList);
|
||||||
|
endTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
executionTime = (endTime - startTime) / 1000.0;
|
||||||
|
System.out.println("Batch " + (i + 1) + "/" + batchCount + " Execution time: " + executionTime + " seconds");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isValidPhoneNumber(String phoneNo) {
|
public static boolean isValidPhoneNumber(String phoneNo) {
|
||||||
if (phoneNo == null || phoneNo.isEmpty()) {
|
if (phoneNo == null || phoneNo.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user