code: protected int toNext(int amount) throws FetchException {
          if (amount <= 1) {
              return (amount <= 0) ? 0 : (toNext() ? 1 : 0);
          }
  
          int count = 0;
  
          disableKeyAndValue();
          try {
              while (amount > 0) {
                  if (toNext()) {
                      count++;
                      amount--;
                  } else {
                      break;
                  }
              }
          } finally {
              enableKeyAndValue();
          }
  
          return count;
      }
docs: Move the cursor to the next available entry, incrementing by the amount
  given. The actual amount incremented is returned. If the amount is less
  then requested, the cursor must be positioned after the last available
  entry. Subclasses may wish to override this method with a faster
  implementation.
  
  <p>Calling to toNext(1) is equivalent to calling toNext().
  
  @param amount positive amount to advance
  @return actual amount advanced
  @throws IllegalStateException if cursor is not opened