Skip to content

Commit 1bad5da

Browse files
authored
Merge pull request #1904 from joto/flush-copy
Flush COPY between nodes/ways and ways/relations respectively
2 parents 37e80f5 + 27dd4dc commit 1bad5da

6 files changed

Lines changed: 41 additions & 7 deletions

File tree

src/db-copy-mgr.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,18 +271,22 @@ class db_copy_mgr_t
271271
m_current->add_deletable(std::forward<ARGS>(args)...);
272272
}
273273

274+
void flush()
275+
{
276+
// finish any ongoing copy operations
277+
if (m_current) {
278+
m_processor->add_buffer(std::move(m_current));
279+
}
280+
}
281+
274282
/**
275283
* Synchronize with worker.
276284
*
277285
* Only returns when all previously issued commands are done.
278286
*/
279287
void sync()
280288
{
281-
// finish any ongoing copy operations
282-
if (m_current) {
283-
m_processor->add_buffer(std::move(m_current));
284-
}
285-
289+
flush();
286290
m_processor->sync_and_wait();
287291
}
288292

src/flex-table.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ class table_connection_t
247247

248248
pg_result_t get_geom_by_id(osmium::item_type type, osmid_t id) const;
249249

250+
void flush() { m_copy_mgr.flush(); }
251+
250252
void sync() { m_copy_mgr.sync(); }
251253

252254
void new_line() { m_copy_mgr.new_line(m_target); }

src/osmdata.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ void osmdata_t::node(osmium::Node const &node)
6767
}
6868
}
6969

70-
void osmdata_t::after_nodes() { m_mid->after_nodes(); }
70+
void osmdata_t::after_nodes()
71+
{
72+
m_mid->after_nodes();
73+
m_output->after_nodes();
74+
}
7175

7276
void osmdata_t::way(osmium::Way &way)
7377
{
@@ -84,7 +88,11 @@ void osmdata_t::way(osmium::Way &way)
8488
}
8589
}
8690

87-
void osmdata_t::after_ways() { m_mid->after_ways(); }
91+
void osmdata_t::after_ways()
92+
{
93+
m_mid->after_ways();
94+
m_output->after_ways();
95+
}
8896

8997
void osmdata_t::relation(osmium::Relation const &rel)
9098
{

src/output-flex.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,20 @@ void output_flex_t::sync()
10011001
}
10021002
}
10031003

1004+
void output_flex_t::after_nodes()
1005+
{
1006+
for (auto &table : m_table_connections) {
1007+
table.flush();
1008+
}
1009+
}
1010+
1011+
void output_flex_t::after_ways()
1012+
{
1013+
for (auto &table : m_table_connections) {
1014+
table.flush();
1015+
}
1016+
}
1017+
10041018
void output_flex_t::stop()
10051019
{
10061020
for (auto &table : m_table_connections) {

src/output-flex.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ class output_flex_t : public output_t
124124
void stop() override;
125125
void sync() override;
126126

127+
void after_nodes() override;
128+
void after_ways() override;
129+
127130
void wait() override;
128131

129132
idset_t const &get_marked_way_ids() override;

src/output.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ class output_t
6262
virtual void stop() = 0;
6363
virtual void sync() = 0;
6464

65+
virtual void after_nodes() {}
66+
virtual void after_ways() {}
67+
6568
virtual void wait() {}
6669

6770
virtual osmium::index::IdSetSmall<osmid_t> const &get_marked_way_ids()

0 commit comments

Comments
 (0)