Skip to content

Commit

Permalink
perf: switch from Java to HPPC hash map
Browse files Browse the repository at this point in the history
  • Loading branch information
aoles committed Apr 12, 2024
1 parent dc279a2 commit c72f45a
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.heigit.ors.routing.graphhopper.extensions;

import com.carrotsearch.hppc.LongArrayList;
import com.graphhopper.coll.GHLongObjectHashMap;
import com.graphhopper.reader.ReaderNode;
import com.graphhopper.reader.ReaderWay;
import com.graphhopper.reader.osm.OSMReader;
Expand All @@ -39,9 +40,7 @@ public class ORSOSMReader extends OSMReader {
private boolean processNodeTags;
private final OSMDataReaderContext readerCntx;

//FIXME: big regular hashmaps should be avoided because they don't support MMAP
private final HashMap<Long, HashMap<String, String>> nodeTags = new HashMap<>();

private final GHLongObjectHashMap<Map<String, String>> nodeTags = new GHLongObjectHashMap(200, 0.5);
private boolean processGeom = false;
private boolean processSimpleGeom = false;
private boolean processWholeGeom = false;
Expand Down Expand Up @@ -171,7 +170,6 @@ protected void processWay(ReaderWay way) {
*/
@Override
public void onProcessWay(ReaderWay way) {

Map<Integer, Map<String, String>> tags = new HashMap<>();
ArrayList<Coordinate> coords = new ArrayList<>();
ArrayList<Coordinate> allCoordinates = new ArrayList<>();
Expand All @@ -189,7 +187,7 @@ public void onProcessWay(ReaderWay way) {
long id = osmNodeIds.get(i);
// replace the osm id with the internal id
int internalId = getNodeMap().get(id);
HashMap<String, String> tagsForNode = nodeTags.get(id);
Map<String, String> tagsForNode = nodeTags.get(id);

if (tagsForNode != null) {
tags.put(internalId, nodeTags.get(id));
Expand Down

0 comments on commit c72f45a

Please sign in to comment.