Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two-stage processing when flat node file is used #2303

Merged
merged 2 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions src/middle-pgsql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,17 +762,33 @@ bool middle_query_pgsql_t::node_get(osmid_t id,
{
assert(buffer);

auto const res = m_db_connection.exec_prepared("get_node", id);
if (m_store_options.nodes) {
auto const res = m_db_connection.exec_prepared("get_node", id);

if (res.num_tuples() != 1) {
return false;
if (res.num_tuples() == 1) {
build_node(id, res, 0, 0, buffer, m_store_options.with_attributes);
buffer->commit();
return true;
}
}

build_node(id, res, 0, 0, buffer, m_store_options.with_attributes);
if (m_store_options.use_flat_node_file) {
auto const location = get_node_location_flatnodes(id);
if (!location.valid()) {
return false;
}

buffer->commit();
{
osmium::builder::NodeBuilder builder{*buffer};
builder.set_id(id);
builder.set_location(location);
}

return true;
buffer->commit();
return true;
}

return false;
}

bool middle_query_pgsql_t::way_get(osmid_t id,
Expand Down
26 changes: 25 additions & 1 deletion src/middle-ram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,32 @@ bool middle_ram_t::node_get(osmid_t id, osmium::memory::Buffer *buffer) const
assert(buffer);

if (m_store_options.nodes) {
return get_object(osmium::item_type::node, id, buffer);
auto const got_it = get_object(osmium::item_type::node, id, buffer);
if (got_it) {
return true;
}
}

if (m_store_options.locations) {
osmium::Location location{};
if (m_persistent_cache) {
location = m_persistent_cache->get(id);
}
if (!location.valid()) {
location = m_node_locations.get(id);
}
if (location.valid()) {
{
osmium::builder::NodeBuilder builder{*buffer};
builder.set_id(id);
builder.set_location(location);
}

buffer->commit();
return true;
}
}

return false;
}

Expand Down