Overpass API regression suite coverage (Saxony) / overpass_api/data/tag_store.h
overpass_api/data/tag_store.h
244 of 249 instrumented lines run by the suite (98.0%) 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#ifndef DE__OSM3S___OVERPASS_API__DATA__TAG_STORE_H20#define DE__OSM3S___OVERPASS_API__DATA__TAG_STORE_H23#include "filenames.h"24#include "../core/datatypes.h"25#include "../../template_db/block_backend.h"26#include "../../template_db/transaction.h"28#include <map>29#include <string>30#include <vector>33template< typename Index, typename Object >34class Tag_Store35{36public:37 Tag_Store(Transaction& transaction);38 ~Tag_Store();40 void prefetch_all(const std::map< Index, std::vector< Object > >& elems);41 void prefetch_chunk(const std::map< Index, std::vector< Object > >& elems,42 typename Object::Id_Type lower_id_bound, typename Object::Id_Type upper_id_bound);43 void prefetch_all(const std::map< Index, std::vector< Attic< Object > > >& elems);44 void prefetch_chunk(const std::map< Index, std::vector< Attic< Object > > >& elems,45 typename Object::Id_Type lower_id_bound, typename Object::Id_Type upper_id_bound);47 const std::vector< std::pair< std::string, std::string > >* get(const Index& index, const Object& elem);49private:50 std::map< typename Object::Id_Type, std::vector< std::pair< std::string, std::string > > > tags_by_id;51 Transaction* transaction;52 bool use_index;53 Index stored_index;54 Ranges< Tag_Index_Local > ranges;55 std::map< uint32, std::vector< typename Object::Id_Type > > ids_by_coarse;56 std::map< uint32, std::vector< Attic< typename Object::Id_Type > > > attic_ids_by_coarse;57 Block_Backend< Tag_Index_Local, typename Object::Id_Type >* items_db;58 typename Block_Backend< Tag_Index_Local, typename Object::Id_Type >::Range_Iterator* tag_it;59 Block_Backend< Tag_Index_Local, Attic< typename Object::Id_Type > >* attic_items_db;60 typename Block_Backend< Tag_Index_Local, Attic< typename Object::Id_Type > >::Range_Iterator* attic_tag_it;61};64template< >65class Tag_Store< Uint31_Index, Derived_Structure >66{67public:71328194 q void prefetch_all(const std::map< Uint31_Index, std::vector< Derived_Structure > >& elems) {}72 void prefetch_chunk(const std::map< Uint31_Index, std::vector< Derived_Structure > >& elems,733063561 q Derived_Structure::Id_Type lower_id_bound, Derived_Structure::Id_Type upper_id_bound) {}75 const std::vector< std::pair< std::string, std::string > >* get(762424809562 q const Uint31_Index& index, const Derived_Structure& elem) const { return &elem.tags; }77};80template< class Id_Type >81void collect_attic_tags82 (std::map< Id_Type, std::vector< std::pair< std::string, std::string > > >& tags_by_id,83 const Block_Backend< Tag_Index_Local, Id_Type >& current_items_db,84 typename Block_Backend< Tag_Index_Local, Id_Type >::Range_Iterator& current_tag_it,85 const Block_Backend< Tag_Index_Local, Attic< Id_Type > >& attic_items_db,86 typename Block_Backend< Tag_Index_Local, Attic< Id_Type > >::Range_Iterator& attic_tag_it,87 const std::vector< Attic< Id_Type > >& id_vec, uint32 coarse_index)892701160 q std::map< Attic< Id_Type >, std::vector< std::pair< std::string, std::string > > > found_tags;91 // Collect all id-matched tag information from the current tags9968020337157 q = std::lower_bound(id_vec.begin(), id_vec.end(), Attic< Id_Type >(current_tag_it.object(), 0ull));104610135129 q found_tags[Attic< Id_Type >(current_tag_it.object(), 0xffffffffffffffffull)].push_back109 // Collect all id-matched tag information that is younger than the respective timestamp from the attic tags117126802459160 q = std::lower_bound(id_vec.begin(), id_vec.end(), Attic< Id_Type >(attic_tag_it.object(), 0ull));126 // Actually take for each object and key of the multiple versions only the oldest valid version1272701160 q for (typename std::map< Attic< Id_Type >, std::vector< std::pair< std::string, std::string > > >138331720130 q std::vector< std::pair< std::string, std::string > >::const_iterator last_added_it = it->second.end();1531071242130 q std::vector< std::pair< std::string, std::string > >::const_iterator it_obj = obj_vec.begin();169 // Remove empty tags. They are placeholders for tags added later than each timestamp in question.1702701160 q for (typename std::map< Id_Type, std::vector< std::pair< std::string, std::string > > >189template< class Id_Type >190void collect_attic_tags191 (std::map< Id_Type, std::vector< std::pair< std::string, std::string > > >& tags_by_id,192 const Block_Backend< Tag_Index_Local, Id_Type >& current_items_db,193 typename Block_Backend< Tag_Index_Local, Id_Type >::Range_Iterator& current_tag_it,194 const Block_Backend< Tag_Index_Local, Attic< Id_Type > >& attic_items_db,195 typename Block_Backend< Tag_Index_Local, Attic< Id_Type > >::Range_Iterator& attic_tag_it,196 std::map< uint32, std::vector< Attic< Id_Type > > >& ids_by_coarse,197 uint32 coarse_index,198 Id_Type lower_id_bound, Id_Type upper_id_bound)217115466 q collect_attic_tags< Id_Type >(tags_by_id, current_items_db, current_tag_it, attic_items_db, attic_tag_it,222template< class Id_Type >223void collect_tags224 (std::map< Id_Type, std::vector< std::pair< std::string, std::string > > >& tags_by_id,225 const Block_Backend< Tag_Index_Local, Id_Type >& items_db,226 typename Block_Backend< Tag_Index_Local, Id_Type >::Range_Iterator& tag_it,227 const std::vector< Id_Type >& ids, uint32 coarse_index)243template< class Id_Type >244void collect_tags_framed245 (std::map< Id_Type, std::vector< std::pair< std::string, std::string > > >& tags_by_id,246 const Block_Backend< Tag_Index_Local, Id_Type >& items_db,247 typename Block_Backend< Tag_Index_Local, Id_Type >::Range_Iterator& tag_it,248 std::map< uint32, std::vector< Id_Type > >& ids_by_coarse,249 uint32 coarse_index,250 Id_Type lower_id_bound, Id_Type upper_id_bound)269template< typename Index, typename Object >270Tag_Store< Index, Object >::Tag_Store(Transaction& transaction_)275template< typename Index, typename Object >276void Tag_Store< Index, Object >::prefetch_all(const std::map< Index, std::vector< Object > >& elems)2873743249 q tag_it = new typename Block_Backend< Tag_Index_Local, typename Object::Id_Type >::Range_Iterator(300template< typename Index, typename Object >301void Tag_Store< Index, Object >::prefetch_chunk(const std::map< Index, std::vector< Object > >& elems,302 typename Object::Id_Type lower_id_bound, typename Object::Id_Type upper_id_bound)306 //generate std::set of relevant coarse indices314494298 q for (typename std::map< uint32, std::vector< typename Object::Id_Type > >::const_iterator31610307282 q collect_tags_framed< typename Object::Id_Type >(tags_by_id, items_db, tag_it, ids_by_coarse, it->first,321template< typename Index, typename Object >322void Tag_Store< Index, Object >::prefetch_all(const std::map< Index, std::vector< Attic< Object > > >& attic_items)3321943123 q attic_items_db = new Block_Backend< Tag_Index_Local, Attic< typename Object::Id_Type > >(3361943123 q tag_it = new typename Block_Backend< Tag_Index_Local, typename Object::Id_Type >::Range_Iterator(3391943123 q attic_tag_it = new typename Block_Backend< Tag_Index_Local, Attic< typename Object::Id_Type > >::Range_Iterator(346521106 q collect_attic_tags< typename Object::Id_Type >(tags_by_id, *items_db, *tag_it, *attic_items_db, *attic_tag_it,352template< typename Index, typename Object >353void Tag_Store< Index, Object >::prefetch_chunk(const std::map< Index, std::vector< Attic< Object > > >& attic_items,354 typename Object::Id_Type lower_id_bound, typename Object::Id_Type upper_id_bound)356 //generate std::set of relevant coarse indices36714270 q for (typename std::map< uint32, std::vector< Attic< typename Object::Id_Type > > >::const_iterator369115466 q collect_attic_tags(tags_by_id, current_tags_db, current_tag_it, attic_tags_db, attic_tag_it,374template< typename Index, typename Object >375Tag_Store< Index, Object >::~Tag_Store()384template< typename Index, typename Object >385const std::vector< std::pair< std::string, std::string > >*386 Tag_Store< Index, Object >::get(const Index& index, const Object& elem)3935819 q tag_it = new typename Block_Backend< Tag_Index_Local, typename Object::Id_Type >::Range_Iterator(39865 q attic_tag_it = new typename Block_Backend< Tag_Index_Local, Attic< typename Object::Id_Type > >::Range_Iterator(406102669 q collect_attic_tags< typename Object::Id_Type >(tags_by_id, *items_db, *tag_it, *attic_items_db, *attic_tag_it,421#endif