SOLR-4965: skip IW.commit if no changes

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1497075 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2013-06-26 20:22:41 +00:00
parent b9e1537a7e
commit 811079b8c6
1 changed files with 11 additions and 5 deletions

View File

@ -540,11 +540,17 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
}
// SolrCore.verbose("writer.commit() start writer=",writer);
final Map<String,String> commitData = new HashMap<String,String>();
commitData.put(SolrIndexWriter.COMMIT_TIME_MSEC_KEY,
String.valueOf(System.currentTimeMillis()));
writer.setCommitData(commitData);
writer.commit();
if (writer.hasUncommittedChanges()) {
final Map<String,String> commitData = new HashMap<String,String>();
commitData.put(SolrIndexWriter.COMMIT_TIME_MSEC_KEY,
String.valueOf(System.currentTimeMillis()));
writer.setCommitData(commitData);
writer.commit();
} else {
log.info("No uncommitted changes. Skipping IW.commit.");
}
// SolrCore.verbose("writer.commit() end");
numDocsPending.set(0);
callPostCommitCallbacks();