|
27 | 27 |
|
28 | 28 | public class SampleOperator implements Operator { |
29 | 29 |
|
30 | | - private boolean finished; |
| 30 | + public record Factory(double probability, int seed) implements OperatorFactory { |
| 31 | + |
| 32 | + @Override |
| 33 | + public SampleOperator get(DriverContext driverContext) { |
| 34 | + return new SampleOperator(probability, seed); |
| 35 | + } |
| 36 | + |
| 37 | + @Override |
| 38 | + public String describe() { |
| 39 | + return "SampleOperator[probability = " + probability + ", seed = " + seed + "]"; |
| 40 | + } |
| 41 | + } |
| 42 | + |
31 | 43 | private final Deque<Page> outputPages; |
32 | 44 | private final RandomSamplingQuery.RandomSamplingIterator randomSamplingIterator; |
| 45 | + private boolean finished; |
33 | 46 |
|
34 | 47 | private int pagesProcessed = 0; |
35 | 48 | private int rowsReceived = 0; |
36 | 49 | private int rowsEmitted = 0; |
37 | | - |
38 | 50 | private long collectNanos; |
39 | 51 | private long emitNanos; |
40 | 52 |
|
41 | | - public SampleOperator(double probability, int seed) { |
| 53 | + private SampleOperator(double probability, int seed) { |
42 | 54 | finished = false; |
43 | 55 | outputPages = new LinkedList<>(); |
44 | 56 | SplittableRandom random = new SplittableRandom(seed); |
45 | 57 | randomSamplingIterator = new RandomSamplingQuery.RandomSamplingIterator(Integer.MAX_VALUE, probability, random::nextInt); |
46 | 58 | randomSamplingIterator.nextDoc(); |
47 | 59 | } |
48 | 60 |
|
49 | | - public record Factory(double probability, int seed) implements OperatorFactory { |
50 | | - |
51 | | - @Override |
52 | | - public SampleOperator get(DriverContext driverContext) { |
53 | | - return new SampleOperator(probability, seed); |
54 | | - } |
55 | | - |
56 | | - @Override |
57 | | - public String describe() { |
58 | | - return "SampleOperator[probability = " + probability + ", seed = " + seed + "]"; |
59 | | - } |
60 | | - } |
61 | | - |
62 | 61 | /** |
63 | 62 | * whether the given operator can accept more input pages |
64 | 63 | */ |
|
0 commit comments