From cc5998bf6d18e6acfdbccf286589ad248f7fe6cc Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Fri, 26 Jul 2013 15:36:17 +0200 Subject: [PATCH] pass the codec to fix index its not used in Lucene fix index implementation, but just in case, pass it because we can (tm). --- src/main/java/org/elasticsearch/index/engine/Engine.java | 1 + .../elasticsearch/index/engine/robin/RobinEngine.java | 1 - .../index/shard/service/InternalIndexShard.java | 9 +++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/engine/Engine.java b/src/main/java/org/elasticsearch/index/engine/Engine.java index 549186c09ee..7ba902b6a5c 100644 --- a/src/main/java/org/elasticsearch/index/engine/Engine.java +++ b/src/main/java/org/elasticsearch/index/engine/Engine.java @@ -49,6 +49,7 @@ import java.util.List; */ public interface Engine extends IndexShardComponent, CloseableComponent { + static final String INDEX_CODEC = "index.codec"; static ByteSizeValue INACTIVE_SHARD_INDEXING_BUFFER = ByteSizeValue.parseBytesSizeValue("500kb"); /** diff --git a/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java b/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java index cf86272060a..d124d5c2d3e 100644 --- a/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java +++ b/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java @@ -1285,7 +1285,6 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { public static final String INDEX_TERM_INDEX_DIVISOR = "index.term_index_divisor"; public static final String INDEX_INDEX_CONCURRENCY = "index.index_concurrency"; public static final String INDEX_GC_DELETES = "index.gc_deletes"; - public static final String INDEX_CODEC = "index.codec"; public static final String INDEX_FAIL_ON_MERGE_FAILURE = "index.fail_on_merge_failure"; class ApplySettings implements IndexSettingsService.Listener { diff --git a/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java b/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java index 32b2df51b70..65ae09a6770 100644 --- a/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java +++ b/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java @@ -45,6 +45,7 @@ import org.elasticsearch.index.cache.filter.FilterCacheStats; import org.elasticsearch.index.cache.filter.ShardFilterCache; import org.elasticsearch.index.cache.id.IdCacheStats; import org.elasticsearch.index.cache.id.ShardIdCache; +import org.elasticsearch.index.codec.CodecService; import org.elasticsearch.index.engine.*; import org.elasticsearch.index.fielddata.FieldDataStats; import org.elasticsearch.index.fielddata.ShardFieldData; @@ -109,6 +110,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I private final ShardFieldData shardFieldData; private final PercolatorQueriesRegistry percolatorQueriesRegistry; private final ShardPercolateService shardPercolateService; + private final CodecService codecService; private final Object mutex = new Object(); private final String checkIndexOnStartup; @@ -133,7 +135,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I public InternalIndexShard(ShardId shardId, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService, IndicesLifecycle indicesLifecycle, Store store, Engine engine, MergeSchedulerProvider mergeScheduler, Translog translog, ThreadPool threadPool, MapperService mapperService, IndexQueryParserService queryParserService, IndexCache indexCache, IndexAliasesService indexAliasesService, ShardIndexingService indexingService, ShardGetService getService, ShardSearchService searchService, ShardIndexWarmerService shardWarmerService, ShardFilterCache shardFilterCache, ShardIdCache shardIdCache, ShardFieldData shardFieldData, - PercolatorQueriesRegistry percolatorQueriesRegistry, ShardPercolateService shardPercolateService) { + PercolatorQueriesRegistry percolatorQueriesRegistry, ShardPercolateService shardPercolateService, CodecService codecService) { super(shardId, indexSettings); this.indicesLifecycle = (InternalIndicesLifecycle) indicesLifecycle; this.indexSettingsService = indexSettingsService; @@ -155,6 +157,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I this.shardFieldData = shardFieldData; this.percolatorQueriesRegistry = percolatorQueriesRegistry; this.shardPercolateService = shardPercolateService; + this.codecService = codecService; state = IndexShardState.CREATED; this.refreshInterval = indexSettings.getAsTime("engine.robin.refresh_interval", indexSettings.getAsTime(INDEX_REFRESH_INTERVAL, engine.defaultRefreshInterval())); @@ -846,8 +849,6 @@ 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; @@ -871,7 +872,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I if (logger.isDebugEnabled()) { logger.debug("fixing index, writing new segments file ..."); } - checkIndex.fixIndex(status, null); + checkIndex.fixIndex(status, codecService.codec(indexSettings.get(Engine.INDEX_CODEC, "default"))); if (logger.isDebugEnabled()) { logger.debug("index fixed, wrote new segments file \"{}\"", status.segmentsFileName); }