/* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
namespace OpenSearch.Client.Specification.IndicesApi
{
public interface IMergePolicySettings
{
///
/// When expungeDeletes is called, we only merge away a segment if its delete percentage
/// is over this threshold. Default is 10.
///
int? ExpungeDeletesAllowed { get; set; }
///
/// Segments smaller than this are "rounded up" to this size, i.e. treated as equal (floor) size for merge selection.
/// This is to prevent frequent flushing of tiny segments, thus preventing a long tail in the index. Default is 2mb.
///
string FloorSegment { get; set; }
///
/// Maximum number of segments to be merged at a time during "normal" merging. Default is 10.
///
int? MaxMergeAtOnce { get; set; }
///
/// Maximum number of segments to be merged at a time, during optimize or expungeDeletes. Default is 30.
///
int? MaxMergeAtOnceExplicit { get; set; }
///
/// Maximum sized segment to produce during normal merging (not explicit optimize).
/// This setting is approximate: the estimate of the merged segment size is made by summing
/// sizes of to-be-merged segments (compensating for percent deleted docs). Default is 5gb.
///
string MaxMergedSegment { get; set; }
///
/// Controls how aggressively merges that reclaim more deletions are favored. Higher values
/// favor selecting merges that reclaim deletions. A value of 0.0 means deletions don’t
/// impact merge selection. Defaults to 2.0
///
double? ReclaimDeletesWeight { get; set; }
///
/// Sets the allowed number of segments per tier. Smaller values mean more merging but fewer segments.
/// Default is 10. Note, this value needs to be >= than the max_merge_at_once otherwise you’ll force too
/// many merges to occur.
///
int? SegmentsPerTier { get; set; }
}
public class MergePolicySettings : IMergePolicySettings
{
///
public int? ExpungeDeletesAllowed { get; set; }
///
public string FloorSegment { get; set; }
///
public int? MaxMergeAtOnce { get; set; }
///
public int? MaxMergeAtOnceExplicit { get; set; }
///
public string MaxMergedSegment { get; set; }
///
public double? ReclaimDeletesWeight { get; set; }
///
public int? SegmentsPerTier { get; set; }
}
public class MergePolicySettingsDescriptor
: DescriptorBase, IMergePolicySettings
{
int? IMergePolicySettings.ExpungeDeletesAllowed { get; set; }
string IMergePolicySettings.FloorSegment { get; set; }
int? IMergePolicySettings.MaxMergeAtOnce { get; set; }
int? IMergePolicySettings.MaxMergeAtOnceExplicit { get; set; }
string IMergePolicySettings.MaxMergedSegment { get; set; }
double? IMergePolicySettings.ReclaimDeletesWeight { get; set; }
int? IMergePolicySettings.SegmentsPerTier { get; set; }
///
public MergePolicySettingsDescriptor ExpungeDeletesAllowed(int? allowed) =>
Assign(allowed, (a, v) => a.ExpungeDeletesAllowed = v);
///
public MergePolicySettingsDescriptor FloorSegment(string floorSegment) =>
Assign(floorSegment, (a, v) => a.FloorSegment = v);
///
public MergePolicySettingsDescriptor MaxMergeAtOnce(int? maxMergeAtOnce) =>
Assign(maxMergeAtOnce, (a, v) => a.MaxMergeAtOnce = v);
///
public MergePolicySettingsDescriptor MaxMergeAtOnceExplicit(int? maxMergeOnceAtOnceExplicit) =>
Assign(maxMergeOnceAtOnceExplicit, (a, v) => a.MaxMergeAtOnceExplicit = v);
///
public MergePolicySettingsDescriptor MaxMergedSegement(string maxMergedSegment) =>
Assign(maxMergedSegment, (a, v) => a.MaxMergedSegment = v);
///
public MergePolicySettingsDescriptor ReclaimDeletesWeight(double? weight) =>
Assign(weight, (a, v) => a.ReclaimDeletesWeight = v);
///
public MergePolicySettingsDescriptor SegmentsPerTier(int? segmentsPerTier) =>
Assign(segmentsPerTier, (a, v) => a.SegmentsPerTier = v);
}
}