Skip to content

Commit 01eaa14

Browse files
author
Peter
committed
reduced initial overallocation if expectedNodes is too high
1 parent 11fd404 commit 01eaa14

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/main/java/com/graphhopper/reader/OSMReader.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.graphhopper.routing.util.FastestCarCalc;
2222
import com.graphhopper.routing.ch.PrepareContractionHierarchies;
2323
import com.graphhopper.routing.util.PrepareRoutingSubnetworks;
24-
import com.graphhopper.routing.util.PrepareTowerNodesShortcuts;
2524
import com.graphhopper.routing.util.RoutingAlgorithmSpecialAreaTests;
2625
import com.graphhopper.storage.Directory;
2726
import com.graphhopper.storage.Graph;

src/main/java/com/graphhopper/reader/OSMReaderHelperDoubleParse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ public String toString() {
211211
*/
212212
@Override
213213
public void preProcess(InputStream osmXml) {
214-
pillarLats.createNew(expectedNodes / 10);
215-
pillarLons.createNew(expectedNodes / 10);
214+
pillarLats.createNew(Math.max(expectedNodes / 50, 100));
215+
pillarLons.createNew(Math.max(expectedNodes / 50, 100));
216216
if (osmXml == null)
217217
throw new IllegalStateException("Stream cannot be empty");
218218

src/main/java/com/graphhopper/storage/GraphStorage.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,10 @@ public GraphStorage setSegmentSize(int bytes) {
116116
}
117117

118118
public GraphStorage createNew(int nodeCount) {
119-
nodes.createNew((long) nodeCount * 4 * nodeEntrySize);
120-
121-
// approximative
122-
edges.createNew((long) nodeCount * 4 * edgeEntrySize);
123-
geometry.createNew((long) nodeCount / 10);
119+
int initBytes = Math.max(nodeCount * 4 / 50, 100);
120+
nodes.createNew((long) initBytes * nodeEntrySize);
121+
edges.createNew((long) initBytes * edgeEntrySize);
122+
geometry.createNew((long) initBytes);
124123
return this;
125124
}
126125

0 commit comments

Comments
 (0)