test_class.file: oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/TapeSamplingTest.java
test_class.identifier: TapeSamplingTest
test_case.body: @Test
      public void allItemsWhenKisN() {
          final int start = 11;
          final int end = 20;
          final int k = 10;
          final Random r = new Random();
  
          List<Integer> input = range(start, end);
          TapeSampling<Integer> res = new TapeSampling<>(r, input.iterator(), input.size(), k);
  
          List<Integer> samples = newArrayList(res.getSamples());
          List<Integer> expected = input;
  
          assertEquals(expected, samples);
      }
test_case.class_method_signature: TapeSamplingTest.allItemsWhenKisN()
test_case.full_signature: @Test public void allItemsWhenKisN()
test_case.identifier: allItemsWhenKisN
test_case.invocations: range iterator size newArrayList getSamples assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void allItemsWhenKisN()
focal_class.declarator: rGen
focal_class.modifier: private final
focal_class.original_string: private final Random rGen;
focal_class.type: Random
focal_class.var_name: rGen
focal_class.declarator: input
focal_class.modifier: private final
focal_class.original_string: private final Iterator<T> input;
focal_class.type: Iterator<T>
focal_class.var_name: input
focal_class.declarator: N
focal_class.modifier: private final
focal_class.original_string: private final int N;
focal_class.type: int
focal_class.var_name: N
focal_class.declarator: k
focal_class.modifier: private final
focal_class.original_string: private final int k;
focal_class.type: int
focal_class.var_name: k
focal_class.file: oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/TapeSampling.java
focal_class.identifier: TapeSampling
focal_class.class_method_signature: TapeSampling.TapeSampling(final Random rGen, final Iterator<T> input, final int N, final int k)
focal_class.full_signature: public  TapeSampling(final Random rGen, final Iterator<T> input, final int N, final int k)
focal_class.identifier: TapeSampling
focal_class.modifiers: public
focal_class.parameters: (final Random rGen, final Iterator<T> input, final int N, final int k)
focal_class.signature:  TapeSampling(final Random rGen, final Iterator<T> input, final int N, final int k)
focal_class.class_method_signature: TapeSampling.getSamples()
focal_class.full_signature: public Iterator<T> getSamples()
focal_class.identifier: getSamples
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Iterator<T>
focal_class.signature: Iterator<T> getSamples()
focal_method.body: 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;
                      }
                  }
              }
          };
      }
focal_method.class_method_signature: TapeSampling.getSamples()
focal_method.full_signature: public Iterator<T> getSamples()
focal_method.identifier: getSamples
focal_method.invocations: endOfData checkArgument hasNext next nextInt
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: Iterator<T>
focal_method.signature: Iterator<T> getSamples()