You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ArrayIndexOutOfBoundsException encountered with flushing properties to disk with large number of StringEncodedValues. #3102
ArrayIndexOutOfBoundsException encountered with flushing properties to disk when using a StringEncodedValue with large number of entries (768K distinct values). Graphhopper is being used as an embedded Java library.
A custom tag representing the closest road network weather station was included for each way in the OSM datafile and encoded as a StringEncodedValue.
GraphHopper hopper = new GraphHopper();
hopper.init(config);
log.debug("Loading data from source: {}", source);
hopper.setOSMFile(source);
hopper.setImportRegistry(new DefaultImportRegistry() {
@Override
public ImportUnit createImportUnit(String name) {
ImportUnit importUnit = super.createImportUnit(name);
if (WeatherStation.KEY.equals(name))
return ImportUnit.create(name, props -> WeatherStation.create(),
(lookup, props) -> new WeatherStationParser(
lookup.getStringEncodedValue(WeatherStation.KEY)));
return importUnit;
}
});
For a small network, the encoded value works and is retrieved just fine. However, for a large graph representing North America, the import of the OSM file fails when StorableProperties are being flushed to disk.
Expected behavior
Graph is serialized to graph-cache directory.
System Information
Operating system:
macOS 14.6.1
JVM:
openjdk 21.0.5 2024-10-15
OpenJDK Runtime Environment Homebrew (build 21.0.5)
OpenJDK 64-Bit Server VM Homebrew (build 21.0.5, mixed mode, sharing)
GraphHopper:
version 10.0|2024-11-04T16:04:43Z (9,23,7,5,2,9)
Screenshots & Logs
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at com.graphhopper.storage.RAMDataAccess.setBytes(RAMDataAccess.java:241) ~[graphhopper-core-10.0.jar:na]
at com.graphhopper.storage.StorableProperties.flush(StorableProperties.java:71) ~[graphhopper-core-10.0.jar:na]
at com.graphhopper.GraphHopper.flush(GraphHopper.java:1423) ~[graphhopper-core-10.0.jar:na]
at com.graphhopper.GraphHopper.process(GraphHopper.java:831) ~[graphhopper-core-10.0.jar:na]
at com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:774) ~[graphhopper-core-10.0.jar:na]
package ai.moove.routing.ev;
import com.graphhopper.routing.ev.StringEncodedValue;
import lombok.Data;
@Data
public class WeatherStation {
public static final String KEY = "weather";
private final String name;
public static StringEncodedValue create() {
return new StringEncodedValue(KEY, 1000000, false);
}
}
Any comment on this as its occurring in a low level function to flush properties to disk?
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at com.graphhopper.storage.RAMDataAccess.setBytes(RAMDataAccess.java:241) ~[graphhopper-core-10.0.jar:na]
at com.graphhopper.storage.StorableProperties.flush(StorableProperties.java:71) ~[graphhopper-core-10.0.jar:na]
at com.graphhopper.GraphHopper.flush(GraphHopper.java:1423) ~[graphhopper-core-10.0.jar:na]
at com.graphhopper.GraphHopper.process(GraphHopper.java:831) ~[graphhopper-core-10.0.jar:na]
at com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:774) ~[graphhopper-core-10.0.jar:na]
@otbutz thanks for the extra pair of eyes; missed that StorableProperties used a separate segment size hard coded in the constructor.
Would it be advisable that StorableProperties be updated to leverage the same graph.dataaccess.segment_size configuration parameter and default to the local value if not provided (or set to -1)?
Rerun the import using #3129 and the resulting properties file is 64KB large as it requires two DataAccess segments. Judging from the properties.txt the encoded values are the main culprit as each profile also creates a subnetwork EV.
Activity
kbrackney commentedon Jan 11, 2025
Code to encode the tag ref:weather as encoded value weather
src/main/java/ai/moove/routing/ev/WeatherStation.java
src/main/java/ai/moove/routing/util/parsers/WeatherStationParser.java
kbrackney commentedon Feb 6, 2025
Any comment on this as its occurring in a low level function to flush properties to disk?
otbutz commentedon Feb 7, 2025
graphhopper/core/src/main/java/com/graphhopper/storage/StorableProperties.java
Lines 69 to 72 in 6d2c9c3
That
TODOlooks suspicious 😉kbrackney commentedon Feb 15, 2025
@otbutz thanks for the extra pair of eyes; missed that StorableProperties used a separate segment size hard coded in the constructor.
Would it be advisable that StorableProperties be updated to leverage the same
graph.dataaccess.segment_sizeconfiguration parameter and default to the local value if not provided (or set to -1)?otbutz commentedon Feb 25, 2025
I'm running into the same problem now, as GraphHopper is unable to complete the import when a large number of CH profiles are configured 🙈
easbar commentedon Feb 25, 2025
How many?
otbutz commentedon Feb 25, 2025
36 profiles
karussell commentedon Feb 25, 2025
Is it fixed if you use:
(instead of
1 << 15)otbutz commentedon Feb 25, 2025
@karussell I'd have to rerun the import, but a big enough segment size should work. I'd propose #3129 as a proper fix.
otbutz commentedon Feb 25, 2025
Rerun the import using #3129 and the resulting properties file is 64KB large as it requires two DataAccess segments. Judging from the
properties.txtthe encoded values are the main culprit as each profile also creates a subnetwork EV.