Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

package org.elasticsearch.index.codec;

import org.apache.lucene.codecs.Codec;

/**
* Abstracts codec lookup by name, to make CodecService extensible.
*/
@FunctionalInterface
public interface CodecProvider {
Codec codec(String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* data-structures per field. Elasticsearch exposes the full
* {@link Codec} capabilities through this {@link CodecService}.
*/
public class CodecService {
public class CodecService implements CodecProvider {

public static final FeatureFlag ZSTD_STORED_FIELDS_FEATURE_FLAG = new FeatureFlag("zstd_stored_fields");

Expand Down Expand Up @@ -86,7 +86,8 @@ public Codec codec(String name) {
}

/**
* Returns all registered available codec names
* Returns all registered available codec names.
* Public visibility for tests.
*/
public String[] availableCodecs() {
return codecs.keySet().toArray(new String[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.codec.CodecService;
import org.elasticsearch.index.codec.CodecProvider;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.seqno.RetentionLeases;
import org.elasticsearch.index.shard.ShardId;
Expand Down Expand Up @@ -60,7 +60,7 @@ public final class EngineConfig {
private final MergePolicy mergePolicy;
private final Analyzer analyzer;
private final Similarity similarity;
private final CodecService codecService;
private final CodecProvider codecProvider;
private final Engine.EventListener eventListener;
private final QueryCache queryCache;
private final QueryCachingPolicy queryCachingPolicy;
Expand Down Expand Up @@ -148,7 +148,7 @@ public EngineConfig(
MergePolicy mergePolicy,
Analyzer analyzer,
Similarity similarity,
CodecService codecService,
CodecProvider codecProvider,
Engine.EventListener eventListener,
QueryCache queryCache,
QueryCachingPolicy queryCachingPolicy,
Expand Down Expand Up @@ -176,7 +176,7 @@ public EngineConfig(
this.mergePolicy = mergePolicy;
this.analyzer = analyzer;
this.similarity = similarity;
this.codecService = codecService;
this.codecProvider = codecProvider;
this.eventListener = eventListener;
codecName = indexSettings.getValue(INDEX_CODEC_SETTING);
this.mapperService = mapperService;
Expand Down Expand Up @@ -252,14 +252,22 @@ public boolean isEnableGcDeletes() {
* </p>
*/
public Codec getCodec() {
return codecService.codec(codecName);
return codecProvider.codec(codecName);
}

/**
* @return the {@link CodecService}
* @return the {@link CodecProvider}
*/
public CodecService getCodecService() {
return codecService;
public CodecProvider getCodecProvider() {
return codecProvider;
}

/**
* @return the {@link CodecProvider}
*/
@Deprecated // to avoid breaking serverless, just temporary
public CodecProvider getCodecService() {
return codecProvider;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public static EngineConfig copy(EngineConfig config, LongSupplier globalCheckpoi
config.getMergePolicy(),
config.getAnalyzer(),
config.getSimilarity(),
config.getCodecService(),
config.getCodecProvider(),
config.getEventListener(),
config.getQueryCache(),
config.getQueryCachingPolicy(),
Expand Down Expand Up @@ -282,7 +282,7 @@ public EngineConfig copy(EngineConfig config, Analyzer analyzer) {
config.getMergePolicy(),
analyzer,
config.getSimilarity(),
config.getCodecService(),
config.getCodecProvider(),
config.getEventListener(),
config.getQueryCache(),
config.getQueryCachingPolicy(),
Expand Down Expand Up @@ -314,7 +314,7 @@ public EngineConfig copy(EngineConfig config, MergePolicy mergePolicy) {
mergePolicy,
config.getAnalyzer(),
config.getSimilarity(),
config.getCodecService(),
config.getCodecProvider(),
config.getEventListener(),
config.getQueryCache(),
config.getQueryCachingPolicy(),
Expand Down