我有一年的年份 - 2013年到2016年。像Jan-Dec一样。 我必须从10000行/记录数据中获得月份数据但是它给出了java.lang.OutOfMemoryError:Java堆空间。在下面的逻辑中帮我解决了什么问题。
for (Integer year : yearSet) {
List<EtrendMonthYearModel> etrendMonthYearModelList = new ArrayList<EtrendMonthYearModel>();
for (Integer month : monthSet) {
for (String zip : zipSet) {
EtrendFilterBYModel etrendFilterBYModel = new EtrendFilterBYModel();
for (int i = 0; i < etrendMonthYearModel.size(); i++) {
EtrendMonthYearModel etrendMonthYearModelTemp = null;
if ((etrendMonthYearModel.get(i).geteTKeymy10() == (long)month)
&& (etrendMonthYearModel.get(i).geteTKeymy11() == year)
&& (etrendMonthYearModel.get(i).geteTKeymy1().equals(zip)))
{
etrendMonthYearModelTemp = new EtrendMonthYearModel();
etrendMonthYearModelTemp = etrendMonthYearModel.get(i);
etrendMonthYearModelList.add(etrendMonthYearModelTemp);
}
}
etrendFilterBYModel.setName(zip);
etrendFilterBYModel.setMonth(month);
etrendFilterBYModel.setLevel("ekeymy1");
etrendFilterBYModel.setYear(year);
String serializedObjList = "";
serializedObjList = encodeMonYear(etrendMonthYearModelList);
etrendFilterBYModel.setObjData(serializedObjList);
etrendFilterBYModelZipList.add(etrendFilterBYModel);
}
}
}
rowCount= 0;
Batch batchProcessZip = QueryBuilder.batch();
for (EtrendFilterBYModel etrendFilterBYModelZipTemp : etrendFilterBYModelZipList) {
Insert insert = QueryBuilder.insertInto("etrend_optimized_monthly");
insert.value("year",etrendFilterBYModelZipTemp.getYear());
insert.value("month",etrendFilterBYModelZipTemp.getMonth());
insert.value("level",etrendFilterBYModelZipTemp.getLevel());
insert.value("name",etrendFilterBYModelZipTemp.getName());
insert.value("objdata",etrendFilterBYModelZipTemp.getObjData());
batchProcessZip.add(insert);
rowCount++;
if(rowCount>1000)
{
cassandraTemplate.execute(batchProcessZip);
batchProcessZip = QueryBuilder.batch();
rowCount = 0;
}
}
cassandraTemplate.execute(batchProcessZip);