2222#include < unordered_map>
2323#include < vector>
2424
25- gen_rivers_t ::gen_rivers_t (pg_conn_t *connection, params_t *params)
26- : gen_base_t (connection, params), m_timer_area(add_timer(" area" )),
25+ gen_rivers_t ::gen_rivers_t (pg_conn_t *connection, bool append, params_t *params)
26+ : gen_base_t (connection, append, params), m_timer_area(add_timer(" area" )),
2727 m_timer_prep (add_timer(" prep" )), m_timer_get(add_timer(" get" )),
2828 m_timer_sort(add_timer(" sort" )), m_timer_net(add_timer(" net" )),
2929 m_timer_remove(add_timer(" remove" )), m_timer_width(add_timer(" width" )),
30- m_timer_write(add_timer(" write" )),
31- m_delete_existing(params->has (" delete_existing" ))
30+ m_timer_write(add_timer(" write" ))
3231{
3332 check_src_dest_table_params_exist ();
3433
@@ -197,7 +196,11 @@ void gen_rivers_t::process()
197196 dbexec (R"( UPDATE {qualified_src_areas} SET width =)"
198197 R"( (ST_MaximumInscribedCircle("{geom_column}")).radius * 2)"
199198 R"( WHERE width IS NULL)" );
200- dbexec (" ANALYZE {qualified_src_areas}" );
199+
200+ if (!append_mode ()) {
201+ dbexec (" ANALYZE {qualified_src_areas}" );
202+ }
203+
201204 timer (m_timer_area).stop ();
202205
203206 log_gen (" Get 'width' from areas onto lines..." );
@@ -323,7 +326,7 @@ SELECT "{id_column}", "{width_column}", "{name_column}", "{geom_column}"
323326 }
324327 timer (m_timer_width).stop ();
325328
326- if (m_delete_existing ) {
329+ if (append_mode () ) {
327330 dbexec (" TRUNCATE {dest}" );
328331 }
329332
@@ -343,7 +346,9 @@ SELECT "{id_column}", "{width_column}", "{name_column}", "{geom_column}"
343346 connection ().exec (" COMMIT" );
344347 timer (m_timer_write).stop ();
345348
346- dbexec (" ANALYZE {dest}" );
349+ if (!append_mode ()) {
350+ dbexec (" ANALYZE {dest}" );
351+ }
347352
348353 log_gen (" Done." );
349354}
0 commit comments