Manages cycling through the requests as long as
scroller provides next page

Verifies the latest response isn't identical as the last one
to prevent infinite loop on awkward pagination APIs
961796
public function run()
    {
        $this->config->setParams($this->buildParams($this->config));

        $parentId = $this->getParentId();

        $request = $this->firstPage($this->config);
        while ($request !== false) {
            $response = $this->download($request);

            $responseHash = sha1(serialize($response));
            if ($responseHash == $this->lastResponseHash) {
                $this->logger->debug(sprintf(
                    "Job '%s' finished when last response matched the previous!",
                    $this->getJobId()
                ));
                $this->scroller->reset();
                break;
            } else {
                $data = $this->runResponseModules($response, $this->config);
                $data = $this->filterResponse($this->config, $data);
                $this->parse($data, $parentId);

                $this->lastResponseHash = $responseHash;
            }

            $request = $this->nextPage($this->config, $response, $data);
        }
    }
1177210
def next_page(self):
        
        if not self.next_page_url:
            return None

        response = self._version.domain.twilio.request('GET', self.next_page_url)
        cls = type(self)
        return cls(self._version, response, self._solution)
219555
def previous_page(self):
        
        if self.is_first_page():
            return False

        self.page -= 1
        self.items = self.fetch_items()
        return True
1038570
def next_page(self):
        
        if self.is_last_page():
            return False

        self.page += 1
        self.items = self.fetch_items()
        return True
488393
@Override
	public void nextPage() {
		if (!paged) {			
			this.firstPage();
			paged = true;
		} else if (!isLast()) {
			offset = (getPageNumber() + 1) * pageSize;

			execute();
		}
	}
375403
def has_next(self):
        
        try:
            next_item = self.paginator.object_list[self.paginator.per_page]
        except IndexError:
            return False
        return True
861459
public function next()
    {
        ++$this->current_position;

        if(!$this->valid()) {
            $this->current_response = $this->next_response();
            $this->current_page_position = $this->current_position;
        }
    }
1001598
def _has_next_page(self):
        
        if self.page_number == 0:
            return True

        if self.max_results is not None:
            if self.num_results >= self.max_results:
                return False

        # Note: intentionally a falsy check instead of a None check. The RPC
        # can return an empty string indicating no more pages.
        return True if self.next_page_token else False
1039944
def _next_page(self, offset):
        """"""
        self._log.debug("Iterator c_record={}".format(self.c_record))
        page_size = self.page_size
        if (offset + page_size) > self.max_records:
            page_size = self.max_records - offset
        param_dict = self.query_dict.copy()
        param_dict.update(
            {
                'start': str(offset),
                'rows': str(page_size),
                'explainOther': '',
                'hl.fl': '',
            }
        )
        self.res = self.client.search(**param_dict)
        self._num_hits = int(self.res['response']['numFound'])
711786
public function postFetch()
    {
        if ($response = $this->client->getLastResponse()) {
            $this->pagination = ResponseMediator::getPagination($response);
        } else {
            $this->pagination = null;
        }
    }
513781
def _continued_query(self, query_params, key="pages"):
        
        query_params.update(self.__title_query_param())

        last_cont = dict()
        prop = query_params.get("prop")

        while True:
            params = query_params.copy()
            params.update(last_cont)

            request = self.mediawiki.wiki_request(params)

            if "query" not in request:
                break

            pages = request["query"][key]
            if "generator" in query_params:
                for datum in pages.values():
                    yield datum
            elif isinstance(pages, list):
                for datum in list(enumerate(pages)):
                    yield datum[1]
            else:
                for datum in pages[self.pageid].get(prop, list()):
                    yield datum

            if "continue" not in request or request["continue"] == last_cont:
                break

            last_cont = request["continue"]
34587
def continue
      fail 'This is the last page' unless continue?

      action = @action.merge(@metadata.fetch('continue'))

      self.class.new(action, merge_responses(JSON.parse(action.perform)))
    end
1093010
def each_page(&block)
      Enumerator.new do |result|
        next_response = self

        while next_response
          result << next_response.body.to_a
          next_response = next_response.next
        end
      end.each(&block)
    end
1241699
def _get_next_page_response(self):
        
        params = self._get_query_params()
        if self._HTTP_METHOD == "GET":
            return self.api_request(
                method=self._HTTP_METHOD, path=self.path, query_params=params
            )
        elif self._HTTP_METHOD == "POST":
            return self.api_request(
                method=self._HTTP_METHOD, path=self.path, data=params
            )
        else:
            raise ValueError("Unexpected HTTP method", self._HTTP_METHOD)
1118590
def _iterator(self, response):
        '''
        
        '''

        while True:
            result = deque(self._parse_data(response))
            del response
            if result:
                doc_count = len(result)
                last = result.pop()
                while result:
                    yield result.popleft()

                # We expect doc_count = self._page_size + 1 results, if
                # we have self._page_size or less it means we are on the
                # last page and need to return the last result.
                if doc_count < self._real_page_size:
                    yield last
                    break
                del result

                # if we are in a view, keys could be duplicate so we
                # need to start from the right docid
                if last['id']:
                    response = self._call(startkey=last['key'],
                                          startkey_docid=last['id'])
                # reduce result keys are unique by definition
                else:
                    response = self._call(startkey=last['key'])

            else:
                break
916969
public void acknowledgePages(long sequenceId)
    {
        checkArgument(sequenceId >= 0, "Invalid sequence id");

        List<SerializedPageReference> removedPages = new ArrayList<>();
        synchronized (this) {
            if (destroyed.get()) {
                return;
            }

            // if pages have already been acknowledged, just ignore this
            long oldCurrentSequenceId = currentSequenceId.get();
            if (sequenceId < oldCurrentSequenceId) {
                return;
            }

            int pagesToRemove = toIntExact(sequenceId - oldCurrentSequenceId);
            checkArgument(pagesToRemove <= pages.size(), "Invalid sequence id");

            long bytesRemoved = 0;
            for (int i = 0; i < pagesToRemove; i++) {
                SerializedPageReference removedPage = pages.removeFirst();
                removedPages.add(removedPage);
                bytesRemoved += removedPage.getRetainedSizeInBytes();
            }

            // update current sequence id
            verify(currentSequenceId.compareAndSet(oldCurrentSequenceId, oldCurrentSequenceId + pagesToRemove));

            // update memory tracking
            verify(bufferedBytes.addAndGet(-bytesRemoved) >= 0);
        }

        // dereference outside of synchronized to avoid making a callback while holding a lock
        removedPages.forEach(SerializedPageReference::dereferencePage);
    }
1374157
protected void getNextPage() {
		    	    	
        final JSONObject params = new JSONObject();
        
        page++;
        
        params.put("page", page);
        params.put("size", size);
        
        clear();
        
        getPage(params);
                
	}