[Tile-serving] [openstreetmap/osm2pgsql] New dependency manager (#1168)
Sarah Hoffmann
notifications at github.com
Wed May 13 20:38:22 UTC 2020
@lonvia commented on this pull request.
The code needs to go through clang-format.
> + * This base class doesn't actually do the dependency management but is a
+ * dummy for cases where no dependency management is needed. See the
+ * full_dependency_manager_t class for the real dependency manager.
+ */
+class dependency_manager_t
+{
+public:
+ virtual ~dependency_manager_t() = default;
+
+ /**
+ * Mark a node as changed to trigger the propagation of this change to
+ * ways and relations.
+ *
+ * This has to be called *after* the object was stored in the object store.
+ */
+ virtual void node_changed(osmid_t) {};
remove semicolon, also below
> + }
+}
+
+void full_dependency_manager_t::way_changed(osmid_t id) {
+ if (m_ways_pending_tracker.is_marked(id)) {
+ return;
+ }
+
+ for (auto const rel_id : m_object_store->get_rels_by_way(id)) {
+ m_rels_pending_tracker.mark(rel_id);
+ }
+}
+
+void full_dependency_manager_t::relation_changed(osmid_t id) {
+ if (m_rels_pending_tracker.is_marked(id)) {
+ return;
This is not true. A marked relation has not necessarily marked its dependencies. That would only be true if we called relation_changed in lines 11, 21 and 31.
> @@ -63,7 +63,17 @@ int main(int argc, char *argv[])
auto const outputs =
output_t::create_outputs(middle->get_query_instance(), options);
- osmdata_t osmdata{middle, outputs};
+ bool const need_dependencies =
+ std::any_of(outputs.cbegin(), outputs.cend(),
+ [](std::shared_ptr<output_t> const &output) {
+ return output->need_forward_dependencies();
+ });
+
+ auto dependency_manager = std::unique_ptr<dependency_manager_t>(
+ need_dependencies ? new full_dependency_manager_t{middle.get()}
+ : new dependency_manager_t{});
+
+ osmdata_t osmdata{dependency_manager.get(), middle, outputs};
Any particular reason not to hand ownership over to osmdata? Or rather move the code into the osmdata constructor?
> + *
+ * \tparam TOutputIterator Some output iterator type, for instance
+ * created with std::back_inserter(some vector).
+ * \param it output iterator to which all ids should be written. *it
+ * must be of type osmid_t.
+ */
+ template <typename TOutputIterator>
+ void get_pending_relation_ids(TOutputIterator &&it) {
+ osmid_t id;
+ while (id_tracker::is_valid(id = m_rels_pending_tracker.pop_mark())) {
+ *it++ = id;
+ }
+ }
+
+private:
+ middle_t* m_object_store;
make that a shared ptr?
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/pull/1168#pullrequestreview-411269193
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20200513/aa245e66/attachment.htm>
More information about the Tile-serving
mailing list