yagagagaga opened a new pull request, #882:
URL: https://github.com/apache/incubator-baremaps/pull/882
The implement of `DataConversions#get` (by default) is as follows:
```java
public V get(Object key) {
Iterator<Entry<K,V>> i = entrySet().iterator();
if (key==null) {
while (i.hasNext()) {
Entry<K,V> e = i.next();
if (e.getKey()==null)
return e.getValue();
}
} else {
while (i.hasNext()) {
Entry<K,V> e = i.next();
if (key.equals(e.getKey()))
return e.getValue();
}
}
return null;
}
```
which means that you need to traverse all entities when find an entity. When
there are lots of elements in the map, the cost of each operation is extremely
high.
For example, it will show very clearly when you [Import OSM data into
PostGIS](https://baremaps.apache.org/documentation/examples/import-osm-into-postgis/).
before improvement:
```bash
# take several hours or even more
baremaps workflow execute --file workflow.json
```
after improvement:
```bash
# take several seconds
baremaps workflow execute --file workflow.json
```
Of course, considering that `org.apache.baremaps.data.collection.DataMap`
have different implementations and behaviors, this optimization is not
applicable to all subclass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]