--- dao/DaoAdresseService/src/dk/daoas/daoadresseservice/AdressSearch.java 2015/02/15 16:09:11 2301
+++ dao/DaoAdresseService/src/dk/daoas/daoadresseservice/AdressSearch.java 2015/02/15 17:09:02 2305
@@ -23,6 +23,8 @@
List
alleAdresser;
+ Map helperCache;
+
Map hundredePct;
@@ -32,6 +34,7 @@
int postnr=0;
boolean google = false;
boolean osm = false;
+ String helperSearchKey = "";
try {
postnr = Integer.parseInt(postnrStr);
@@ -55,21 +58,38 @@
Long gadeident = postnrVeje.get(vasketVejnavn);
+
if ( gadeident == null) {
- String osmVej = GeocodeHelper.openstreetmapHelper(postnr, split.vej );
- if (osmVej != null) {
- String osmVasket = AddressUtils.vaskVejnavn( osmVej );
- gadeident = postnrVeje.get(osmVasket);
- osm = true;
- }
+ helperSearchKey = "" + postnr + "/" + vasketVejnavn;
+ gadeident = helperCache.get(helperSearchKey);
}
+
if ( gadeident == null) {
String googleVej = GeocodeHelper.googleHelper(postnr, split.vej );
+ google = true;
+
if (googleVej != null) {
String googleVasket = AddressUtils.vaskVejnavn( googleVej );
gadeident = postnrVeje.get(googleVasket);
- google = true;
+
+ if (gadeident != null) {
+ helperCache.put(helperSearchKey, gadeident);
+ }
+ }
+ }
+
+ if ( gadeident == null) {
+ String osmVej = GeocodeHelper.openstreetmapHelper(postnr, split.vej );
+ osm = true;
+
+ if (osmVej != null) {
+ String osmVasket = AddressUtils.vaskVejnavn( osmVej );
+ gadeident = postnrVeje.get(osmVasket);
+
+ if (gadeident != null) {
+ helperCache.put(helperSearchKey, gadeident);
+ }
}
}
@@ -105,7 +125,8 @@
public void buildSearchStructures() throws SQLException{
searchPostnrVejnavnGadeid = new HashMap>();
searchGadeidentAdresser = new HashMap>();
-
+ helperCache = new ConcurrentHashMap();
+
System.out.println("Build -- stage 1");
alleAdresser = DatabaseLayer.getAllAdresses();