Search in sources :

Example 1 with CHStorage

use of com.graphhopper.storage.CHStorage in project graphhopper by graphhopper.

the class CHPreparationHandler method load.

public Map<String, RoutingCHGraph> load(GraphHopperStorage ghStorage, List<CHConfig> chConfigs) {
    Map<String, RoutingCHGraph> loaded = Collections.synchronizedMap(new LinkedHashMap<>());
    List<Callable<String>> callables = chConfigs.stream().map(c -> (Callable<String>) () -> {
        CHStorage chStorage = ghStorage.loadCHStorage(c.getName(), c.isEdgeBased());
        if (chStorage != null)
            loaded.put(c.getName(), ghStorage.createCHGraph(chStorage, c));
        else {
            // todo: this is ugly, see comments in LMPreparationHandler
            ghStorage.getDirectory().remove("nodes_ch_" + c.getName());
            ghStorage.getDirectory().remove("shortcuts_" + c.getName());
        }
        return c.getName();
    }).collect(Collectors.toList());
    GHUtility.runConcurrently(callables, preparationThreads);
    return loaded;
}
Also used : RoutingCHGraph(com.graphhopper.storage.RoutingCHGraph) java.util(java.util) Logger(org.slf4j.Logger) GraphHopperConfig(com.graphhopper.GraphHopperConfig) Helper.createFormatter(com.graphhopper.util.Helper.createFormatter) PMap(com.graphhopper.util.PMap) LoggerFactory(org.slf4j.LoggerFactory) CHConfig(com.graphhopper.storage.CHConfig) CHStorage(com.graphhopper.storage.CHStorage) Callable(java.util.concurrent.Callable) GHUtility(com.graphhopper.util.GHUtility) CHProfile(com.graphhopper.config.CHProfile) Collectors(java.util.stream.Collectors) GraphHopperStorage(com.graphhopper.storage.GraphHopperStorage) Helper.getMemInfo(com.graphhopper.util.Helper.getMemInfo) CH(com.graphhopper.util.Parameters.CH) CHStorage(com.graphhopper.storage.CHStorage) RoutingCHGraph(com.graphhopper.storage.RoutingCHGraph) Callable(java.util.concurrent.Callable)

Aggregations

GraphHopperConfig (com.graphhopper.GraphHopperConfig)1 CHProfile (com.graphhopper.config.CHProfile)1 CHConfig (com.graphhopper.storage.CHConfig)1 CHStorage (com.graphhopper.storage.CHStorage)1 GraphHopperStorage (com.graphhopper.storage.GraphHopperStorage)1 RoutingCHGraph (com.graphhopper.storage.RoutingCHGraph)1 GHUtility (com.graphhopper.util.GHUtility)1 Helper.createFormatter (com.graphhopper.util.Helper.createFormatter)1 Helper.getMemInfo (com.graphhopper.util.Helper.getMemInfo)1 PMap (com.graphhopper.util.PMap)1 CH (com.graphhopper.util.Parameters.CH)1 java.util (java.util)1 Callable (java.util.concurrent.Callable)1 Collectors (java.util.stream.Collectors)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1