Commit a2551f78 by 徐鹏

Merge branch 'TECH-search-fix' into 'master'

修正临时文件一直追加问题

See merge request !6
parents c8a7957b 619f3d94
......@@ -117,9 +117,11 @@ public class QueryPlanHelper {
}
long nowSecond = System.currentTimeMillis()/1000;
long sevenDays = 3600 * 24 * 7;
boolean appendToFile = true;
if (nowSecond - minTimeStamp > sevenDays) {
// 文件中最早的时间戳超过7天,全量更新;否则只更新新增的
if (keywordMap.size() > 0) {
appendToFile = false;
newWordLines = new ArrayList<>(); // map转存到newWordLines
for (Map.Entry<String, Integer> entry : keywordMap.entrySet()) {
String line = entry.getKey() + "," + entry.getValue() + "," + nowSecond;
......@@ -129,7 +131,7 @@ public class QueryPlanHelper {
}
}
if (newWordLines != null && newWordLines.size() > 0) {
FileUtils.saveToFile(newWordLines, queryPlanFile, true);
FileUtils.saveToFile(newWordLines, queryPlanFile, appendToFile);
newWordLines = new ArrayList<>();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment