oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/TapeSampling.java [44:71]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public Iterator<T> getSamples() {
        return new AbstractIterator<T>() {
            int sampled = 0;
            int seen = 0;

            @Override
            protected T computeNext() {
                if (sampled == k) {
                    return endOfData();
                }

                while (true) {
                    Preconditions.checkArgument(input.hasNext(),
                            "Not enough input items provided. Declared: " + N + "; got " + seen + "; sampled: " + sampled);

                    T i = input.next();

                    int r = rGen.nextInt(N - seen) + 1;
                    seen++;

                    if (r <= k - sampled) {
                        sampled++;
                        return i;
                    }
                }
            }
        };
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/util/TapeSampling.java [55:82]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public Iterator<T> getSamples() {
        return new AbstractIterator<T>() {
            int sampled = 0;
            int seen = 0;

            @Override
            protected T computeNext() {
                if (sampled == k) {
                    return endOfData();
                }

                while (true) {
                    Preconditions.checkArgument(input.hasNext(),
                            "Not enough input items provided. Declared: " + N + "; got " + seen + "; sampled: " + sampled);

                    T i = input.next();

                    int r = rGen.nextInt(N - seen) + 1;
                    seen++;

                    if (r <= k - sampled) {
                        sampled++;
                        return i;
                    }
                }
            }
        };
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



