MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / get_page_statistics

Function get_page_statistics

strings/uca-dump.c:285–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283
284
285static void
286get_page_statistics(MY_UCA *uca, size_t page, size_t level,
287 size_t *maxnum, size_t *ndefs)
288{
289 size_t offs;
290
291 for (offs= 0; offs < MY_UCA_NCHARS; offs++)
292 {
293 size_t i, num;
294 MY_UCA_ITEM *item= &uca->item[page * MY_UCA_NCHARS + offs];
295
296 /* Calculate only non-zero weights */
297 for (num= 0, i= 0; i < item->num; i++)
298 {
299 if (item->weight[level][i])
300 num++;
301 }
302 *maxnum= *maxnum < num ? num : *maxnum;
303
304 /* Check if default weight */
305 if (level == 1 && num == 1)
306 {
307 /* 0020 0000 ... */
308 if (item->weight[level][0] == 0x0020)
309 (*ndefs)++;
310 }
311 else if (level == 2 && num == 1)
312 {
313 /* 0002 0000 ... */
314 if (item->weight[level][0] == 0x0002)
315 (*ndefs)++;
316 }
317 }
318}
319
320
321static const char *pname[]= {"", "_s", "_t", "_q"};

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected