lucene 4: changed InternalIndexShard#checkIndex to use the new fixIndex and indexExists apis

This commit is contained in:
uboness 2012-10-26 15:22:31 +02:00 committed by Shay Banon
parent 8009b80481
commit c3633ab99f
1 changed files with 5 additions and 3 deletions

View File

@ -21,7 +21,7 @@ package org.elasticsearch.index.shard.service;
import com.google.common.base.Charsets;
import org.apache.lucene.index.CheckIndex;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.FilteredQuery;
import org.apache.lucene.search.Query;
@ -808,11 +808,13 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
}
}
//LUCENE 4 UPGRADE: currently passing 'null' codec to fixIndex, when we have proper support for a codec service
// we'll us that to figure out the codec that should be used
private void checkIndex(boolean throwException) throws IndexShardException {
try {
checkIndexTook = 0;
long time = System.currentTimeMillis();
if (!IndexReader.indexExists(store.directory())) {
if (!DirectoryReader.indexExists(store.directory())) {
return;
}
CheckIndex checkIndex = new CheckIndex(store.directory());
@ -831,7 +833,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
if (logger.isDebugEnabled()) {
logger.debug("fixing index, writing new segments file ...");
}
checkIndex.fixIndex(status);
checkIndex.fixIndex(status, null);
if (logger.isDebugEnabled()) {
logger.debug("index fixed, wrote new segments file \"{}\"", status.segmentsFileName);
}