Skip to content

Commit 813d287

Browse files
committed
Store more options internally in osmdata_t
1 parent 0ed8085 commit 813d287

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/osmdata.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ osmdata_t::osmdata_t(std::unique_ptr<dependency_manager_t> dependency_manager,
2323
std::vector<std::shared_ptr<output_t>> outs,
2424
options_t const &options)
2525
: m_dependency_manager(std::move(dependency_manager)), m_mid(std::move(mid)),
26-
m_outs(std::move(outs)), m_with_extra_attrs(options.extra_attributes)
26+
m_outs(std::move(outs)), m_conninfo(options.database_options.conninfo()),
27+
m_num_procs(options.num_procs), m_append(options.append),
28+
m_droptemp(options.droptemp), m_parallel_indexing(options.parallel_indexing),
29+
m_with_extra_attrs(options.extra_attributes)
2730
{
2831
assert(m_dependency_manager);
2932
assert(m_mid);
@@ -375,14 +378,11 @@ void osmdata_t::stop() const
375378
out->sync();
376379
}
377380

378-
// should be the same for all outputs
379-
auto const *opts = m_outs[0]->get_options();
380-
381381
// In append mode there might be dependent objects pending that we
382382
// need to process.
383-
if (opts->append && m_dependency_manager->has_pending()) {
384-
multithreaded_processor proc{opts->database_options.conninfo(), m_mid,
385-
m_outs, (std::size_t)opts->num_procs};
383+
if (m_append && m_dependency_manager->has_pending()) {
384+
multithreaded_processor proc{m_conninfo, m_mid, m_outs,
385+
(std::size_t)m_num_procs};
386386

387387
proc.process_ways(m_dependency_manager->get_pending_way_ids());
388388
proc.process_relations(
@@ -397,10 +397,9 @@ void osmdata_t::stop() const
397397
// Clustering, index creation, and cleanup.
398398
// All the intensive parts of this are long-running PostgreSQL commands
399399
{
400-
osmium::thread::Pool pool{opts->parallel_indexing ? opts->num_procs : 1,
401-
512};
400+
osmium::thread::Pool pool{m_parallel_indexing ? m_num_procs : 1, 512};
402401

403-
if (opts->droptemp) {
402+
if (m_droptemp) {
404403
// When dropping middle tables, make sure they are gone before
405404
// indexing starts.
406405
m_mid->stop(pool);
@@ -410,7 +409,7 @@ void osmdata_t::stop() const
410409
out->stop(&pool);
411410
}
412411

413-
if (!opts->droptemp) {
412+
if (!m_droptemp) {
414413
// When keeping middle tables, there is quite a large index created
415414
// which is better done after the output tables have been copied.
416415
// Note that --disable-parallel-indexing needs to be used to really

src/osmdata.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ class osmdata_t
4343
std::shared_ptr<middle_t> m_mid;
4444
std::vector<std::shared_ptr<output_t>> m_outs;
4545

46+
std::string m_conninfo;
47+
int m_num_procs;
48+
bool m_append;
49+
bool m_droptemp;
50+
bool m_parallel_indexing;
4651
bool m_with_extra_attrs;
52+
4753
};
4854

4955
#endif // OSM2PGSQL_OSMDATA_HPP

0 commit comments

Comments
 (0)