Module org.elasticsearch.server
Record Class SamplingContext
java.lang.Object
java.lang.Record
org.elasticsearch.search.aggregations.support.SamplingContext
This provides information around the current sampling context for aggregations
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSamplingContext(double probability, int seed, Integer shardSeed) Creates an instance of aSamplingContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.lucene.search.QuerybuildQueryWithSampler(QueryBuilder builder, AggregationContext context) Builds the provided query builder into a Lucene query object.Optional<org.apache.lucene.search.Query> final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleandoubleReturns the value of theprobabilityrecord component.doublescaleDown(double value) Scales the given value according to the configured sampling probability.longscaleDown(long value) Scales the given value according to the configured sampling probability.doublescaleUp(double value) This scales the given value according to the inverse of the configured sampling probabilitylongscaleUp(long value) This scales the given value according to the inverse of the configured sampling probability The value is rounded to the nearest whole valueintseed()Returns the value of theseedrecord component.Returns the value of theshardSeedrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
NONE
-
-
Constructor Details
-
SamplingContext
Creates an instance of aSamplingContextrecord class.- Parameters:
probability- the value for theprobabilityrecord componentseed- the value for theseedrecord componentshardSeed- the value for theshardSeedrecord component
-
-
Method Details
-
isSampled
public boolean isSampled() -
scaleDown
public long scaleDown(long value) Scales the given value according to the configured sampling probability. If the sampling context is NONE, then no scaling takes place.- Parameters:
value- the value to scale- Returns:
- the scaled value, or the passed value if no sampling is configured
-
scaleUp
public long scaleUp(long value) This scales the given value according to the inverse of the configured sampling probability The value is rounded to the nearest whole value- Parameters:
value- the value to inversely scale- Returns:
- the scaled value, or the passed value if no sampling has been configured
-
scaleDown
public double scaleDown(double value) Scales the given value according to the configured sampling probability. If the sampling context is NONE, then no scaling takes place.- Parameters:
value- the value to scale- Returns:
- the scaled value, or the passed value if no sampling is configured
-
scaleUp
public double scaleUp(double value) This scales the given value according to the inverse of the configured sampling probability- Parameters:
value- the value to inversely scale- Returns:
- the scaled value, or the passed value if no sampling has been configured
-
buildQueryWithSampler
public org.apache.lucene.search.Query buildQueryWithSampler(QueryBuilder builder, AggregationContext context) throws IOException Builds the provided query builder into a Lucene query object. The returned query takes sampling into account.- Parameters:
builder- The filter query to build along with the random sampling querycontext- The current aggregation context- Returns:
- A lucene query that takes sampling into account if necessary
- Throws:
IOException- on query build failure
-
buildSamplingQueryIfNecessary
public Optional<org.apache.lucene.search.Query> buildSamplingQueryIfNecessary(AggregationContext context) - Parameters:
context- The current aggregation context- Returns:
- the sampling query if the sampling context indicates that sampling is required
-
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 '=='. -
probability
public double probability()Returns the value of theprobabilityrecord component.- Returns:
- the value of the
probabilityrecord component
-
seed
public int seed()Returns the value of theseedrecord component.- Returns:
- the value of the
seedrecord component
-
shardSeed
Returns the value of theshardSeedrecord component.- Returns:
- the value of the
shardSeedrecord component
-