1 | /* |
---|---|
2 | Copyright (c) 2015 MariaDB Corporation Ab |
3 | |
4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by |
6 | the Free Software Foundation; version 2 of the License. |
7 | |
8 | This program is distributed in the hope that it will be useful, |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | GNU General Public License for more details. |
12 | |
13 | You should have received a copy of the GNU General Public License |
14 | along with this program; if not, write to the Free Software |
15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ |
16 | |
17 | #ifdef USE_PRAGMA_IMPLEMENTATION |
18 | #pragma implementation // gcc: Class implementation |
19 | #endif |
20 | |
21 | #include "mariadb.h" |
22 | #include "sql_priv.h" |
23 | #include "sql_select.h" |
24 | #include "my_json_writer.h" |
25 | |
26 | void Filesort_tracker::print_json_members(Json_writer *writer) |
27 | { |
28 | const char *varied_str= "(varied across executions)"; |
29 | |
30 | if (!get_r_loops()) |
31 | writer->add_member("r_loops").add_null(); |
32 | else |
33 | writer->add_member("r_loops").add_ll(get_r_loops()); |
34 | |
35 | if (get_r_loops() && time_tracker.timed) |
36 | { |
37 | writer->add_member("r_total_time_ms"). |
38 | add_double(time_tracker.get_time_ms()); |
39 | } |
40 | if (r_limit != HA_POS_ERROR) |
41 | { |
42 | writer->add_member("r_limit"); |
43 | if (!get_r_loops()) |
44 | writer->add_null(); |
45 | else if (r_limit == 0) |
46 | writer->add_str(varied_str); |
47 | else |
48 | writer->add_ll((longlong) rint(r_limit/get_r_loops())); |
49 | } |
50 | |
51 | writer->add_member("r_used_priority_queue"); |
52 | if (!get_r_loops()) |
53 | writer->add_null(); |
54 | else if (r_used_pq == get_r_loops()) |
55 | writer->add_bool(true); |
56 | else if (r_used_pq == 0) |
57 | writer->add_bool(false); |
58 | else |
59 | writer->add_str(varied_str); |
60 | |
61 | if (!get_r_loops()) |
62 | writer->add_member("r_output_rows").add_null(); |
63 | else |
64 | writer->add_member("r_output_rows").add_ll((longlong) rint(r_output_rows / |
65 | get_r_loops())); |
66 | |
67 | if (sort_passes) |
68 | { |
69 | writer->add_member("r_sort_passes").add_ll((longlong) rint(sort_passes / |
70 | get_r_loops())); |
71 | } |
72 | |
73 | if (sort_buffer_size != 0) |
74 | { |
75 | writer->add_member("r_buffer_size"); |
76 | if (sort_buffer_size == ulonglong(-1)) |
77 | writer->add_str(varied_str); |
78 | else |
79 | writer->add_size(sort_buffer_size); |
80 | } |
81 | } |
82 | |
83 |