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.
  • Field Details

  • 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 to DEFAULT_MAX_SAMPLES)
      maxSize - The maximum total size of sampled documents (optional, defaults to DEFAULT_MAX_SIZE_GIGABYTES GB)
      timeToLive - The duration for which the sampled documents should be retained (optional, defaults to DEFAULT_TIME_TO_LIVE_DAYS days)
      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

      public SamplingConfiguration(StreamInput in) throws IOException
      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

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • toXContent

      public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface ToXContent
      Throws:
      IOException
    • fromXContent

      public static SamplingConfiguration fromXContent(XContentParser parser) throws IOException
      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

      public static Diff<SamplingConfiguration> readDiffFrom(StreamInput in) throws IOException
      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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • rate

      public double rate()
      Returns the value of the rate record component.
      Returns:
      the value of the rate record component
    • maxSamples

      public Integer maxSamples()
      Returns the value of the maxSamples record component.
      Returns:
      the value of the maxSamples record component
    • maxSize

      public ByteSizeValue maxSize()
      Returns the value of the maxSize record component.
      Returns:
      the value of the maxSize record component
    • timeToLive

      public TimeValue timeToLive()
      Returns the value of the timeToLive record component.
      Returns:
      the value of the timeToLive record component
    • condition

      public String condition()
      Returns the value of the condition record component.
      Returns:
      the value of the condition record component