refetch data if changed
This commit is contained in:
parent
ca4a3361c0
commit
54c5af30d9
@ -25,12 +25,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef SHARED_DATA_FACADE_H
|
||||||
#ifndef SHARED_DATA_FACADE
|
#define SHARED_DATA_FACADE_H
|
||||||
#define SHARED_DATA_FACADE
|
|
||||||
|
|
||||||
//implements all data storage when shared memory is _NOT_ used
|
//implements all data storage when shared memory is _NOT_ used
|
||||||
|
|
||||||
|
#include <boost/make_shared.hpp>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include "BaseDataFacade.h"
|
#include "BaseDataFacade.h"
|
||||||
#include "SharedDataType.h"
|
#include "SharedDataType.h"
|
||||||
|
|
||||||
@ -57,6 +59,11 @@ private:
|
|||||||
|
|
||||||
SharedDataLayout * data_layout;
|
SharedDataLayout * data_layout;
|
||||||
char * shared_memory;
|
char * shared_memory;
|
||||||
|
SharedDataType * data_type;
|
||||||
|
SharedDataType * data_type_ptr;
|
||||||
|
|
||||||
|
SharedDataType CURRENT_LAYOUT;
|
||||||
|
SharedDataType CURRENT_DATA;
|
||||||
|
|
||||||
unsigned m_check_sum;
|
unsigned m_check_sum;
|
||||||
unsigned m_number_of_nodes;
|
unsigned m_number_of_nodes;
|
||||||
@ -69,9 +76,9 @@ private:
|
|||||||
ShM<TurnInstruction, true>::vector m_turn_instruction_list;
|
ShM<TurnInstruction, true>::vector m_turn_instruction_list;
|
||||||
ShM<char, true>::vector m_names_char_list;
|
ShM<char, true>::vector m_names_char_list;
|
||||||
ShM<unsigned, true>::vector m_name_begin_indices;
|
ShM<unsigned, true>::vector m_name_begin_indices;
|
||||||
StaticRTree<RTreeLeaf, true> * m_static_rtree;
|
boost::shared_ptr<StaticRTree<RTreeLeaf, true> > m_static_rtree;
|
||||||
|
|
||||||
SharedDataFacade() { }
|
// SharedDataFacade() { }
|
||||||
|
|
||||||
void LoadTimestamp() {
|
void LoadTimestamp() {
|
||||||
char * timestamp_ptr = shared_memory + data_layout->GetTimeStampOffset();
|
char * timestamp_ptr = shared_memory + data_layout->GetTimeStampOffset();
|
||||||
@ -86,10 +93,11 @@ private:
|
|||||||
void LoadRTree(
|
void LoadRTree(
|
||||||
const boost::filesystem::path & file_index_path
|
const boost::filesystem::path & file_index_path
|
||||||
) {
|
) {
|
||||||
|
SimpleLogger().Write() << "loading fileindex from " << file_index_path;
|
||||||
RTreeNode * tree_ptr = (RTreeNode *)(
|
RTreeNode * tree_ptr = (RTreeNode *)(
|
||||||
shared_memory + data_layout->GetRSearchTreeOffset()
|
shared_memory + data_layout->GetRSearchTreeOffset()
|
||||||
);
|
);
|
||||||
m_static_rtree = new StaticRTree<RTreeLeaf, true>(
|
m_static_rtree = boost::make_shared<StaticRTree<RTreeLeaf, true> >(
|
||||||
tree_ptr,
|
tree_ptr,
|
||||||
data_layout->r_search_tree_size,
|
data_layout->r_search_tree_size,
|
||||||
file_index_path
|
file_index_path
|
||||||
@ -183,39 +191,62 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SharedDataFacade( const ServerPaths & server_paths ) {
|
SharedDataFacade( ) {
|
||||||
//check contents of config file
|
data_type_ptr = (SharedDataType *)SharedMemoryFactory::Get(
|
||||||
if( server_paths.find("fileindex") == server_paths.end() ) {
|
CURRENT_REGIONS,
|
||||||
throw OSRMException("no leaf index file given in ini file");
|
2*sizeof(SharedDataType),
|
||||||
}
|
false,
|
||||||
|
false
|
||||||
|
)->Ptr();
|
||||||
|
|
||||||
SimpleLogger().Write() << "1";
|
CURRENT_LAYOUT = LAYOUT_NONE;
|
||||||
|
CURRENT_DATA = DATA_NONE;
|
||||||
//generate paths of data files
|
|
||||||
ServerPaths::const_iterator paths_iterator = server_paths.find("fileindex");
|
|
||||||
BOOST_ASSERT(server_paths.end() != paths_iterator);
|
|
||||||
boost::filesystem::path ram_index_path = paths_iterator->second;
|
|
||||||
|
|
||||||
data_layout = (SharedDataLayout *)(
|
|
||||||
SharedMemoryFactory::Get(LAYOUT_1)->Ptr()
|
|
||||||
);
|
|
||||||
|
|
||||||
shared_memory = (char *)(
|
|
||||||
SharedMemoryFactory::Get(DATA_1)->Ptr()
|
|
||||||
);
|
|
||||||
|
|
||||||
data_layout->PrintInformation();
|
|
||||||
|
|
||||||
//load data
|
//load data
|
||||||
SimpleLogger().Write() << "loading graph data";
|
CheckAndReloadFacade();
|
||||||
LoadGraph();
|
|
||||||
LoadNodeAndEdgeInformation();
|
|
||||||
LoadRTree(ram_index_path);
|
|
||||||
LoadTimestamp();
|
|
||||||
LoadViaNodeList();
|
|
||||||
LoadNames();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheckAndReloadFacade() {
|
||||||
|
if(
|
||||||
|
CURRENT_LAYOUT != data_type_ptr[0] ||
|
||||||
|
CURRENT_DATA != data_type_ptr[1]
|
||||||
|
) {
|
||||||
|
CURRENT_LAYOUT = data_type_ptr[0];
|
||||||
|
CURRENT_DATA = data_type_ptr[1];
|
||||||
|
|
||||||
|
data_layout = (SharedDataLayout *)(
|
||||||
|
SharedMemoryFactory::Get(LAYOUT_1)->Ptr()
|
||||||
|
);
|
||||||
|
boost::filesystem::path ram_index_path(data_layout->ram_index_file_name);
|
||||||
|
if( !boost::filesystem::exists(ram_index_path) ) {
|
||||||
|
throw OSRMException("no leaf index file given in ini file");
|
||||||
|
}
|
||||||
|
SimpleLogger().Write() << "0";
|
||||||
|
|
||||||
|
shared_memory = (char *)(
|
||||||
|
SharedMemoryFactory::Get(DATA_1)->Ptr()
|
||||||
|
);
|
||||||
|
|
||||||
|
SimpleLogger().Write(logDEBUG) << "(re-)loading data from shared memory";
|
||||||
|
LoadGraph();
|
||||||
|
SimpleLogger().Write() << "1";
|
||||||
|
LoadNodeAndEdgeInformation();
|
||||||
|
SimpleLogger().Write() << "2";
|
||||||
|
LoadRTree(ram_index_path);
|
||||||
|
SimpleLogger().Write() << "3";
|
||||||
|
LoadTimestamp();
|
||||||
|
SimpleLogger().Write() << "4";
|
||||||
|
LoadViaNodeList();
|
||||||
|
SimpleLogger().Write() << "5";
|
||||||
|
LoadNames();
|
||||||
|
SimpleLogger().Write() << "6";
|
||||||
|
} else {
|
||||||
|
SimpleLogger().Write(logDEBUG) << "using previously loaded data";
|
||||||
|
}
|
||||||
|
data_layout->PrintInformation();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//search graph access
|
//search graph access
|
||||||
unsigned GetNumberOfNodes() const {
|
unsigned GetNumberOfNodes() const {
|
||||||
return m_query_graph->GetNumberOfNodes();
|
return m_query_graph->GetNumberOfNodes();
|
||||||
@ -347,4 +378,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHARED_DATA_FACADE
|
#endif // SHARED_DATA_FACADE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user