Skip to content

Commit

Permalink
Merge pull request #650 from codepainters/master
Browse files Browse the repository at this point in the history
Ensure ImportThread is always terminated.
  • Loading branch information
lonvia authored Mar 1, 2022
2 parents 15275dd + b06dd18 commit ab9f7ed
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions src/main/java/de/komoot/photon/nominatim/NominatimConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,31 +264,34 @@ public void readEntireDatabase(String... countryCodes) {

ImportThread importThread = new ImportThread(importer);

template.query(SELECT_COLS_PLACEX + " FROM placex " +
" WHERE linked_place_id IS NULL AND centroid IS NOT NULL " + andCountryCodeStr +
" ORDER BY geometry_sector, parent_place_id; ", rs -> {
// turns a placex row into a photon document that gathers all de-normalised information
NominatimResult docs = placeRowMapper.mapRow(rs, 0);
assert(docs != null);

if (docs.isUsefulForIndex()) {
importThread.addDocument(docs);
}
});

template.query(selectOsmlineSql + " FROM location_property_osmline " +
"WHERE startnumber is not null " +
andCountryCodeStr +
" ORDER BY geometry_sector, parent_place_id; ", rs -> {
NominatimResult docs = osmlineRowMapper.mapRow(rs, 0);
assert(docs != null);

if (docs.isUsefulForIndex()) {
importThread.addDocument(docs);
}
});

importThread.finish();
try {
template.query(SELECT_COLS_PLACEX + " FROM placex " +
" WHERE linked_place_id IS NULL AND centroid IS NOT NULL " + andCountryCodeStr +
" ORDER BY geometry_sector, parent_place_id; ", rs -> {
// turns a placex row into a photon document that gathers all de-normalised information
NominatimResult docs = placeRowMapper.mapRow(rs, 0);
assert (docs != null);

if (docs.isUsefulForIndex()) {
importThread.addDocument(docs);
}
});

template.query(selectOsmlineSql + " FROM location_property_osmline " +
"WHERE startnumber is not null " +
andCountryCodeStr +
" ORDER BY geometry_sector, parent_place_id; ", rs -> {
NominatimResult docs = osmlineRowMapper.mapRow(rs, 0);
assert (docs != null);

if (docs.isUsefulForIndex()) {
importThread.addDocument(docs);
}
});

} finally {
importThread.finish();
}
}

/**
Expand Down

0 comments on commit ab9f7ed

Please sign in to comment.