Skip to content

Commit

Permalink
Merge branch 'minor_issues' into uint3x_cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
drolbr committed Oct 12, 2022
2 parents d311e7b + 44246a4 commit e21c39f
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 98 deletions.
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ bin_bbox_brim_query_LDADD = libexpatwrapper.la
bin_translate_xapi_SOURCES = expat/translate_xapi.cc expat/escape_xml.cc
bin_translate_xapi_LDADD =

distdir = osm-3s_v0.7.58
distdir = osm-3s_v0.7.58.5

nobase_dist_HEADERS = \
expat/escape_json.h\
Expand Down
2 changes: 1 addition & 1 deletion src/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.61])
AC_INIT([OverpassAPI], [0.7.58], [[email protected]])
AC_INIT([OverpassAPI], [0.7.58.5], [[email protected]])
AC_CONFIG_SRCDIR([template_db/file_blocks.h])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
Expand Down
2 changes: 1 addition & 1 deletion src/overpass_api/core/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Basic_Settings::Basic_Settings()
base_directory("./"),
logfile_name("transactions.log"),
shared_name_base("/osm3s_v0.7.58"),
version("0.7.58"),
version("0.7.59"),
source_hash("4f7e2b3b87ff98dc98f61d4f01b2127578d79aef"),
#ifdef HAVE_LZ4
compression_method(File_Blocks_Index_Base::LZ4_COMPRESSION),
Expand Down
22 changes: 17 additions & 5 deletions src/overpass_api/data/filter_by_tags.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,28 @@ template< class Id_Type >
std::map< Id_Type, std::pair< uint64, Uint31_Index > > collect_attic_kv(
std::vector< std::pair< std::string, std::string > >::const_iterator kvit, uint64 timestamp,
Block_Backend< Tag_Index_Global, Tag_Object_Global< Id_Type > >& tags_db,
Block_Backend< Tag_Index_Global, Attic< Tag_Object_Global< Id_Type > > >& attic_tags_db)
Block_Backend< Tag_Index_Global, Attic< Tag_Object_Global< Id_Type > > >& attic_tags_db,
std::vector< std::pair< Id_Type, Uint31_Index > >* relevant_ids = 0)
{
std::map< Id_Type, std::pair< uint64, Uint31_Index > > timestamp_per_id;
std::set< Tag_Index_Global > tag_req = get_kv_req(kvit->first, kvit->second);

for (typename Block_Backend< Tag_Index_Global, Tag_Object_Global< Id_Type > >::Discrete_Iterator
it2(tags_db.discrete_begin(tag_req.begin(), tag_req.end()));
!(it2 == tags_db.discrete_end()); ++it2)
timestamp_per_id[it2.object().id] = std::make_pair(NOW, it2.object().idx);
{
if (!relevant_ids || std::binary_search(
relevant_ids->begin(), relevant_ids->end(), std::make_pair(it2.object().id, Uint31_Index(0u))))
timestamp_per_id[it2.object().id] = std::make_pair(NOW, it2.object().idx);
}

for (typename Block_Backend< Tag_Index_Global, Attic< Tag_Object_Global< Id_Type > > >::Discrete_Iterator
it2(attic_tags_db.discrete_begin(tag_req.begin(), tag_req.end()));
!(it2 == attic_tags_db.discrete_end()); ++it2)
{
if (it2.object().timestamp > timestamp)
if (it2.object().timestamp > timestamp &&
(!relevant_ids || std::binary_search(
relevant_ids->begin(), relevant_ids->end(), std::make_pair(it2.object().id, Uint31_Index(0u)))))
{
std::pair< uint64, Uint31_Index >& ref = timestamp_per_id[it2.object().id];
if (ref.first == 0 || it2.object().timestamp < ref.first)
Expand Down Expand Up @@ -165,20 +172,25 @@ template< class Id_Type >
std::map< Id_Type, std::pair< uint64, Uint31_Index > > collect_attic_kregv(
std::vector< std::pair< std::string, Regular_Expression* > >::const_iterator krit, uint64 timestamp,
Block_Backend< Tag_Index_Global, Tag_Object_Global< Id_Type > >& tags_db,
Block_Backend< Tag_Index_Global, Attic< Tag_Object_Global< Id_Type > > >& attic_tags_db)
Block_Backend< Tag_Index_Global, Attic< Tag_Object_Global< Id_Type > > >& attic_tags_db,
std::vector< std::pair< Id_Type, Uint31_Index > >* relevant_ids = 0)
{
std::map< Id_Type, std::pair< uint64, Uint31_Index > > timestamp_per_id;
Ranges< Tag_Index_Global > ranges = get_k_req(krit->first);

for (auto it2 = tags_db.range_begin(ranges); !(it2 == tags_db.range_end()); ++it2)
{
if (krit->second->matches(it2.index().value))
if ((!relevant_ids || std::binary_search(
relevant_ids->begin(), relevant_ids->end(), std::make_pair(it2.object().id, Uint31_Index(0u))))
&& krit->second->matches(it2.index().value))
timestamp_per_id[it2.object().id] = std::make_pair(NOW, it2.object().idx);
}

for (auto it2 = attic_tags_db.range_begin(ranges); !(it2 == attic_tags_db.range_end()); ++it2)
{
if (it2.object().timestamp > timestamp && it2.index().value != void_tag_value()
&& (!relevant_ids || std::binary_search(
relevant_ids->begin(), relevant_ids->end(), std::make_pair(it2.object().id, Uint31_Index(0u))))
&& krit->second->matches(it2.index().value))
{
std::pair< uint64, Uint31_Index >& ref = timestamp_per_id[it2.object().id];
Expand Down
62 changes: 7 additions & 55 deletions src/overpass_api/osm-backend/area_updater.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,15 @@ void Area_Updater::prepare_delete_tags
Ranges< Tag_Index_Local > ranges;
for (auto it = to_delete_coarse.begin(); it != to_delete_coarse.end(); ++it)
ranges.push_back({ it->first, "", "" }, { it->first + 1, "", "" });

ranges.sort();

// iterate over the result
Block_Backend< Tag_Index_Local, Uint32_Index > areas_db
(transaction->data_index(area_settings().AREA_TAGS_LOCAL));
Tag_Index_Local current_index;
Tag_Entry< uint32 > tag_entry;
current_index.index = 0xffffffff;
std::set< Area::Id_Type >* handle = 0;
for (auto it = areas_db.range_begin(ranges); !(it == areas_db.range_end()); ++it)
{
if (!(current_index == it.index()))
Expand All @@ -177,16 +179,18 @@ void Area_Updater::prepare_delete_tags
tag_entry.key = it.index().key;
tag_entry.value = it.index().value;
tag_entry.ids.clear();

handle = &to_delete_coarse[it.index().index];
}

std::set< Area::Id_Type >& handle(to_delete_coarse[it.index().index]);
if (handle.find(it.object().val()) != handle.end())
if (handle->find(it.object().val()) != handle->end())
tag_entry.ids.push_back(it.object().val());
}
if ((current_index.index != 0xffffffff) && (!tag_entry.ids.empty()))
tags_to_delete.push_back(tag_entry);
}


Area_Location* binary_search_for_id
(std::vector< std::pair< Area_Location, Uint31_Index > >& vect, uint32 id)
{
Expand All @@ -206,58 +210,6 @@ Area_Location* binary_search_for_id
return 0;
}

void Area_Updater::prepare_tags
(std::vector< Tag_Entry< uint32 > >& tags_to_delete,
const std::map< uint32, std::vector< uint32 > >& to_delete)
{
// make indices appropriately coarse
std::map< uint32, std::set< uint32 > > to_delete_coarse;
for (std::map< uint32, std::vector< uint32 > >::const_iterator
it(to_delete.begin()); it != to_delete.end(); ++it)
{
std::set< uint32 >& handle(to_delete_coarse[it->first & 0xffffff00]);
for (std::vector< uint32 >::const_iterator it2(it->second.begin());
it2 != it->second.end(); ++it2)
handle.insert(*it2);
}

// formulate range query
Ranges< Tag_Index_Local > ranges;
for (auto it = to_delete_coarse.begin(); it != to_delete_coarse.end(); ++it)
ranges.push_back({ it->first, "", "" }, { it->first + 1, "", "" });

// iterate over the result
Block_Backend< Tag_Index_Local, Uint32_Index > areas_db
(transaction->data_index(area_settings().AREA_TAGS_LOCAL));
Tag_Index_Local current_index;
Tag_Entry< uint32 > tag_entry;
current_index.index = 0xffffffff;
for (auto it = areas_db.range_begin(ranges); !(it == areas_db.range_end()); ++it)
{
if (!(current_index == it.index()))
{
if ((current_index.index != 0xffffffff) && (!tag_entry.ids.empty()))
tags_to_delete.push_back(tag_entry);
current_index = it.index();
tag_entry.index = it.index().index;
tag_entry.key = it.index().key;
tag_entry.value = it.index().value;
tag_entry.ids.clear();
}

std::set< uint32 >& handle(to_delete_coarse[it.index().index]);
if (handle.find(it.object().val()) != handle.end())
{
Area_Location* area(binary_search_for_id(areas_to_insert, it.object().val()));
if (area != 0)
area->tags.push_back(std::make_pair(it.index().key, it.index().value));
tag_entry.ids.push_back(it.object().val());
}
}
if ((current_index.index != 0xffffffff) && (!tag_entry.ids.empty()))
tags_to_delete.push_back(tag_entry);
}

void Area_Updater::update_area_tags_local
(const std::vector< Tag_Entry< uint32 > >& tags_to_delete)
{
Expand Down
3 changes: 0 additions & 3 deletions src/overpass_api/osm-backend/area_updater.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ struct Area_Updater : public Area_Usage_Listener
void prepare_delete_tags
(std::vector< Tag_Entry< uint32 > >& tags_to_delete,
const std::map< Uint31_Index, std::set< Area_Skeleton > >& to_delete);
void prepare_tags
(std::vector< Tag_Entry< uint32 > >& tags_to_delete,
const std::map< uint32, std::vector< uint32 > >& to_delete);
void update_area_tags_local
(const std::vector< Tag_Entry< uint32 > >& tags_to_delete);
void update_area_tags_global
Expand Down
2 changes: 1 addition & 1 deletion src/overpass_api/statements/coord_query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ void Coord_Query_Statement::execute(Resource_Manager& rman)
while (!tai.is_end() && tai.get_idx().val() < idx.val())
tai.next();
if (tai.is_end())
continue;
break;

if (cur_it->first == tai.get_idx())
{
Expand Down
Loading

0 comments on commit e21c39f

Please sign in to comment.