Overpass API regression suite coverage (Nova Scotia) / overpass_api/statements/changed.cc
overpass_api/statements/changed.cc
183 of 256 instrumented lines run by the suite (71.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 modify6 * it under the terms of the GNU Affero General Public License as7 * published by the Free Software Foundation, either version 3 of the8 * 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 of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU General Public License for more details.14 *15 * You should have received a copy of the GNU Affero General Public License16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.17 */19#include <sstream>21#include "../../template_db/block_backend.h"22#include "../../template_db/random_file.h"23#include "../core/settings.h"24#include "../data/abstract_processing.h"25#include "../data/collect_members.h"26#include "../data/filenames.h"27#include "changed.h"30bool Changed_Statement::area_query_exists_ = false;33Changed_Statement::Statement_Maker Changed_Statement::statement_maker;34Changed_Statement::Criterion_Maker Changed_Statement::criterion_maker;37Statement* Changed_Statement::Criterion_Maker::create_criterion(const Token_Node_Ptr& tree_it,38 const std::string& type, const std::string& into,39 Statement::Factory& stmt_factory, Parsed_Query& global_settings, Error_Output* error_output)5082 q else if (tree_it->token == "," && tree_it->lhs && tree_it.lhs()->token == ":" && tree_it.lhs()->rhs83template< class TIndex, class TObject >84void filter_elems(const std::vector< typename TObject::Id_Type >& ids, std::map< TIndex, std::vector< TObject > >& elems)101template< typename Index, typename Skeleton, typename Id_Predicate >102std::vector< typename Skeleton::Id_Type > collect_changed_elements103 (uint64 since, uint64 until,104 const Id_Predicate& relevant, Resource_Manager& rman)1097013 q auto changelog_db_idx = rman.get_transaction()->data_index(changelog_file_properties< Skeleton >());1120 Block_Backend< Timestamp, Change_Entry< typename Skeleton::Id_Type > > changelog_db(changelog_db_idx);135//-----------------------------------------------------------------------------137template< typename Id_Type >138struct Trivial_Id_Predicate139{141};144template< typename Index, typename Skeleton >145struct Ids_In_Set_Predicate146{147 Ids_In_Set_Predicate(148 const std::map< Index, std::vector< Skeleton > >& current,149 const std::map< Index, std::vector< Attic< Skeleton > > >& attic);151 bool operator()(typename Skeleton::Id_Type id) const154private:155 std::vector< typename Skeleton::Id_Type > set_ids;156};159template< typename Index, typename Skeleton >160Ids_In_Set_Predicate< Index, Skeleton >::Ids_In_Set_Predicate(161 const std::map< Index, std::vector< Skeleton > >& current,162 const std::map< Index, std::vector< Attic< Skeleton > > >& attic)1644813 q for (typename std::map< Index, std::vector< Skeleton > >::const_iterator it_idx = current.begin();1671989910 q for (typename std::vector< Skeleton >::const_iterator it_elem = it_idx->second.begin();1724813 q for (typename std::map< Index, std::vector< Attic< Skeleton > > >::const_iterator it_idx = attic.begin();175123195 q for (typename std::vector< Attic< Skeleton > >::const_iterator it_elem = it_idx->second.begin();185class Changed_Constraint : public Query_Constraint186{187 public:192 bool get_node_ids193 (Resource_Manager& rman, std::vector< Node_Skeleton::Id_Type >& ids);194 bool get_way_ids195 (Resource_Manager& rman, std::vector< Way_Skeleton::Id_Type >& ids);196 bool get_relation_ids197 (Resource_Manager& rman, std::vector< Relation_Skeleton::Id_Type >& ids);199 void filter(Resource_Manager& rman, Set& into);202 private:203 Changed_Statement* stmt;204};207bool Changed_Constraint::get_node_ids(Resource_Manager& rman, std::vector< Node_Skeleton::Id_Type >& ids)21054 q stmt->get_since(rman), stmt->get_until(rman), Trivial_Id_Predicate< Node_Skeleton::Id_Type >(), rman);215bool Changed_Constraint::get_way_ids(Resource_Manager& rman, std::vector< Way_Skeleton::Id_Type >& ids)21897 q stmt->get_since(rman), stmt->get_until(rman), Trivial_Id_Predicate< Way_Skeleton::Id_Type >(), rman);223bool Changed_Constraint::get_relation_ids(Resource_Manager& rman, std::vector< Relation_Skeleton::Id_Type >& ids)22687 q stmt->get_since(rman), stmt->get_until(rman), Trivial_Id_Predicate< Relation_Skeleton::Id_Type >(), rman);231void Changed_Constraint::filter(Resource_Manager& rman, Set& into)2601613 q Ids_In_Set_Predicate< Uint31_Index, Relation_Skeleton >(into.relations, into.attic_relations), rman);269//-----------------------------------------------------------------------------271Changed_Statement::Changed_Statement272 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)2885213 q if (!behave_trivial && ((attributes["since"] == "auto") ^ (attributes["until"] == "auto")))3000 add_static_error("The attribute \"since\" must contain a timestamp exactly in the form \"yyyy-mm-ddThh:mm:ssZ\".");3070 add_static_error("The attribute \"until\" must contain a timestamp exactly in the form \"yyyy-mm-ddThh:mm:ssZ\".");311uint64 Changed_Statement::get_since(Resource_Manager& rman) const314 // We have zero arguments on changed.317 // We are on diff mode320 // We are in attic mode323 // We are in present mode.324 // Trigger an empty result on purpose328 // We have one argument on changed only.331 // We are on diff mode334 // If the only parameter is equal to the time range then silently ignore it337 // Trigger an empty result on purpose341 // We are in attic mode344 // We are in present mode.348 // We have two arguments on changed.353uint64 Changed_Statement::get_until(Resource_Manager& rman) const356 // We have zero arguments on changed.359 // We are on diff mode362 // We are in attic mode365 // We are in present mode.366 // Trigger an empty result on purpose370 // We have one argument on changed only.373 // We are on diff mode376 // If the only parameter is equal to the time range then silently ignore it379 // Trigger an empty result on purpose383 // We are in attic mode386 // We are in present mode.390 // We have two arguments on changed.395template< typename Index, typename Skeleton >396void get_elements(Changed_Statement& stmt, Resource_Manager& rman,397 std::map< Index, std::vector< Skeleton > >& current_result,398 std::map< Index, std::vector< Attic< Skeleton > > >& attic_result)4060 collect_items_discrete(context, req, Id_Predicate< Skeleton >(ids), current_result, attic_result);413void Changed_Statement::execute(Resource_Manager& rman)427Changed_Statement::~Changed_Statement()435Query_Constraint* Changed_Statement::get_query_constraint()