MCPcopy Create free account
hub / github.com/MariaDB/server / parse_bucket

Method parse_bucket

sql/opt_histogram_json.cc:526–680  ·  view source on GitHub ↗

@brief Parse a JSON representation for one histogram bucket @param je The JSON parser object @param field Table field we are using histogram (used to convert endpoints from text representation to binary) @param total_size INOUT Fraction of the table rows in the buckets parsed so far. @param assigned_last_end OUT TRUE<=>

Source from the content-addressed store, hash-verified

524 -1 EOF
525*/
526int Histogram_json_hb::parse_bucket(json_engine_t *je, Field *field,
527 double *total_size,
528 bool *assigned_last_end,
529 const char **err)
530{
531 *assigned_last_end= false;
532 if (json_scan_next(je))
533 return 1;
534 if (je->state != JST_VALUE)
535 {
536 if (je->state == JST_ARRAY_END)
537 return -1; // EOF
538 else
539 return 1; // An error
540 }
541
542 if (json_scan_next(je) || je->state != JST_OBJ_START)
543 {
544 *err= "Expected an object in the buckets array";
545 return 1;
546 }
547
548 bool have_start= false;
549 bool have_size= false;
550 bool have_ndv= false;
551 CHARSET_INFO *cs;
552
553 if (!(cs= field->charset()))
554 cs= &my_charset_bin;
555
556 double size_d;
557 longlong ndv_ll= 0;
558 StringBuffer<128> value_buf(cs);
559 int rc;
560
561 while (!(rc= json_scan_next(je)) && je->state != JST_OBJ_END)
562 {
563 Json_saved_parser_state save1(je);
564 Json_string start_str("start");
565 if (json_key_matches(je, start_str.get()))
566 {
567 if (read_bucket_endpoint(je, field, &value_buf, err))
568 return 1;
569
570 have_start= true;
571 continue;
572 }
573 save1.restore_to(je);
574
575 Json_string size_str("size");
576 if (json_key_matches(je, size_str.get()))
577 {
578 if (json_read_value(je))
579 return 1;
580
581 const char *size= (const char*)je->value_begin;
582 char *size_end= (char*)je->value_end;
583 int conv_err;

Callers

nothing calls this directly

Calls 15

json_scan_nextFunction · 0.85
json_key_matchesFunction · 0.85
read_bucket_endpointFunction · 0.85
json_read_valueFunction · 0.85
my_strtodFunction · 0.85
my_strtoll10Function · 0.85
read_hex_bucket_endpointFunction · 0.85
json_skip_keyFunction · 0.85
stringClass · 0.85
restore_toMethod · 0.80
assignMethod · 0.80
charsetMethod · 0.45

Tested by

no test coverage detected