-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements Mapping for NodeBasedGraph -> EdgeBasedgraph Translation
- Loading branch information
1 parent
f63cb28
commit ad9ea6e
Showing
8 changed files
with
201 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
include/extractor/node_based_graph_to_edge_based_graph_mapping_writer.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#ifndef NODE_BASED_GRAPH_TO_EDGE_BASED_GRAPH_MAPPING_WRITER_HPP | ||
#define NODE_BASED_GRAPH_TO_EDGE_BASED_GRAPH_MAPPING_WRITER_HPP | ||
|
||
#include "storage/io.hpp" | ||
#include "util/log.hpp" | ||
#include "util/typedefs.hpp" | ||
|
||
#include <boost/assert.hpp> | ||
|
||
#include <cstddef> | ||
|
||
#include <string> | ||
|
||
namespace osrm | ||
{ | ||
namespace extractor | ||
{ | ||
|
||
// Writes: | Fingerprint | #mappings | u v head tail | u v head tail | .. | ||
// - uint64: number of mappings (u, v, head, tail) chunks | ||
// - NodeID u, NodeID v, EdgeID head, EdgeID tail | ||
|
||
struct NodeBasedGraphToEdgeBasedGraphMappingWriter | ||
{ | ||
NodeBasedGraphToEdgeBasedGraphMappingWriter(const std::string &path) | ||
: writer{path, storage::io::FileWriter::GenerateFingerprint}, num_written{0} | ||
{ | ||
const std::uint64_t dummy{0}; // filled in later | ||
writer.WriteElementCount64(dummy); | ||
} | ||
|
||
void WriteMapping(NodeID u, NodeID v, EdgeID head, EdgeID tail) | ||
{ | ||
BOOST_ASSERT(u != SPECIAL_NODEID); | ||
BOOST_ASSERT(v != SPECIAL_NODEID); | ||
BOOST_ASSERT(head != SPECIAL_EDGEID || tail != SPECIAL_EDGEID); | ||
|
||
writer.WriteOne(u); | ||
writer.WriteOne(v); | ||
writer.WriteOne(head); | ||
writer.WriteOne(tail); | ||
|
||
num_written += 1; | ||
} | ||
|
||
~NodeBasedGraphToEdgeBasedGraphMappingWriter() | ||
{ | ||
if (num_written != 0) | ||
{ | ||
writer.SkipToBeginning(); | ||
writer.WriteOne(num_written); | ||
} | ||
} | ||
|
||
private: | ||
storage::io::FileWriter writer; | ||
std::uint64_t num_written; | ||
}; | ||
|
||
} // ns extractor | ||
} // ns osrm | ||
|
||
#endif // NODE_BASED_GRAPH_TO_EDGE_BASED_GRAPH_MAPPING_WRITER_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.