@@ -126,19 +126,27 @@ int Partitioner::Run(const PartitionerConfig &config)
126126 renumber (partitions, permutation);
127127 {
128128 renumber (mapping, permutation);
129- extractor::files::writeNBGMapping (config.GetPath (" .osrm.cnbg_to_ebg" ).string (), mapping);
129+ extractor::files::writeNBGMapping (config.GetOutputPath (" .osrm.cnbg_to_ebg" ).string (),
130+ mapping);
130131 }
131132 {
133+ // If writing to a different output path, copy the file first since we mmap in-place
134+ if (!config.output_path .empty ())
135+ {
136+ std::filesystem::copy_file (config.GetPath (" .osrm.fileIndex" ),
137+ config.GetOutputPath (" .osrm.fileIndex" ),
138+ std::filesystem::copy_options::overwrite_existing);
139+ }
132140 boost::iostreams::mapped_file segment_region;
133141 auto segments = util::mmapFile<extractor::EdgeBasedNodeSegment>(
134- config.GetPath (" .osrm.fileIndex" ), segment_region);
142+ config.GetOutputPath (" .osrm.fileIndex" ), segment_region);
135143 renumber (segments, permutation);
136144 }
137145 {
138146 extractor::EdgeBasedNodeDataContainer node_data;
139147 extractor::files::readNodeData (config.GetPath (" .osrm.ebg_nodes" ), node_data);
140148 renumber (node_data, permutation);
141- extractor::files::writeNodeData (config.GetPath (" .osrm.ebg_nodes" ), node_data);
149+ extractor::files::writeNodeData (config.GetOutputPath (" .osrm.ebg_nodes" ), node_data);
142150 }
143151 {
144152 std::vector<EdgeWeight> node_weights;
@@ -151,10 +159,11 @@ int Partitioner::Run(const PartitionerConfig &config)
151159 util::inplacePermutation (node_durations.begin (), node_durations.end (), permutation);
152160 util::inplacePermutation (node_distances.begin (), node_distances.end (), permutation);
153161 extractor::files::writeEdgeBasedNodeWeightsDurationsDistances (
154- config.GetPath (" .osrm.enw" ), node_weights, node_durations, node_distances);
162+ config.GetOutputPath (" .osrm.enw" ), node_weights, node_durations, node_distances);
155163 }
156164 {
157165 const auto &filename = config.GetPath (" .osrm.maneuver_overrides" );
166+ const auto &output_filename = config.GetOutputPath (" .osrm.maneuver_overrides" );
158167 std::vector<extractor::StorageManeuverOverride> maneuver_overrides;
159168 std::vector<NodeID> node_sequences;
160169 extractor::files::readManeuverOverrides (filename, maneuver_overrides, node_sequences);
@@ -168,13 +177,14 @@ int Partitioner::Run(const PartitionerConfig &config)
168177 maneuver_overrides.end (),
169178 [](const auto &a, const auto &b) { return a.start_node < b.start_node ; });
170179
171- extractor::files::writeManeuverOverrides (filename, maneuver_overrides, node_sequences);
180+ extractor::files::writeManeuverOverrides (
181+ output_filename, maneuver_overrides, node_sequences);
172182 }
173- if (std::filesystem::exists (config.GetPath (" .osrm.hsgr" )))
183+ if (std::filesystem::exists (config.GetOutputPath (" .osrm.hsgr" )))
174184 {
175185 util::Log (logWARNING) << " Found existing .osrm.hsgr file, removing. You need to re-run "
176186 " osrm-contract after osrm-partition." ;
177- std::filesystem::remove (config.GetPath (" .osrm.hsgr" ));
187+ std::filesystem::remove (config.GetOutputPath (" .osrm.hsgr" ));
178188 }
179189 TIMER_STOP (renumber);
180190 util::Log () << " Renumbered data in " << TIMER_SEC (renumber) << " seconds" ;
@@ -190,9 +200,9 @@ int Partitioner::Run(const PartitionerConfig &config)
190200 util::Log () << " CellStorage constructed in " << TIMER_SEC (cell_storage) << " seconds" ;
191201
192202 TIMER_START (writing_mld_data);
193- files::writePartition (config.GetPath (" .osrm.partition" ), mlp);
194- files::writeCells (config.GetPath (" .osrm.cells" ), storage);
195- extractor::files::writeEdgeBasedGraph (config.GetPath (" .osrm.ebg" ),
203+ files::writePartition (config.GetOutputPath (" .osrm.partition" ), mlp);
204+ files::writeCells (config.GetOutputPath (" .osrm.cells" ), storage);
205+ extractor::files::writeEdgeBasedGraph (config.GetOutputPath (" .osrm.ebg" ),
196206 edge_based_graph.GetNumberOfNodes (),
197207 graphToEdges (edge_based_graph),
198208 edge_based_graph.connectivity_checksum );
0 commit comments