Overpass API regression suite coverage (Saxony) / overpass_api/dispatch/resource_manager.cc

overpass_api/dispatch/resource_manager.cc

422 of 531 instrumented lines run by the suite (79.5%) at 8edf11b0419c (this file on GitHub).

runnever runcolumns: line, executions, queries (click for the queries that run the line)

1/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al.
2 *
3 * This file is part of Overpass_API.
4 *
5 * Overpass_API is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * Overpass_API is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.
17 */
19#include "resource_manager.h"
20#include "../data/abstract_processing.h"
21#include "../data/utils.h"
22#include "../statements/statement.h"
24#include <sstream>
27uint64 eval_map(const std::map< Uint32_Index, std::vector< Node_Skeleton > >& nodes)
28156881670 q{
29156881670 q uint64 size(0);
30156881670 q for (std::map< Uint32_Index, std::vector< Node_Skeleton > >::const_iterator
3121763080670 q it(nodes.begin()); it != nodes.end(); ++it)
3221606199326 q size += it->second.size()*8 + 64;
33156881670 q return size;
34156881670 q}
37uint64 eval_map(const std::map< Uint31_Index, std::vector< Way_Skeleton > >& ways)
38154238670 q{
39154238670 q uint64 size(0);
40154238670 q for (std::map< Uint31_Index, std::vector< Way_Skeleton > >::const_iterator
412817048670 q it(ways.begin()); it != ways.end(); ++it)
422662810349 q size += it->second.size()*128 + 64;
43154238670 q return size;
44154238670 q}
47uint64 eval_map(const std::map< Uint31_Index, std::vector< Relation_Skeleton > >& relations)
48153693670 q{
49153693670 q uint64 size(0);
50153693670 q for (std::map< Uint31_Index, std::vector< Relation_Skeleton > >::const_iterator
51394076670 q it(relations.begin()); it != relations.end(); ++it)
52240383211 q size += it->second.size()*192 + 64;
53153693670 q return size;
54153693670 q}
57uint64 eval_map(const std::map< Uint32_Index, std::vector< Attic< Node_Skeleton > > >& nodes)
58155701670 q{
59155701670 q uint64 size(0);
60155701670 q for (std::map< Uint32_Index, std::vector< Attic< Node_Skeleton > > >::const_iterator
618943490670 q it(nodes.begin()); it != nodes.end(); ++it)
628787789140 q size += it->second.size()*16 + 64;
63155701670 q return size;
64155701670 q}
67uint64 eval_map(const std::map< Uint31_Index, std::vector< Attic< Way_Skeleton > > >& ways)
68153693670 q{
69153693670 q uint64 size(0);
70153693670 q for (std::map< Uint31_Index, std::vector< Attic< Way_Skeleton > > >::const_iterator
71187346670 q it(ways.begin()); it != ways.end(); ++it)
7233653133 q size += it->second.size()*136 + 64;
73153693670 q return size;
74153693670 q}
77uint64 eval_map(const std::map< Uint31_Index, std::vector< Attic< Relation_Skeleton > > >& relations)
78153693670 q{
79153693670 q uint64 size(0);
80153693670 q for (std::map< Uint31_Index, std::vector< Attic< Relation_Skeleton > > >::const_iterator
81263878670 q it(relations.begin()); it != relations.end(); ++it)
82110185101 q size += it->second.size()*200 + 64;
83153693670 q return size;
84153693670 q}
87uint64 eval_map(const std::map< Uint31_Index, std::vector< Area_Skeleton > >& areas)
88153693670 q{
89153693670 q uint64 size(0);
90153693670 q for (std::map< Uint31_Index, std::vector< Area_Skeleton > >::const_iterator
91155300670 q it(areas.begin()); it != areas.end(); ++it)
92160791 q size += it->second.size()*128 + 64;
93153693670 q return size;
94153693670 q}
97uint64 eval_set(const Set& set_)
98153693670 q{
99153693670 q return eval_map(set_.nodes) + eval_map(set_.ways) + eval_map(set_.relations)
100153693670 q + eval_map(set_.attic_nodes) + eval_map(set_.attic_ways)
101153693670 q + eval_map(set_.attic_relations) + eval_map(set_.areas);
102153693670 q}
105Set* Runtime_Stack_Frame::get_set(const std::string& set_name)
106110058666 q{
107110058666 q std::map< std::string, Set >::iterator it = sets.find(set_name);
108110058666 q if (it != sets.end())
10981917663 q return &it->second;
11128141254 q std::map< std::string, Diff_Set >::iterator it_diff = diff_sets.find(set_name);
11228141254 q if (it_diff != diff_sets.end())
1130 return 0;
11528141254 q if (parent)
11627416161 q return parent->get_set(set_name);
118725126 q return 0;
11928141254 q}
122Diff_Set* Runtime_Stack_Frame::get_diff_set(const std::string& set_name)
123102781 q{
124102781 q std::map< std::string, Diff_Set >::iterator it = diff_sets.find(set_name);
125102781 q if (it != diff_sets.end())
1266820 q return &it->second;
12895981 q std::map< std::string, Set >::iterator it_set = sets.find(set_name);
12995981 q if (it_set != sets.end())
13092381 q return 0;
1323612 q if (parent)
1332211 q return parent->get_diff_set(set_name);
135145 q return 0;
139void Runtime_Stack_Frame::swap_set(const std::string& set_name, Set& set_)
140127625670 q{
141127625670 q diff_sets.erase(set_name);
142127625670 q key_values.erase(set_name);
143127625670 q Set& to_swap = sets[set_name];
144127625670 q set_.swap(to_swap);
145127625670 q size_per_set[set_name] = eval_set(to_swap);
146127625670 q}
149void Runtime_Stack_Frame::swap_diff_set(const std::string& set_name, Diff_Set& set_)
1512020 q sets.erase(set_name);
1522020 q key_values.erase(set_name);
1532020 q Diff_Set& to_swap = diff_sets[set_name];
1542020 q set_.swap(to_swap);
158const std::string* Runtime_Stack_Frame::get_value(const std::string& set_name, const std::string& key)
1590{
1600 const std::map< std::string, std::string >* key_values = get_set_key_values(set_name);
1610 if (key_values)
1620 {
1630 std::map< std::string, std::string >::const_iterator kvit = key_values->find(key);
1640 return kvit == key_values->end() ? 0 : &kvit->second;
1650 }
1660 return 0;
1670}
170const std::map< std::string, std::string >* Runtime_Stack_Frame::get_set_key_values(const std::string& set_name)
1711233 q{
1721233 q std::map< std::string, std::map< std::string, std::string > >::iterator it = key_values.find(set_name);
1731233 q if (it != key_values.end())
1740 return &it->second;
1761233 q std::map< std::string, Set >::iterator it_set = sets.find(set_name);
1771233 q if (it_set != sets.end())
1781172 q return 0;
17963 q std::map< std::string, Diff_Set >::iterator it_diff = diff_sets.find(set_name);
18063 q if (it_diff != diff_sets.end())
1810 return 0;
18363 q if (parent)
18433 q return parent->get_set_key_values(set_name);
18633 q return 0;
190void Runtime_Stack_Frame::set_value(const std::string& set_name, const std::string& key, const std::string& value)
19240414 q key_values[set_name][key] = value;
196void Runtime_Stack_Frame::erase_set(const std::string& set_name)
1970{
1980 sets.erase(set_name);
1990 diff_sets.erase(set_name);
2000 key_values.erase(set_name);
2010 size_per_set[set_name] = 0;
2020}
205void Runtime_Stack_Frame::clear_sets()
2078181 q sets.clear();
2088181 q diff_sets.clear();
2098181 q key_values.clear();
2108181 q size_per_set.clear();
214void Runtime_Stack_Frame::copy_outward(const std::string& inner_set_name, const std::string& top_set_name)
21620869 q Set* from = 0;
21820869 q if (parent)
21920869 q from = parent->get_set(inner_set_name);
22120869 q if (from)
22220468 q {
22320468 q size_per_set[top_set_name] = eval_set(*from);
22420468 q sets[top_set_name] = *from;
22520468 q }
22642 q else
22842 q size_per_set[top_set_name] = 0;
22942 q sets[top_set_name].clear();
23120869 q diff_sets.erase(top_set_name);
23220869 q key_values.erase(top_set_name);
236void Runtime_Stack_Frame::move_outward(const std::string& inner_set_name, const std::string& top_set_name)
2372747796 q{
2382747796 q Runtime_Stack_Frame* source = parent;
2402929496 q while (source && source->parent)
2412738621 q {
2422738621 q std::map< std::string, Set >::iterator it = source->sets.find(inner_set_name);
2432738621 q if (it != source->sets.end())
2442556912 q break;
246181714 q std::map< std::string, Diff_Set >::iterator it_diff = source->diff_sets.find(inner_set_name);
247181714 q if (it_diff != source->diff_sets.end())
2480 break;
250181714 q source = source->parent;
251181714 q }
2532747796 q if (source)
2542747796 q {
2552747796 q size_per_set[top_set_name] = source->size_per_set[inner_set_name];
2562747796 q sets[top_set_name].clear();
2572747796 q if (source == parent)
2582566087 q source->swap_set(inner_set_name, sets[top_set_name]);
259181714 q else
260181714 q sets[top_set_name] = source->sets[inner_set_name];
2612747796 q }
2622747796 q diff_sets.erase(top_set_name);
2632747796 q key_values.erase(top_set_name);
2642747796 q}
267bool Runtime_Stack_Frame::union_inward(const std::string& top_set_name, const std::string& inner_set_name)
26825841137 q{
26925841137 q bool new_elements_found = false;
27025841137 q Set* source = get_set(top_set_name);
27225841137 q if (source && parent)
27325839136 q {
27425839136 q Set& target = parent->sets[inner_set_name];
27625839136 q new_elements_found |= indexed_set_union(target.nodes, source->nodes);
27725839136 q new_elements_found |= indexed_set_union(target.attic_nodes, source->attic_nodes);
27925839136 q new_elements_found |= indexed_set_union(target.ways, source->ways);
28025839136 q new_elements_found |= indexed_set_union(target.attic_ways, source->attic_ways);
28225839136 q new_elements_found |= indexed_set_union(target.relations, source->relations);
28325839136 q new_elements_found |= indexed_set_union(target.attic_relations, source->attic_relations);
28525839136 q new_elements_found |= indexed_set_union(target.areas, source->areas);
28625839136 q new_elements_found |= indexed_set_union(target.deriveds, source->deriveds);
28825839136 q parent->size_per_set[inner_set_name] = eval_set(target);
28925839136 q }
29025841137 q parent->diff_sets.erase(inner_set_name);
29125841137 q parent->key_values.erase(top_set_name);
29325841137 q return new_elements_found;
29425841137 q}
297void Runtime_Stack_Frame::copy_inward(const std::string& top_set_name, const std::string& inner_set_name)
2992521 q if (!parent)
3000 return;
3022521 q std::map< std::string, Set >::iterator it = sets.find(top_set_name);
3032521 q if (it == sets.end())
3040 {
3050 Set* source = parent->get_set(top_set_name);
3060 if (!source)
3070 parent->sets[inner_set_name] = Set();
3080 else if (source != &parent->sets[inner_set_name])
3090 parent->sets[inner_set_name] = *source;
3100 }
3112521 q else
3122521 q parent->sets[inner_set_name] = it->second;
3142521 q parent->diff_sets.erase(inner_set_name);
3152521 q parent->key_values.erase(inner_set_name);
319void Runtime_Stack_Frame::substract_from_inward(const std::string& top_set_name, const std::string& inner_set_name)
3212521 q Set* source = get_set(top_set_name);
3232521 q if (source && parent)
3252521 q Set& target = parent->sets[inner_set_name];
3272521 q indexed_set_difference(target.nodes, source->nodes);
3282521 q indexed_set_difference(target.ways, source->ways);
3292521 q indexed_set_difference(target.relations, source->relations);
3312521 q indexed_set_difference(target.attic_nodes, source->attic_nodes);
3322521 q indexed_set_difference(target.attic_ways, source->attic_ways);
3332521 q indexed_set_difference(target.attic_relations, source->attic_relations);
3352521 q indexed_set_difference(target.areas, source->areas);
3362521 q indexed_set_difference(target.deriveds, source->deriveds);
3382521 q parent->size_per_set[inner_set_name] = eval_set(target);
3402521 q parent->diff_sets.erase(inner_set_name);
3412521 q parent->key_values.erase(inner_set_name);
345void Runtime_Stack_Frame::move_all_inward()
34710469 q if (parent)
34810469 q {
34923369 q for (std::map< std::string, Set >::iterator it = sets.begin(); it != sets.end(); ++it)
35012969 q {
35112969 q parent->swap_set(it->first, it->second);
35212969 q parent->diff_sets.erase(it->first);
35312969 q parent->key_values.erase(it->first);
35412969 q }
35510469 q }
359void Runtime_Stack_Frame::move_all_inward_except(const std::string& set_name)
36027554139 q{
36127554139 q if (parent)
36227554139 q {
36380681139 q for (std::map< std::string, Set >::iterator it = sets.begin(); it != sets.end(); ++it)
36453127134 q {
36553127134 q if (it->first != set_name)
3662560674 q {
3672560674 q parent->swap_set(it->first, it->second);
3682560674 q parent->diff_sets.erase(it->first);
3692560674 q parent->key_values.erase(it->first);
3702560674 q }
37153127134 q }
37227554139 q }
37327554139 q}
376uint64 Runtime_Stack_Frame::total_size()
377445575673 q{
378445575673 q uint64 result = 0;
3801484620673 q for (std::map< std::string, uint64 >::const_iterator it = size_per_set.begin(); it != size_per_set.end(); ++it)
3811039045670 q result += it->second;
383445575673 q if (parent)
38425784072 q return result + parent->total_size();
386187735673 q return result;
387445575673 q}
390std::vector< std::pair< uint, uint > > Runtime_Stack_Frame::stack_progress() const
39211 q std::vector< std::pair< uint, uint > > result;
39311 q if (parent)
3940 parent->stack_progress().swap(result);
39611 q result.push_back(std::make_pair(loop_count, loop_size));
39811 q return result;
402Resource_Manager::Resource_Manager(
403 Transaction& transaction_, Parsed_Query* global_settings_, Watchdog_Callback* watchdog_,
404 Error_Output* error_output_)
405551551 q : transaction(&transaction_), error_output(error_output_),
406551551 q area_transaction(0), area_updater_(0),
407551551 q watchdog(watchdog_), global_settings(global_settings_), global_settings_owned(false),
408551551 q start_time(time(NULL)), last_ping_time(0), last_report_time(0),
409551551 q max_allowed_time(0), max_allowed_space(0)
411551551 q if (!global_settings)
4120 {
4130 global_settings = new Parsed_Query();
4140 global_settings_owned = true;
4150 }
417551551 q runtime_stack.push_back(new Runtime_Stack_Frame());
421Resource_Manager::Resource_Manager(
422 Transaction& transaction_, Parsed_Query& global_settings_, Error_Output* error_output_,
423 Transaction& area_transaction_, Watchdog_Callback* watchdog_, Area_Usage_Listener* area_updater__)
424122122 q : transaction(&transaction_), error_output(error_output_),
425122122 q area_transaction(&area_transaction_), area_updater_(area_updater__),
426122122 q watchdog(watchdog_), global_settings(&global_settings_), global_settings_owned(false),
427122122 q start_time(time(NULL)), last_ping_time(0), last_report_time(0),
428122122 q max_allowed_time(0), max_allowed_space(0)
430122122 q runtime_stack.push_back(new Runtime_Stack_Frame());
434const Set* Resource_Manager::get_set(const std::string& set_name)
43556568666 q{
43656568666 q if (runtime_stack.empty())
4370 return 0;
43956568666 q return runtime_stack.back()->get_set(set_name);
44056568666 q}
443const Diff_Set* Resource_Manager::get_diff_set(const std::string& set_name)
44598381 q if (runtime_stack.empty())
4460 return 0;
44898381 q return runtime_stack.back()->get_diff_set(set_name);
452void Resource_Manager::swap_set(const std::string& set_name, Set& set_)
45376208669 q{
45476208669 q if (runtime_stack.empty())
4550 runtime_stack.push_back(new Runtime_Stack_Frame());
45776208669 q sort(set_);
45876208669 q runtime_stack.back()->swap_set(set_name, set_);
45976208669 q}
462void Resource_Manager::swap_diff_set(const std::string& set_name, Diff_Set& set_)
4642020 q if (runtime_stack.empty())
4650 runtime_stack.push_back(new Runtime_Stack_Frame());
4672020 q runtime_stack.back()->swap_diff_set(set_name, set_);
471const std::string* Resource_Manager::get_value(const std::string& set_name, const std::string& key)
4720{
4730 if (runtime_stack.empty())
4740 return 0;
4760 return runtime_stack.back()->get_value(set_name, key);
4770}
480const std::map< std::string, std::string >* Resource_Manager::get_set_key_values(const std::string& set_name)
4811203 q{
4821203 q if (runtime_stack.empty())
4830 return 0;
4851203 q return runtime_stack.back()->get_set_key_values(set_name);
4861203 q}
489void Resource_Manager::set_value(const std::string& set_name, const std::string& key, const std::string& value)
49140414 q if (runtime_stack.empty())
4920 runtime_stack.push_back(new Runtime_Stack_Frame());
49440414 q runtime_stack.back()->set_value(set_name, key, value);
498void Resource_Manager::erase_set(const std::string& set_name)
4990{
5000 if (runtime_stack.empty())
5010 runtime_stack.push_back(new Runtime_Stack_Frame());
5030 runtime_stack.back()->erase_set(set_name);
5040}
507void Resource_Manager::clear_sets()
5080{
5090 if (!runtime_stack.empty())
5100 runtime_stack.back()->clear_sets();
5110}
515void Resource_Manager::push_stack_frame()
51627680203 q{
51727680203 q runtime_stack.push_back(new Runtime_Stack_Frame(runtime_stack.empty() ? 0 : runtime_stack.back()));
51827680203 q}
521void Resource_Manager::copy_outward(const std::string& inner_set_name, const std::string& top_set_name)
52320869 q if (!runtime_stack.empty())
52420869 q runtime_stack.back()->copy_outward(inner_set_name, top_set_name);
528void Resource_Manager::move_outward(const std::string& inner_set_name, const std::string& top_set_name)
5292747796 q{
5302747796 q if (!runtime_stack.empty())
5312747796 q runtime_stack.back()->move_outward(inner_set_name, top_set_name);
5322747796 q}
535bool Resource_Manager::union_inward(const std::string& top_set_name, const std::string& inner_set_name)
53625841137 q{
53725841137 q if (runtime_stack.empty())
5380 return false;
54025841137 q return runtime_stack.back()->union_inward(top_set_name, inner_set_name);
54125841137 q}
544void Resource_Manager::copy_inward(const std::string& top_set_name, const std::string& inner_set_name)
5462521 q if (!runtime_stack.empty())
5472521 q runtime_stack.back()->copy_inward(top_set_name, inner_set_name);
551void Resource_Manager::substract_from_inward(const std::string& top_set_name, const std::string& inner_set_name)
5532521 q if (!runtime_stack.empty())
5542521 q runtime_stack.back()->substract_from_inward(top_set_name, inner_set_name);
558void Resource_Manager::move_all_inward()
56010469 q if (!runtime_stack.empty())
56110469 q runtime_stack.back()->move_all_inward();
565void Resource_Manager::move_all_inward_except(const std::string& set_name)
56627554139 q{
56727554139 q if (!runtime_stack.empty())
56827554139 q runtime_stack.back()->move_all_inward_except(set_name);
56927554139 q}
572void Resource_Manager::pop_stack_frame()
57327680203 q{
57427680203 q if (!runtime_stack.empty())
57527680203 q {
57627680203 q delete runtime_stack.back();
57727680203 q runtime_stack.pop_back();
57827680203 q }
57927680203 q}
582uint count_set(const Set& set_)
5830{
5840 uint size(0);
5850 for (std::map< Uint32_Index, std::vector< Node_Skeleton > >::const_iterator
5860 it(set_.nodes.begin()); it != set_.nodes.end(); ++it)
5870 size += it->second.size();
5880 for (std::map< Uint31_Index, std::vector< Way_Skeleton > >::const_iterator
5890 it(set_.ways.begin()); it != set_.ways.end(); ++it)
5900 size += it->second.size();
5910 for (std::map< Uint31_Index, std::vector< Relation_Skeleton > >::const_iterator
5920 it(set_.relations.begin()); it != set_.relations.end(); ++it)
5930 size += it->second.size();
5950 for (std::map< Uint32_Index, std::vector< Attic< Node_Skeleton > > >::const_iterator
5960 it(set_.attic_nodes.begin()); it != set_.attic_nodes.end(); ++it)
5970 size += it->second.size();
5980 for (std::map< Uint31_Index, std::vector< Attic< Way_Skeleton > > >::const_iterator
5990 it(set_.attic_ways.begin()); it != set_.attic_ways.end(); ++it)
6000 size += it->second.size();
6010 for (std::map< Uint31_Index, std::vector< Attic< Relation_Skeleton > > >::const_iterator
6020 it(set_.attic_relations.begin()); it != set_.attic_relations.end(); ++it)
6030 size += it->second.size();
6050 for (std::map< Uint31_Index, std::vector< Area_Skeleton > >::const_iterator
6060 it(set_.areas.begin()); it != set_.areas.end(); ++it)
6070 size += it->second.size();
6090 return size;
6100}
613void Resource_Manager::count_loop()
6144860340 q{
6154860340 q if (runtime_stack.empty())
6160 return;
6184860340 q runtime_stack.back()->count_loop();
6194860340 q}
622void Resource_Manager::log_and_display_error(std::string message)
6230{
6240 if (error_output)
6250 error_output->runtime_error(message);
6270 Logger logger(transaction->get_db_dir());
6280 logger.annotated_log(message);
6290}
632bool Resource_Manager::health_check(const Statement& stmt, uint32 extra_time, uint64 extra_space)
633187735673 q{
634187735673 q bool extra_space_uses_half_empty = false;
636187735673 q uint32 elapsed_time = 0;
637187735673 q if (max_allowed_time > 0)
638187735673 q elapsed_time = time(NULL) - start_time + extra_time;
640187735673 q if (elapsed_time >= last_ping_time + 5)
6426360 q if (watchdog)
6436360 q watchdog->ping();
6446360 q last_ping_time = elapsed_time;
6466360 q if (elapsed_time >= last_report_time + 15)
64811 q if (error_output)
65011 q error_output->display_statement_progress
65111 q (elapsed_time, stmt.get_name(), stmt.get_progress(), stmt.get_line_number(),
65211 q runtime_stack.back()->stack_progress());
65411 q last_report_time = elapsed_time;
658187735673 q uint64 size = 0;
659187735673 q if (max_allowed_space > 0)
660187735673 q {
661187735673 q if (!runtime_stack.empty())
662187735673 q size += runtime_stack.back()->total_size();
663187735673 q extra_space_uses_half_empty = (extra_space*2 >= max_allowed_space - size);
664187735673 q size += extra_space;
665187735673 q }
667187735673 q if (elapsed_time > max_allowed_time || size > max_allowed_space)
6680 {
6690 if (error_output)
6700 {
6710 error_output->display_statement_progress
6720 (elapsed_time, stmt.get_name(), stmt.get_progress(), stmt.get_line_number(),
6730 runtime_stack.back()->stack_progress());
6740 }
6760 Resource_Error error;
6770 error.timed_out = (elapsed_time > max_allowed_time);
6780 error.stmt_name = stmt.get_name();
6790 error.line_number = stmt.get_line_number();
6800 error.size = size;
6810 error.runtime = elapsed_time;
6830 Logger logger(transaction->get_db_dir());
6840 std::ostringstream out;
6850 if (elapsed_time > max_allowed_time)
6860 out<<"Timeout:";
6870 else
6880 out<<"Oversized:";
6890 out<<" runtime "<<error.runtime<<" seconds, size "<<error.size<<" bytes, "
6900 "in line "<<error.line_number<<", statement "<<error.stmt_name;
6910 logger.annotated_log(out.str());
6930 throw error;
6940 }
696187735673 q return extra_space_uses_half_empty;
697187735673 q}
700uint64 Resource_Manager::get_desired_timestamp() const
701243965669 q{
702243965669 q return runtime_stack.empty() ? NOW : runtime_stack.back()->get_desired_timestamp();
703243965669 q}
706Diff_Action::_ Resource_Manager::get_desired_action() const
70729115665 q{
70829115665 q return runtime_stack.empty() ? Diff_Action::positive : runtime_stack.back()->get_desired_action();
70929115665 q}
712uint64 Resource_Manager::get_diff_from_timestamp() const
713129447 q{
714129447 q return runtime_stack.empty() ? NOW : runtime_stack.back()->get_diff_from_timestamp();
715129447 q}
718uint64 Resource_Manager::get_diff_to_timestamp() const
72093847 q return runtime_stack.empty() ? NOW : runtime_stack.back()->get_diff_to_timestamp();
724void Resource_Manager::start_diff(uint64 comparison_timestamp, uint64 desired_timestamp)
7268181 q if (!runtime_stack.empty())
7288181 q runtime_stack.back()->set_desired_action(Diff_Action::collect_lhs);
7298181 q runtime_stack.back()->set_diff_from_timestamp(comparison_timestamp);
7308181 q runtime_stack.back()->set_diff_to_timestamp(desired_timestamp);
7318181 q runtime_stack.back()->set_desired_timestamp(comparison_timestamp);
736void Resource_Manager::switch_diff_rhs(bool add_deletion_information)
7388181 q if (!runtime_stack.empty())
7408181 q runtime_stack.back()->clear_sets();
7418181 q runtime_stack.back()->set_desired_action(
7428181 q add_deletion_information ? Diff_Action::collect_rhs_with_del : Diff_Action::collect_rhs_no_del);
7438181 q runtime_stack.back()->set_desired_timestamp(runtime_stack.back()->get_diff_to_timestamp());
748void Resource_Manager::switch_diff_show_from(const std::string& diff_set_name)
7501111 q if (!runtime_stack.empty())
7521111 q runtime_stack.back()->set_desired_action(Diff_Action::show_old);
7531111 q runtime_stack.back()->set_desired_timestamp(runtime_stack.back()->get_diff_from_timestamp());
7551111 q Diff_Set* diff_set = runtime_stack.back()->get_diff_set(diff_set_name);
7561111 q if (diff_set)
7581111 q Set set = diff_set->make_from_set();
7591111 q runtime_stack.back()->swap_set(diff_set_name, set);
765void Resource_Manager::switch_diff_show_to(const std::string& diff_set_name)
7671111 q if (!runtime_stack.empty())
7691111 q runtime_stack.back()->set_desired_action(Diff_Action::show_new);
7701111 q runtime_stack.back()->set_desired_timestamp(runtime_stack.back()->get_diff_to_timestamp());
7721111 q Diff_Set* diff_set = runtime_stack.back()->get_diff_set(diff_set_name);
7731111 q if (diff_set)
7751111 q Set set = diff_set->make_to_set();
7761111 q runtime_stack.back()->swap_set(diff_set_name, set);
782void Resource_Manager::set_desired_timestamp(uint64 timestamp)
7841621673 q if (!runtime_stack.empty())
7851621673 q runtime_stack.back()->set_desired_timestamp(timestamp);
789void Resource_Manager::start_cpu_timer(uint index)
79029750673 q{
79129750673 q if (cpu_start_time.size() <= index)
7921905673 q cpu_start_time.resize(index+1, 0);
79329750673 q cpu_start_time[index] = clock()/1000;
79429750673 q}
797void Resource_Manager::stop_cpu_timer(uint index)
79829750673 q{
79929750673 q if (cpu_runtime.size() <= index)
8001236673 q cpu_runtime.resize(index+1, 0);
80129750673 q if (index < cpu_start_time.size())
80229750673 q cpu_runtime[index] += clock()/1000 - cpu_start_time[index];
80329750673 q}