def _scan_hit_region_once(self, previous_stop_key, table, start_key, stop_key, families, filters): try: # Lookup the next region to scan by searching for the # previous_stop_key (region keys are inclusive on the start and # exclusive on the end) cur_region = self._find_hosting_region( table, previous_stop_key) except PyBaseException as e: # This means that either Master is down or something's funky with the META region. Try handling it # and recursively perform the same call again. e._handle_exception(self) return self._scan_hit_region_once(previous_stop_key, table, start_key, stop_key, families, filters) # Create the scan request object. The last two values are 'Close' and # 'Scanner_ID' respectively. rq = request.scan_request( cur_region, start_key, stop_key, families, filters, False, None) try: # Send the request. response = cur_region.region_client._send_request(rq) except PyBaseException as e: # Uh oh. Probably a region/region server issue. Handle it and try # again. e._handle_exception(self, dest_region=cur_region) return self._scan_hit_region_once(previous_stop_key, table, start_key, stop_key, families, filters) return response, cur_region
def _scan_hit_region_once(self, previous_stop_key, table, start_key, stop_key, families, filters): try: # Lookup the next region to scan by searching for the # previous_stop_key (region keys are inclusive on the start and # exclusive on the end) cur_region = self._find_hosting_region(table, previous_stop_key) except PyBaseException as e: # This means that either Master is down or something's funky with the META region. Try handling it # and recursively perform the same call again. e._handle_exception(self) return self._scan_hit_region_once(previous_stop_key, table, start_key, stop_key, families, filters) # Create the scan request object. The last two values are 'Close' and # 'Scanner_ID' respectively. rq = request.scan_request(cur_region, start_key, stop_key, families, filters, False, None) try: # Send the request. response = cur_region.region_client._send_request(rq) except PyBaseException as e: # Uh oh. Probably a region/region server issue. Handle it and try # again. e._handle_exception(self, dest_region=cur_region) return self._scan_hit_region_once(previous_stop_key, table, start_key, stop_key, families, filters) return response, cur_region
def _scan_region_while_more_results(self, cur_region, response): # Create our own intermediate response set. response_set = Result(None) # Grab the scanner_id from the first_response. scanner_id = response.scanner_id # We only need to specify the scanner_id here because the region we're # pinging remembers our query based on the scanner_id. rq = request.scan_request( cur_region, None, None, None, None, False, scanner_id) while response.more_results_in_region: # Repeatedly hit it until empty. Note that we're not handling any # exceptions here, instead letting them bubble up because if any # of these calls fail we need to rescan the whole region (it seems # like a lot of work to search the results for the max row key that # we've received so far and rescan from there up) response = cur_region.region_client._send_request(rq) response_set._append_response(response) # Now close the scanner. rq = request.scan_request( cur_region, None, None, None, None, True, scanner_id) _ = cur_region.region_client._send_request(rq) # Close it and return the results! return response_set
def _scan_region_while_more_results(self, cur_region, response): # Create our own intermediate response set. response_set = Result(None) # Grab the scanner_id from the first_response. scanner_id = response.scanner_id # We only need to specify the scanner_id here because the region we're # pinging remembers our query based on the scanner_id. rq = request.scan_request(cur_region, None, None, None, None, False, scanner_id) while response.more_results_in_region: # Repeatedly hit it until empty. Note that we're not handling any # exceptions here, instead letting them bubble up because if any # of these calls fail we need to rescan the whole region (it seems # like a lot of work to search the results for the max row key that # we've received so far and rescan from there up) response = cur_region.region_client._send_request(rq) response_set._append_response(response) # Now close the scanner. rq = request.scan_request(cur_region, None, None, None, None, True, scanner_id) _ = cur_region.region_client._send_request(rq) # Close it and return the results! return response_set