Module org.elasticsearch.server
Record Class SamplingConfiguration
java.lang.Object
java.lang.Record
org.elasticsearch.action.admin.indices.sampling.SamplingConfiguration
- All Implemented Interfaces:
Diffable<SamplingConfiguration>,SimpleDiffable<SamplingConfiguration>,Writeable,ToXContent,ToXContentObject
public record SamplingConfiguration(double rate, Integer maxSamples, ByteSizeValue maxSize, TimeValue timeToLive, String condition)
extends Record
implements ToXContentObject, SimpleDiffable<SamplingConfiguration>
Configuration for sampling raw documents in an index.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.cluster.SimpleDiffable
SimpleDiffable.CompleteDiff<T extends Diffable<T>>Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final longstatic final longstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final longstatic final longstatic final StringFields inherited from interface org.elasticsearch.cluster.SimpleDiffable
EMPTYFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionSamplingConfiguration(double rate, Integer maxSamples, ByteSizeValue maxSize, TimeValue timeToLive, String condition) Constructor with validation and defaulting for optional fields.Constructs a SamplingConfiguration from a StreamInput for wire protocol deserialization. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theconditionrecord component.final booleanIndicates whether some other object is "equal to" this one.static SamplingConfigurationfromXContent(XContentParser parser) Parses a SamplingConfiguration from XContent (JSON).final inthashCode()Returns a hash code value for this object.Returns the value of themaxSamplesrecord component.maxSize()Returns the value of themaxSizerecord component.doublerate()Returns the value of theraterecord component.static Diff<SamplingConfiguration> Creates a diff reader for SamplingConfiguration objects that can deserialize diffs from wire protocol.Returns the value of thetimeToLiverecord component.final StringtoString()Returns a string representation of this record class.toXContent(XContentBuilder builder, ToXContent.Params params) voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.cluster.SimpleDiffable
diffMethods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
TYPE
- See Also:
-
MAX_SAMPLES_LIMIT
public static final int MAX_SAMPLES_LIMIT- See Also:
-
MAX_SIZE_LIMIT_GIGABYTES
public static final long MAX_SIZE_LIMIT_GIGABYTES- See Also:
-
MAX_TIME_TO_LIVE_DAYS
public static final long MAX_TIME_TO_LIVE_DAYS- See Also:
-
DEFAULT_MAX_SAMPLES
public static final int DEFAULT_MAX_SAMPLES- See Also:
-
DEFAULT_MAX_SIZE_GIGABYTES
public static final long DEFAULT_MAX_SIZE_GIGABYTES- See Also:
-
DEFAULT_TIME_TO_LIVE_DAYS
public static final long DEFAULT_TIME_TO_LIVE_DAYS- See Also:
-
INVALID_RATE_MESSAGE
- See Also:
-
INVALID_MAX_SAMPLES_MIN_MESSAGE
- See Also:
-
INVALID_MAX_SAMPLES_MAX_MESSAGE
- See Also:
-
INVALID_MAX_SIZE_MIN_MESSAGE
- See Also:
-
INVALID_MAX_SIZE_MAX_MESSAGE
- See Also:
-
INVALID_TIME_TO_LIVE_MIN_MESSAGE
- See Also:
-
INVALID_TIME_TO_LIVE_MAX_MESSAGE
- See Also:
-
INVALID_CONDITION_MESSAGE
- See Also:
-
-
Constructor Details
-
SamplingConfiguration
public SamplingConfiguration(double rate, Integer maxSamples, ByteSizeValue maxSize, TimeValue timeToLive, String condition) Constructor with validation and defaulting for optional fields.- Parameters:
rate- The fraction of documents to sample (must be between 0 and 1)maxSamples- The maximum number of documents to sample (optional, defaults toDEFAULT_MAX_SAMPLES)maxSize- The maximum total size of sampled documents (optional, defaults toDEFAULT_MAX_SIZE_GIGABYTESGB)timeToLive- The duration for which the sampled documents should be retained (optional, defaults toDEFAULT_TIME_TO_LIVE_DAYSdays)condition- An optional condition script that sampled documents must satisfy (optional, can be null)- Throws:
IllegalArgumentException- If any of the parameters are invalid, according to the validation rules
-
SamplingConfiguration
Constructs a SamplingConfiguration from a StreamInput for wire protocol deserialization.- Parameters:
in- The StreamInput to read from- Throws:
IOException- If an I/O error occurs during deserialization
-
-
Method Details
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
fromXContent
Parses a SamplingConfiguration from XContent (JSON).- Parameters:
parser- The XContentParser to parse from- Returns:
- The parsed SamplingConfiguration object
- Throws:
IOException- If parsing fails due to invalid JSON or I/O errors
-
readDiffFrom
Creates a diff reader for SamplingConfiguration objects that can deserialize diffs from wire protocol.- Parameters:
in- The StreamInput to read the diff from- Returns:
- A Diff that can be applied to produce the target SamplingConfiguration
- Throws:
IOException- If an I/O error occurs during deserialization
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
rate
public double rate()Returns the value of theraterecord component.- Returns:
- the value of the
raterecord component
-
maxSamples
Returns the value of themaxSamplesrecord component.- Returns:
- the value of the
maxSamplesrecord component
-
maxSize
Returns the value of themaxSizerecord component.- Returns:
- the value of the
maxSizerecord component
-
timeToLive
Returns the value of thetimeToLiverecord component.- Returns:
- the value of the
timeToLiverecord component
-
condition
Returns the value of theconditionrecord component.- Returns:
- the value of the
conditionrecord component
-