144 |
|
|
145 |
return new ConcurrentLinkedQueue<Adresse>(postListe); |
return new ConcurrentLinkedQueue<Adresse>(postListe); |
146 |
} |
} |
|
|
|
147 |
|
|
148 |
public Adresse[] hentDaekkedeAdresserCache( BoundingBox bbox) { |
public Adresse[] hentDaekkedeAdresserCache( BoundingBox bbox, Adresse adresseListe[] ) { |
149 |
long start = System.currentTimeMillis(); |
long start = System.currentTimeMillis(); |
150 |
ArrayList<Adresse> list = new ArrayList<Adresse>(); |
ArrayList<Adresse> list = new ArrayList<Adresse>(); |
151 |
for (Adresse a : alleAdresser) { |
for (Adresse a : adresseListe) { |
152 |
if ( a.latitude > bbox.latitudeMin && a.latitude< bbox.latitudeMax && a.longitude> bbox.longitudeMin && a.longitude < bbox.longitudeMax) { |
if ( a.latitude > bbox.latitudeMin && a.latitude< bbox.latitudeMax && a.longitude> bbox.longitudeMin && a.longitude < bbox.longitudeMax) { |
153 |
list.add(a); |
list.add(a); |
154 |
} |
} |
157 |
logger.info("Elapsed cache: " + (stop - start)); |
logger.info("Elapsed cache: " + (stop - start)); |
158 |
return list.toArray( new Adresse[ list.size() ] ); |
return list.toArray( new Adresse[ list.size() ] ); |
159 |
} |
} |
160 |
|
|
161 |
|
|
162 |
|
public Adresse[] hentDaekkedeAdresserCache( BoundingBox bbox) { |
163 |
|
return hentDaekkedeAdresserCache(bbox, alleAdresser); |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
public Adresse[] hentAlleDaekkedeAdresser() throws SQLException { |
public Adresse[] hentAlleDaekkedeAdresser() throws SQLException { |
178 |
|
|
179 |
// Forward only + concur_read_only + fetchsize tvinger driver til at hente en række af gangen (bedre performance ved store result sets) |
// Forward only + concur_read_only + fetchsize tvinger driver til at hente en række af gangen (bedre performance ved store result sets) |
180 |
// Se http://dev.mysql.com/doc/connector-j/en/connector-j-reference-implementation-notes.html |
// Se http://dev.mysql.com/doc/connector-j/en/connector-j-reference-implementation-notes.html |
|
//PreparedStatement stmt = conn.prepareStatement(sql); |
|
181 |
PreparedStatement stmt = conn.prepareStatement(sql, java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY); |
PreparedStatement stmt = conn.prepareStatement(sql, java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY); |
182 |
stmt.setFetchSize(Integer.MIN_VALUE); |
stmt.setFetchSize(Integer.MIN_VALUE); |
183 |
|
|
222 |
|
|
223 |
saveStmt.addBatch(); |
saveStmt.addBatch(); |
224 |
batchCount++; |
batchCount++; |
225 |
if (batchCount >= 100) { |
if (batchCount >= 1000) { |
226 |
saveStmt.executeBatch(); |
saveStmt.executeBatch(); |
227 |
batchCount = 0; |
batchCount = 0; |
228 |
} |
} |
310 |
|
|
311 |
|
|
312 |
// ////////////////////////////////////////////////////////////////// |
// ////////////////////////////////////////////////////////////////// |
313 |
|
/* |
314 |
@Deprecated |
@Deprecated |
315 |
private BoundingBox getBoundingboxFromDb_old(String postnr) throws SQLException { |
private BoundingBox getBoundingboxFromDb_old(String postnr) throws SQLException { |
316 |
String minPostnr = postnr.replace('x', '0'); |
String minPostnr = postnr.replace('x', '0'); |
406 |
"AND rute is null " + // Træk kun liste på postnumre hvor der er ikke-dækkede adresser |
"AND rute is null " + // Træk kun liste på postnumre hvor der er ikke-dækkede adresser |
407 |
"GROUP BY postnr " + |
"GROUP BY postnr " + |
408 |
"ORDER by postnr"; |
"ORDER by postnr"; |
409 |
*/ |
* / |
410 |
|
|
411 |
|
|
412 |
String sql = "SELECT rpad(left(postnr,?),'4', 'x') as postnr2 " + |
String sql = "SELECT rpad(left(postnr,?),'4', 'x') as postnr2 " + |
438 |
//list.add(8700); |
//list.add(8700); |
439 |
|
|
440 |
return list; |
return list; |
441 |
} |
}*/ |
442 |
|
|
443 |
|
|
444 |
} |
} |