code: public long count(FilterValues<S> values) throws FetchException {
          Cursor<S> cursor = fetch(values);
          try {
              long count = cursor.skipNext(Integer.MAX_VALUE);
              if (count == Integer.MAX_VALUE) {
                  int amt;
                  while ((amt = cursor.skipNext(Integer.MAX_VALUE)) > 0) {
                      count += amt;
                  }
              }
              return count;
          } finally {
              cursor.close();
          }
      }
docs: Counts results by opening a cursor and skipping entries. Subclasses are
  encouraged to override with a more efficient implementation.