File tree Expand file tree Collapse file tree 7 files changed +32
-11
lines changed
Expand file tree Collapse file tree 7 files changed +32
-11
lines changed Original file line number Diff line number Diff line change @@ -262,10 +262,12 @@ class db_copy_mgr_t
262262
263263 void flush ()
264264 {
265- // finish any ongoing copy operations
265+ // flush current buffer if there is one
266266 if (m_current) {
267267 m_processor->add_buffer (std::move (m_current));
268268 }
269+ // close any ongoing copy operations
270+ m_processor->end_copy ();
269271 }
270272
271273 /* *
Original file line number Diff line number Diff line change @@ -105,6 +105,11 @@ void db_copy_thread_t::add_buffer(std::unique_ptr<db_cmd_t> &&buffer)
105105 m_shared.queue_cond .notify_one ();
106106}
107107
108+ void db_copy_thread_t::end_copy ()
109+ {
110+ add_buffer (std::make_unique<db_cmd_end_copy_t >());
111+ }
112+
108113void db_copy_thread_t::sync_and_wait ()
109114{
110115 std::promise<void > barrier;
@@ -157,6 +162,9 @@ void db_copy_thread_t::thread_t::operator()()
157162 case db_cmd_t ::Cmd_copy:
158163 write_to_db (static_cast <db_cmd_copy_t *>(item.get ()));
159164 break ;
165+ case db_cmd_t ::Cmd_end_copy:
166+ finish_copy ();
167+ break ;
160168 case db_cmd_t ::Cmd_sync:
161169 finish_copy ();
162170 static_cast <db_cmd_sync_t *>(item.get ())->barrier .set_value ();
Original file line number Diff line number Diff line change @@ -144,8 +144,9 @@ class db_cmd_t
144144public:
145145 enum cmd_t
146146 {
147- Cmd_copy, // /< Copy buffer content into given target.
148- Cmd_sync, // /< Synchronize with parent.
147+ Cmd_copy, // /< Copy buffer content into given target.
148+ Cmd_end_copy, // /< End COPY command.
149+ Cmd_sync, // /< Synchronize with parent.
149150 Cmd_finish
150151 };
151152
@@ -229,6 +230,11 @@ class db_cmd_copy_delete_t : public db_cmd_copy_t
229230 DELETER m_deleter;
230231};
231232
233+ struct db_cmd_end_copy_t : public db_cmd_t
234+ {
235+ db_cmd_end_copy_t () : db_cmd_t (db_cmd_t ::Cmd_end_copy) {}
236+ };
237+
232238struct db_cmd_sync_t : public db_cmd_t
233239{
234240 std::promise<void > barrier;
@@ -264,6 +270,9 @@ class db_copy_thread_t
264270 */
265271 void add_buffer (std::unique_ptr<db_cmd_t > &&buffer);
266272
273+ // / Close COPY if one is open
274+ void end_copy ();
275+
267276 /* *
268277 * Send sync command and wait for the notification.
269278 */
Original file line number Diff line number Diff line change @@ -191,6 +191,7 @@ void osmdata_t::relation(osmium::Relation const &rel)
191191void osmdata_t::after_relations ()
192192{
193193 m_mid->after_relations ();
194+ m_output->after_relations ();
194195
195196 if (m_append) {
196197 // Remove ids from changed relations in the input data from
Original file line number Diff line number Diff line change @@ -931,19 +931,18 @@ void output_flex_t::sync()
931931 }
932932}
933933
934- void output_flex_t::after_nodes ( )
934+ static void flush_tables (std::vector< table_connection_t > &table_connections )
935935{
936- for (auto &table : m_table_connections ) {
936+ for (auto &table : table_connections ) {
937937 table.flush ();
938938 }
939939}
940940
941- void output_flex_t::after_ways ()
942- {
943- for (auto &table : m_table_connections) {
944- table.flush ();
945- }
946- }
941+ void output_flex_t::after_nodes () { flush_tables (m_table_connections); }
942+
943+ void output_flex_t::after_ways () { flush_tables (m_table_connections); }
944+
945+ void output_flex_t::after_relations () { flush_tables (m_table_connections); }
947946
948947void output_flex_t::stop ()
949948{
Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ class output_flex_t : public output_t
123123
124124 void after_nodes () override ;
125125 void after_ways () override ;
126+ void after_relations () override ;
126127
127128 void wait () override ;
128129
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ class output_t
6565
6666 virtual void after_nodes () {}
6767 virtual void after_ways () {}
68+ virtual void after_relations () {}
6869
6970 virtual void wait () {}
7071
You can’t perform that action at this time.
0 commit comments