Refactor name of legacy class _Node into more telling name ExternalMemoryNode

This commit is contained in:
Dennis Luxen 2013-11-12 18:23:09 -05:00
parent 3da664236c
commit 510cc22484
7 changed files with 38 additions and 19 deletions

View File

@ -32,15 +32,31 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../DataStructures/HashTable.h"
struct _Node : NodeInfo{
_Node(int _lat, int _lon, unsigned int _id, bool _bollard, bool _trafficLight) : NodeInfo(_lat, _lon, _id), bollard(_bollard), trafficLight(_trafficLight) {}
_Node() : bollard(false), trafficLight(false) {}
struct ExternalMemoryNode : NodeInfo {
ExternalMemoryNode(
int lat,
int lon,
unsigned int id,
bool bollard,
bool traffic_light
) :
NodeInfo(lat, lon, id),
bollard(bollard),
trafficLight(traffic_light)
{ }
ExternalMemoryNode() : bollard(false), trafficLight(false) {}
static _Node min_value() {
return _Node(0,0,0, false, false);
static ExternalMemoryNode min_value() {
return ExternalMemoryNode(0,0,0, false, false);
}
static _Node max_value() {
return _Node((std::numeric_limits<int>::max)(), (std::numeric_limits<int>::max)(), (std::numeric_limits<unsigned int>::max)(), false, false);
static ExternalMemoryNode max_value() {
return ExternalMemoryNode(
std::numeric_limits<int>::max(),
std::numeric_limits<int>::max(),
std::numeric_limits<unsigned>::max(),
false,
false
);
}
NodeID key() const {
return id;
@ -49,7 +65,7 @@ struct _Node : NodeInfo{
bool trafficLight;
};
struct ImportNode : public _Node {
struct ImportNode : public ExternalMemoryNode {
HashTable<std::string, std::string> keyVals;
inline void Clear() {

View File

@ -165,7 +165,7 @@ void ExtractionContainers::PrepareData(const std::string & output_file_name, con
continue;
}
if(*usedNodeIDsIT == nodesIT->id) {
fout.write((char*)&(*nodesIT), sizeof(_Node));
fout.write((char*)&(*nodesIT), sizeof(ExternalMemoryNode));
++usedNodeCounter;
++usedNodeIDsIT;
++nodesIT;

View File

@ -41,7 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
class ExtractionContainers {
public:
typedef stxxl::vector<NodeID> STXXLNodeIDVector;
typedef stxxl::vector<_Node> STXXLNodeVector;
typedef stxxl::vector<ExternalMemoryNode> STXXLNodeVector;
typedef stxxl::vector<InternalExtractorEdge> STXXLEdgeVector;
typedef stxxl::vector<std::string> STXXLStringVector;
typedef stxxl::vector<_RawRestrictionContainer> STXXLRestrictionsVector;

View File

@ -36,7 +36,7 @@ ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers * ext, StringMap * s
ExtractorCallbacks::~ExtractorCallbacks() { }
/** warning: caller needs to take care of synchronization! */
void ExtractorCallbacks::nodeFunction(const _Node &n) {
void ExtractorCallbacks::nodeFunction(const ExternalMemoryNode &n) {
if(n.lat <= 85*COORDINATE_PRECISION && n.lat >= -85*COORDINATE_PRECISION) {
externalMemory->allNodes.push_back(n);
}

View File

@ -55,7 +55,7 @@ public:
~ExtractorCallbacks();
/** warning: caller needs to take care of synchronization! */
void nodeFunction(const _Node &n);
void nodeFunction(const ExternalMemoryNode &n);
bool restrictionFunction(const _RawRestrictionContainer &r);

View File

@ -172,16 +172,19 @@ struct Cmp : public std::binary_function<NodeID, NodeID, bool> {
}
};
struct CmpNodeByID : public std::binary_function<_Node, _Node, bool> {
typedef _Node value_type;
bool operator () (const _Node & a, const _Node & b) const {
struct CmpNodeByID : public std::binary_function<ExternalMemoryNode, ExternalMemoryNode, bool> {
typedef ExternalMemoryNode value_type;
bool operator () (
const ExternalMemoryNode & a,
const ExternalMemoryNode & b
) const {
return a.id < b.id;
}
value_type max_value() {
return _Node::max_value();
return ExternalMemoryNode::max_value();
}
value_type min_value() {
return _Node::min_value();
return ExternalMemoryNode::min_value();
}
};

View File

@ -84,9 +84,9 @@ NodeID readBinaryOSRMGraphFromStream(
ExternalNodeMap ext_to_int_id_map;
in.read((char*)&n, sizeof(NodeID));
SimpleLogger().Write() << "Importing n = " << n << " nodes ";
_Node node;
ExternalMemoryNode node;
for (NodeID i=0; i<n; ++i) {
in.read((char*)&node, sizeof(_Node));
in.read((char*)&node, sizeof(ExternalMemoryNode));
int2ExtNodeMap->push_back(NodeInfo(node.lat, node.lon, node.id));
ext_to_int_id_map.emplace(node.id, i);
if(node.bollard) {