MCPcopy
hub / github.com/google/clusterfuzz / query

Method query

src/clusterfuzz/_internal/google_cloud_utils/big_query.py:239–274  ·  view source on GitHub ↗

Performs a query and returns an array of dicts.

(self,
            query,
            timeout=QUERY_TIMEOUT,
            max_results=QUERY_MAX_RESULTS,
            offset=0,
            limit=None)

Source from the content-addressed store, hash-verified

237 time.sleep(1)
238
239 def query(self,
240 query,
241 timeout=QUERY_TIMEOUT,
242 max_results=QUERY_MAX_RESULTS,
243 offset=0,
244 limit=None):
245 """Performs a query and returns an array of dicts."""
246 rows = []
247 start_time = time.time()
248
249 result = self.raw_query(query, max_results=0)
250
251 result = self.wait_for_completion(
252 job_id=result['jobReference']['jobId'],
253 offset=offset,
254 max_results=_get_max_results(max_results, limit, 0),
255 start_time=start_time,
256 timeout=timeout)
257
258 # totalRows is only present after the job completed successfully.
259 total_count = int(result['totalRows'])
260
261 while limit is None or len(rows) < limit:
262 rows += convert(result)
263
264 if result['jobComplete'] and 'pageToken' not in result:
265 total_count = int(result['totalRows'])
266 break
267
268 result = self.get_query_results(
269 job_id=result['jobReference']['jobId'],
270 page_token=result.get('pageToken'),
271 start_index=0,
272 max_results=_get_max_results(max_results, limit, len(rows)))
273
274 return QueryResult(rows=rows, total_count=total_count)
275
276 @retry.wrap(
277 retries=QUERY_RETRY_COUNT,

Callers 15

getFunction · 0.95
getFunction · 0.95
get_last_crash_timeFunction · 0.95
get_start_hourFunction · 0.95
_query_fuzzer_statsFunction · 0.95
test_one_pageMethod · 0.95
test_multiple_pageMethod · 0.95
test_not_completeMethod · 0.95
test_timeoutMethod · 0.95
getMethod · 0.80

Calls 7

raw_queryMethod · 0.95
wait_for_completionMethod · 0.95
get_query_resultsMethod · 0.95
_get_max_resultsFunction · 0.85
convertFunction · 0.85
timeMethod · 0.80
getMethod · 0.45

Tested by 15

test_one_pageMethod · 0.76
test_multiple_pageMethod · 0.76
test_not_completeMethod · 0.76
test_timeoutMethod · 0.76
query_testcaseFunction · 0.64
_handle_uploadMethod · 0.64
get_variantsMethod · 0.64
unpack_crash_testcasesFunction · 0.64
_testMethod · 0.64