@Override public Fetcher restoreFetcher(final Cookie cookie) { // log.info("OLD-BROWSE: restoreFetcher"); return new FetcherImpl(service, cookie); }
@Override public void fetchFirst() throws BrowseException { fetch(Page.FIRST, 0); }
@Override public void fetchNext() throws BrowseException { fetchNext(0); }
/** * Fetches a specified page of at most <code>limit</code> results from the browser. * * @param dir specifies which data to fetch * @param limit the maximum number of tuples to fetch * @param skip the number of tuples to skip before fetching results * @throws NoSuchRelationException if the relation is no longer present in the browser * @throws InvalidCookieException if the browser does not recognize the query, * eg. if it expires old queries */ private ResultPage fetch(Page dir, int skip) throws BrowseException { ResultPage result = fetchInitialPageIfNecessary(); if (result==null || !initialPageMatchesFetchRequest(dir, skip)) { DataResponse resp = browser.fetch(new FetchRequest(cookie, dir, pageSize, skip)); checkOther(check(check(resp, InvalidCookieException.class), NoSuchRelationException.class)); if (resp.getEstimatedCount()>=0) { this.count = resp.getEstimatedCount(); } this.cookie = resp.getCookie(); result = new ResultPageImpl(resp.getPage()); } return result; }
@Override public void fetchPrevious() throws BrowseException { fetchPrevious(0); }
@Override public int getEstimatedCount() { try { fetchInitialPageIfNecessary(); if (count == -1 && counter != null) { count = counter.call(); } } catch (Exception e) { // assume that failures mean that we cannot ever get the count counter = null; log.warn("Exception caught while trying to count tuples", e); } return count; }
@Override public ResultPage fetchAndGetNextPage() throws BrowseException { return fetch(Page.NEXT, 0); }
return new FetcherImpl(browser, initialPageCallback, countCallback);
@Override public void fetchNext(int skip) throws BrowseException { fetch(Page.NEXT, skip); }
return new FetcherImpl(browser, initialPageCallback, countCallback);
@Override public void fetchLast() throws BrowseException { fetch(Page.LAST, 0); }
@Override public void fetchPrevious(int skip) throws BrowseException { fetch(Page.PREVIOUS, skip); }
@Override public ResultPage getPage() throws BrowseException { return fetch(Page.CURRENT, 0); }