Skip to content

Commit 04d9b49

Browse files
RajatGupta02Rajat Guptacwperks
authored
Add toBuilder() method in EngineConfig (#19054)
* Add a toBuilder() method Signed-off-by: Rajat Gupta <gptrajat@amazon.com> * Fix release version Signed-off-by: Rajat Gupta <gptrajat@amazon.com> --------- Signed-off-by: Rajat Gupta <gptrajat@amazon.com> Signed-off-by: Craig Perkins <cwperx@amazon.com> Co-authored-by: Rajat Gupta <gptrajat@amazon.com> Co-authored-by: Craig Perkins <cwperx@amazon.com>
1 parent 5c8036d commit 04d9b49

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88
- Expand fetch phase profiling to support inner hits and top hits aggregation phases ([##18936](https://github.com/opensearch-project/OpenSearch/pull/18936))
99
- Add temporal routing processors for time-based document routing ([#18920](https://github.com/opensearch-project/OpenSearch/issues/18920))
1010
- The dynamic mapping parameter supports false_allow_templates ([#19065](https://github.com/opensearch-project/OpenSearch/pull/19065))
11-
11+
- Add a toBuilder method in EngineConfig to support easy modification of configs([#19054](https://github.com/opensearch-project/OpenSearch/pull/19054))
1212

1313
### Changed
1414
- Add CompletionStage variants to methods in the Client Interface and default to ActionListener impl ([#18998](https://github.com/opensearch-project/OpenSearch/pull/18998))

server/src/main/java/org/opensearch/index/codec/CodecService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.lucene.codecs.lucene101.Lucene101Codec;
3838
import org.apache.lucene.codecs.lucene101.Lucene101Codec.Mode;
3939
import org.opensearch.common.Nullable;
40+
import org.opensearch.common.annotation.PublicApi;
4041
import org.opensearch.common.collect.MapBuilder;
4142
import org.opensearch.index.IndexSettings;
4243
import org.opensearch.index.codec.composite.CompositeCodecFactory;
@@ -50,8 +51,9 @@
5051
* data-structures per field. OpenSearch exposes the full
5152
* {@link Codec} capabilities through this {@link CodecService}.
5253
*
53-
* @opensearch.internal
54+
* @opensearch.api
5455
*/
56+
@PublicApi(since = "3.3.0")
5557
public class CodecService {
5658

5759
private final Map<String, Codec> codecs;

server/src/main/java/org/opensearch/index/engine/EngineConfig.java

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,45 @@ public void setEnableGcDeletes(boolean enableGcDeletes) {
317317
this.enableGcDeletes = enableGcDeletes;
318318
}
319319

320+
/**
321+
* Creates a new Builder pre-populated with all values from this EngineConfig.
322+
* This allows for easy modification of specific fields while preserving all others.
323+
*
324+
* @return a new Builder instance with all current configuration values
325+
*/
326+
public Builder toBuilder() {
327+
return new Builder().shardId(this.shardId)
328+
.threadPool(this.threadPool)
329+
.indexSettings(this.indexSettings)
330+
.warmer(this.warmer)
331+
.store(this.store)
332+
.mergePolicy(this.mergePolicy)
333+
.analyzer(this.analyzer)
334+
.similarity(this.similarity)
335+
.codecService(this.codecService)
336+
.eventListener(this.eventListener)
337+
.queryCache(this.queryCache)
338+
.queryCachingPolicy(this.queryCachingPolicy)
339+
.translogConfig(this.translogConfig)
340+
.translogDeletionPolicyFactory(this.translogDeletionPolicyFactory)
341+
.flushMergesAfter(this.flushMergesAfter)
342+
.externalRefreshListener(this.externalRefreshListener)
343+
.internalRefreshListener(this.internalRefreshListener)
344+
.indexSort(this.indexSort)
345+
.circuitBreakerService(this.circuitBreakerService)
346+
.globalCheckpointSupplier(this.globalCheckpointSupplier)
347+
.retentionLeasesSupplier(this.retentionLeasesSupplier)
348+
.primaryTermSupplier(this.primaryTermSupplier)
349+
.tombstoneDocSupplier(this.tombstoneDocSupplier)
350+
.readOnlyReplica(this.isReadOnlyReplica)
351+
.startedPrimarySupplier(this.startedPrimarySupplier)
352+
.translogFactory(this.translogFactory)
353+
.leafSorter(this.leafSorter)
354+
.documentMapperForTypeSupplier(this.documentMapperForTypeSupplier)
355+
.indexReaderWarmer(this.indexReaderWarmer)
356+
.clusterApplierService(this.clusterApplierService);
357+
}
358+
320359
/**
321360
* Returns the initial index buffer size. This setting is only read on startup and otherwise controlled
322361
* by {@link IndexingMemoryController}
@@ -589,8 +628,9 @@ public ClusterApplierService getClusterApplierService() {
589628
/**
590629
* Builder for EngineConfig class
591630
*
592-
* @opensearch.internal
631+
* @opensearch.api
593632
*/
633+
@PublicApi(since = "3.3.0")
594634
public static class Builder {
595635
private ShardId shardId;
596636
private ThreadPool threadPool;

0 commit comments

Comments
 (0)