test_class.file: oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/PrefetchIteratorTest.java
test_class.identifier: PrefetchIteratorTest
test_case.body: @Test
      public void testFastSize() {
          Iterable<Integer> s;
          PrefetchIterator<Integer> it;
          s = seq(0, 21);
          it = new PrefetchIterator<Integer>(s.iterator(), 
                  new PrefetchOptions() { {
                      size = -1;
                      fastSize = true;
                      fastSizeCallback = new Result() {
  
                          @Override
                          public String[] getColumnNames() {
                              return null;
                          }
  
                          @Override
                          public String[] getColumnSelectorNames() {
                              return null;
                          }
  
                          @Override
                          public Iterable<? extends ResultRow> getRows() {
                              return null;
                          }
  
                          @Override
                          public String[] getSelectorNames() {
                              return null;
                          }
  
                          @Override
                          public long getSize() {
                              return 100;
                          }
  
                          @Override
                          public long getSize(SizePrecision precision, long max) {
                              return 100;
                          }
                          
                      };
                  } });
          assertEquals(21, it.size());
      }
test_case.class_method_signature: PrefetchIteratorTest.testFastSize()
test_case.full_signature: @Test public void testFastSize()
test_case.identifier: testFastSize
test_case.invocations: seq iterator assertEquals size
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFastSize()
focal_class.declarator: it
focal_class.modifier: private final
focal_class.original_string: private final Iterator<K> it;
focal_class.type: Iterator<K>
focal_class.var_name: it
focal_class.declarator: minPrefetch
focal_class.modifier: private final
focal_class.original_string: private final long minPrefetch, timeout, maxPrefetch;
focal_class.type: long
focal_class.var_name: minPrefetch
focal_class.declarator: fastSize
focal_class.modifier: private final
focal_class.original_string: private final boolean fastSize;
focal_class.type: boolean
focal_class.var_name: fastSize
focal_class.declarator: fastSizeCallback
focal_class.modifier: private final
focal_class.original_string: private final Result fastSizeCallback;
focal_class.type: Result
focal_class.var_name: fastSizeCallback
focal_class.declarator: prefetchDone
focal_class.modifier: private
focal_class.original_string: private boolean prefetchDone;
focal_class.type: boolean
focal_class.var_name: prefetchDone
focal_class.declarator: prefetchIterator
focal_class.modifier: private
focal_class.original_string: private Iterator<K> prefetchIterator;
focal_class.type: Iterator<K>
focal_class.var_name: prefetchIterator
focal_class.declarator: size
focal_class.modifier: private
focal_class.original_string: private long size, position;
focal_class.type: long
focal_class.var_name: size
focal_class.file: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/PrefetchIterator.java
focal_class.identifier: PrefetchIterator
focal_class.interfaces: implements Iterator<K>
focal_class.class_method_signature: PrefetchIterator.PrefetchIterator(Iterator<K> it, PrefetchOptions options)
focal_class.full_signature:   PrefetchIterator(Iterator<K> it, PrefetchOptions options)
focal_class.identifier: PrefetchIterator
focal_class.parameters: (Iterator<K> it, PrefetchOptions options)
focal_class.signature:  PrefetchIterator(Iterator<K> it, PrefetchOptions options)
focal_class.class_method_signature: PrefetchIterator.hasNext()
focal_class.full_signature: @Override public boolean hasNext()
focal_class.identifier: hasNext
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean hasNext()
focal_class.class_method_signature: PrefetchIterator.next()
focal_class.full_signature: @Override public K next()
focal_class.identifier: next
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: K
focal_class.signature: K next()
focal_class.class_method_signature: PrefetchIterator.remove()
focal_class.full_signature: @Override public void remove()
focal_class.identifier: remove
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void remove()
focal_class.class_method_signature: PrefetchIterator.size()
focal_class.full_signature: public long size()
focal_class.identifier: size
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long size()
focal_method.body: public long size() {
          if (size != -1) {
              return size;
          }
          if (!fastSize) {
              if (prefetchDone || position > maxPrefetch) {
                  return -1;
              }
          }
          prefetchDone = true;
          ArrayList<K> list = new ArrayList<K>();
          long end;
          if (timeout <= 0) {
              end = 0;
          } else {
              long nanos = System.nanoTime();
              end = nanos + timeout * 1000 * 1000;
          }
          while (true) {
              if (!it.hasNext()) {
                  size = position;
                  break;
              }
              if (position > maxPrefetch) {
                  break;
              }
              if (position > minPrefetch) {
                  if (end == 0 || System.nanoTime() > end) {
                      break;
                  }
              }
              position++;
              list.add(it.next());
          }
          if (list.size() > 0) {
              prefetchIterator = list.iterator();
              position -= list.size();
          }
          if (size == -1 && fastSize) {
              if (fastSizeCallback != null) {
                  size = fastSizeCallback.getSize(SizePrecision.EXACT, Long.MAX_VALUE);
              }
          }
          return size;
      }
focal_method.class_method_signature: PrefetchIterator.size()
focal_method.full_signature: public long size()
focal_method.identifier: size
focal_method.invocations: nanoTime hasNext nanoTime add next size iterator size getSize
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: long
focal_method.signature: long size()