Node location cache: off-heap storage and “array” implementation that supports parallel inserts (#131)

* Add --nodemap-type=array option for 2-3x faster osm pass 1 imports
* Add --nodemap-storage=direct option to experiment with direct (off-heap) memory usage
* Extract ResourceUsage and OsmPhaser utilities
This commit is contained in:
Michael Barry
2022-03-19 05:46:03 -04:00
committed by GitHub
parent 9f4271be24
commit 79576f33d7
2 changed files with 15 additions and 9 deletions

View File

@@ -151,7 +151,9 @@ public class TransportationName implements
@Override @Override
public void preprocessOsmNode(OsmElement.Node node) { public void preprocessOsmNode(OsmElement.Node node) {
if (node.hasTag("highway", "motorway_junction")) { if (node.hasTag("highway", "motorway_junction")) {
motorwayJunctionHighwayClasses.put(node.id(), HighwayClass.UNKNOWN.value); synchronized (motorwayJunctionHighwayClasses) {
motorwayJunctionHighwayClasses.put(node.id(), HighwayClass.UNKNOWN.value);
}
} }
} }
@@ -162,13 +164,15 @@ public class TransportationName implements
HighwayClass cls = HighwayClass.from(highway); HighwayClass cls = HighwayClass.from(highway);
if (cls != HighwayClass.UNKNOWN) { if (cls != HighwayClass.UNKNOWN) {
LongArrayList nodes = way.nodes(); LongArrayList nodes = way.nodes();
for (int i = 0; i < nodes.size(); i++) { synchronized (motorwayJunctionHighwayClasses) {
long node = nodes.get(i); for (int i = 0; i < nodes.size(); i++) {
if (motorwayJunctionHighwayClasses.containsKey(node)) { long node = nodes.get(i);
byte oldValue = motorwayJunctionHighwayClasses.get(node); if (motorwayJunctionHighwayClasses.containsKey(node)) {
byte newValue = cls.value; byte oldValue = motorwayJunctionHighwayClasses.get(node);
if (newValue > oldValue) { byte newValue = cls.value;
motorwayJunctionHighwayClasses.put(node, newValue); if (newValue > oldValue) {
motorwayJunctionHighwayClasses.put(node, newValue);
}
} }
} }
} }

View File

@@ -145,7 +145,9 @@ public class Waterway implements
@Override @Override
public List<OsmRelationInfo> preprocessOsmRelation(OsmElement.Relation relation) { public List<OsmRelationInfo> preprocessOsmRelation(OsmElement.Relation relation) {
if (relation.hasTag("waterway", "river") && !Utils.nullOrEmpty(relation.getString("name"))) { if (relation.hasTag("waterway", "river") && !Utils.nullOrEmpty(relation.getString("name"))) {
riverRelationLengths.put(relation.id(), new AtomicDouble()); synchronized (riverRelationLengths) {
riverRelationLengths.put(relation.id(), new AtomicDouble());
}
return List.of(new WaterwayRelation(relation.id(), LanguageUtils.getNames(relation.tags(), translations))); return List.of(new WaterwayRelation(relation.id(), LanguageUtils.getNames(relation.tags(), translations)));
} }
return null; return null;