java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.SampleNode
- Record Components:
probability- the per-row keep probability, in[0, 1]seed- the optional RNG seed for reproducible sampling; empty = non-deterministicinput- the relation to sample; must not be nulllocation- the source location of this node; never null
- All Implemented Interfaces:
RelNode
public record SampleNode(double probability, Optional<Long> seed, RelNode input, SourceLocation location)
extends Record
implements RelNode
Bernoulli sampling (SAMPLE) — independently keeps each row of
input
with probability probability (a fraction in [0, 1]).
It is the streaming, composable form of TABLESAMPLE: every row is an
independent coin flip, so the result size is approximately
probability × |input| and varies from run to run.
Reproducibility: when seed is present the sampling is
deterministic — identical runs produce identical row selections. Without a
seed, fresh randomness is drawn each run.
Examples:
SAMPLE 0.1 (Events)— keeps roughly 10% of the rows (non-deterministic)SAMPLE 0.8 SEED 42 (HistoricalData)— reproducible 80% sample
-
Constructor Summary
ConstructorsConstructorDescriptionSampleNode(double probability, RelNode input) Convenience constructor for tests; usesSourceLocation.UNKNOWNand no seed.SampleNode(double probability, RelNode input, SourceLocation location) Convenience constructor without seed (non-deterministic); uses provided location.SampleNode(double probability, Optional<Long> seed, RelNode input, SourceLocation location) Creates an instance of aSampleNoderecord class. -
Method Summary
Modifier and TypeMethodDescription<R> Raccept(RelNodeVisitor<R> visitor) final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.input()Returns the value of theinputrecord component.location()Returns the value of thelocationrecord component.doubleReturns the value of theprobabilityrecord component.seed()Returns the value of theseedrecord component.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.darkcollective.relix.ast.RelNode
children, mapChildren, materializationMode, prettyPrint
-
Constructor Details
-
SampleNode
Creates an instance of aSampleNoderecord class.- Parameters:
probability- the value for theprobabilityrecord componentseed- the value for theseedrecord componentinput- the value for theinputrecord componentlocation- the value for thelocationrecord component
-
SampleNode
Convenience constructor without seed (non-deterministic); uses provided location. -
SampleNode
Convenience constructor for tests; usesSourceLocation.UNKNOWNand no seed.
-
-
Method Details
-
accept
-
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
Returns the value of theseedrecord component.- Returns:
- the value of the
seedrecord component
-
input
Returns the value of theinputrecord component.- Returns:
- the value of the
inputrecord component
-
location
Returns the value of thelocationrecord component.
-