Load r-tree search data structure from shared memory
This commit is contained in:
		
							parent
							
								
									e35a78e3cf
								
							
						
					
					
						commit
						bbf03e3060
					
				| @ -70,7 +70,7 @@ static boost::thread_specific_ptr<boost::filesystem::ifstream> thread_local_rtre | ||||
| 
 | ||||
| template<class DataT, bool UseSharedMemory = false> | ||||
| class StaticRTree : boost::noncopyable { | ||||
| private: | ||||
| public: | ||||
|     struct RectangleInt2D { | ||||
|         RectangleInt2D() : | ||||
|             min_lon(INT_MAX), | ||||
| @ -242,6 +242,16 @@ private: | ||||
| 
 | ||||
|     typedef RectangleInt2D RectangleT; | ||||
| 
 | ||||
|     struct TreeNode { | ||||
|         TreeNode() : child_count(0), child_is_on_disk(false) {} | ||||
|         RectangleT minimum_bounding_rectangle; | ||||
|         uint32_t child_count:31; | ||||
|         bool child_is_on_disk:1; | ||||
|         uint32_t children[RTREE_BRANCHING_FACTOR]; | ||||
|     }; | ||||
| 
 | ||||
| private: | ||||
| 
 | ||||
|     struct WrappedInputElement { | ||||
|         explicit WrappedInputElement( | ||||
|             const uint32_t _array_index, | ||||
| @ -264,14 +274,6 @@ private: | ||||
|         DataT objects[RTREE_LEAF_NODE_SIZE]; | ||||
|     }; | ||||
| 
 | ||||
|     struct TreeNode { | ||||
|         TreeNode() : child_count(0), child_is_on_disk(false) {} | ||||
|         RectangleT minimum_bounding_rectangle; | ||||
|         uint32_t child_count:31; | ||||
|         bool child_is_on_disk:1; | ||||
|         uint32_t children[RTREE_BRANCHING_FACTOR]; | ||||
|     }; | ||||
| 
 | ||||
|     struct QueryCandidate { | ||||
|         explicit QueryCandidate( | ||||
|             const uint32_t n_id, | ||||
| @ -454,14 +456,13 @@ public: | ||||
|         //SimpleLogger().Write() << m_element_count << " elements in leafs";
 | ||||
|     } | ||||
| 
 | ||||
|         //Read-only operation for queries
 | ||||
|     explicit StaticRTree( | ||||
|             const TreeNode * tree_node_ptr, | ||||
|             TreeNode * tree_node_ptr, | ||||
|             const uint32_t number_of_nodes, | ||||
|             const boost::filesystem::path & leaf_file | ||||
|     ) : m_leaf_node_filename(leaf_file.string()), | ||||
|         m_search_tree(tree_node_ptr, number_of_nodes) | ||||
|      { | ||||
|     ) : m_search_tree(tree_node_ptr, number_of_nodes), | ||||
|         m_leaf_node_filename(leaf_file.string()) | ||||
|     { | ||||
|         //open leaf node file and store thread specific pointer
 | ||||
|         if ( !boost::filesystem::exists( leaf_file ) ) { | ||||
|             throw OSRMException("mem index file does not exist"); | ||||
| @ -477,6 +478,7 @@ public: | ||||
|         //SimpleLogger().Write() << tree_size << " nodes in search tree";
 | ||||
|         //SimpleLogger().Write() << m_element_count << " elements in leafs";
 | ||||
|     } | ||||
|     //Read-only operation for queries
 | ||||
| /*
 | ||||
|     inline void FindKNearestPhantomNodesForCoordinate( | ||||
|         const FixedPointCoordinate & location, | ||||
|  | ||||
| @ -56,7 +56,7 @@ private: | ||||
|     typename ShM<NodeID, false>::vector               m_via_node_list; | ||||
|     typename ShM<unsigned, false>::vector             m_name_ID_list; | ||||
|     typename ShM<TurnInstruction, false>::vector      m_turn_instruction_list; | ||||
|     StaticRTree<RTreeLeaf, false>          * m_static_rtree; | ||||
|     StaticRTree<RTreeLeaf, false>                   * m_static_rtree; | ||||
| 
 | ||||
| 
 | ||||
|     void LoadTimestamp(const boost::filesystem::path & timestamp_path) { | ||||
|  | ||||
| @ -37,12 +37,14 @@ template<class EdgeDataT> | ||||
| class SharedDataFacade : public BaseDataFacade<EdgeDataT> { | ||||
| 
 | ||||
| private: | ||||
|     typedef BaseDataFacade<EdgeDataT>                   super; | ||||
|     typedef StaticGraph<typename super::EdgeData, true> QueryGraph; | ||||
|     typedef typename StaticGraph<typename super::EdgeData, true>::_StrNode GraphNode; | ||||
|     typedef typename StaticGraph<typename super::EdgeData, true>::_StrEdge GraphEdge; | ||||
|     typedef typename QueryGraph::InputEdge              InputEdge; | ||||
|     typedef typename super::RTreeLeaf                   RTreeLeaf; | ||||
|     typedef EdgeDataT EdgeData; | ||||
|     typedef BaseDataFacade<EdgeData>                        super; | ||||
|     typedef StaticGraph<EdgeData, true>                     QueryGraph; | ||||
|     typedef typename StaticGraph<EdgeData, true>::_StrNode  GraphNode; | ||||
|     typedef typename StaticGraph<EdgeData, true>::_StrEdge  GraphEdge; | ||||
|     typedef typename QueryGraph::InputEdge                  InputEdge; | ||||
|     typedef typename super::RTreeLeaf                       RTreeLeaf; | ||||
|     typedef typename StaticRTree<RTreeLeaf, true>::TreeNode RTreeNode; | ||||
| 
 | ||||
|     unsigned                                m_check_sum; | ||||
|     unsigned                                m_number_of_nodes; | ||||
| @ -75,17 +77,16 @@ private: | ||||
|             SharedMemoryFactory::Get(R_SEARCH_TREE_SIZE)->Ptr() | ||||
|         ); | ||||
|         SharedMemory * search_tree = SharedMemoryFactory::Get(R_SEARCH_TREE); | ||||
|         typedef StaticRTree<RTreeLeaf, true> TreeNode; | ||||
|         TreeNode * tree_ptr = static_cast<TreeNode *>( search_tree->Ptr() ); | ||||
|         // m_static_rtree = new StaticRTree<RTreeLeaf, true>(
 | ||||
|         //     tree_ptr,
 | ||||
|         //     tree_size,
 | ||||
|         //     file_index_path
 | ||||
|         // );
 | ||||
|         RTreeNode * tree_ptr = static_cast<RTreeNode *>( search_tree->Ptr() ); | ||||
|         m_static_rtree = new StaticRTree<RTreeLeaf, true>( | ||||
|             tree_ptr, | ||||
|             tree_size, | ||||
|             file_index_path | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     void LoadGraph() { | ||||
|         uint32_t number_of_nodes = *static_cast<unsigned *>( | ||||
|         m_number_of_nodes = *static_cast<unsigned *>( | ||||
|             SharedMemoryFactory::Get(GRAPH_NODE_LIST_SIZE)->Ptr() | ||||
|         ); | ||||
|         SharedMemory * graph_nodes = SharedMemoryFactory::Get(GRAPH_NODE_LIST); | ||||
| @ -97,7 +98,7 @@ private: | ||||
|         SharedMemory * graph_edges = SharedMemoryFactory::Get(GRAPH_EDGE_LIST); | ||||
|         GraphEdge * graph_edges_ptr = static_cast<GraphEdge *>( graph_edges->Ptr() ); | ||||
| 
 | ||||
|         typename ShM<GraphNode, true>::vector node_list(graph_nodes_ptr, number_of_nodes); | ||||
|         typename ShM<GraphNode, true>::vector node_list(graph_nodes_ptr, m_number_of_nodes); | ||||
|         typename ShM<GraphEdge, true>::vector edge_list(graph_edges_ptr, number_of_edges); | ||||
|         m_query_graph = new QueryGraph( | ||||
|             node_list , | ||||
| @ -110,10 +111,29 @@ private: | ||||
|         uint32_t number_of_coordinates = *static_cast<unsigned *>( | ||||
|             SharedMemoryFactory::Get(COORDINATE_LIST_SIZE)->Ptr() | ||||
|         ); | ||||
|         FixedPointCoordinate * graph_edges_ptr = static_cast<FixedPointCoordinate *>( | ||||
|         FixedPointCoordinate * coordinate_list_ptr = static_cast<FixedPointCoordinate *>( | ||||
|             SharedMemoryFactory::Get(COORDINATE_LIST)->Ptr() | ||||
|         ); | ||||
|         typename ShM<FixedPointCoordinate, true>::vector coordinate_list( | ||||
|                 coordinate_list_ptr, | ||||
|                 number_of_coordinates | ||||
|         ); | ||||
|         m_coordinate_list.swap( coordinate_list ); | ||||
| 
 | ||||
|         uint32_t number_of_turn_instructions = *static_cast<unsigned *>( | ||||
|             SharedMemoryFactory::Get(TURN_INSTRUCTION_LIST_SIZE)->Ptr() | ||||
|         ); | ||||
| 
 | ||||
|         TurnInstruction * turn_instruction_list_ptr = static_cast<TurnInstruction * >( | ||||
|             SharedMemoryFactory::Get(TURN_INSTRUCTION_LIST)->Ptr() | ||||
|         ); | ||||
| 
 | ||||
|         typename ShM<TurnInstruction, true>::vector turn_instruction_list( | ||||
|             turn_instruction_list_ptr, | ||||
|             number_of_turn_instructions | ||||
|         ); | ||||
| 
 | ||||
|         m_turn_instruction_list.swap(turn_instruction_list); | ||||
|     } | ||||
| public: | ||||
|     SharedDataFacade( | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user