22
33#include " utils.h"
44
5- #include " parallel_hashmap/phmap.h"
6-
75#ifdef _WIN32
86#include < process.h>
97#endif
@@ -142,21 +140,21 @@ hetero_sample(const vector<node_t> &node_types,
142140 const int64_t num_hops) {
143141
144142 // Create a mapping to convert single string relations to edge type triplets:
145- unordered_map <rel_t , edge_t > to_edge_type;
143+ phmap::flat_hash_map <rel_t , edge_t > to_edge_type;
146144 for (const auto &k : edge_types)
147145 to_edge_type[get<0 >(k) + " __" + get<1 >(k) + " __" + get<2 >(k)] = k;
148146
149147 // Initialize some data structures for the sampling process:
150- unordered_map <node_t , vector<int64_t >> samples_dict;
151- unordered_map <node_t , unordered_map <int64_t , int64_t >> to_local_node_dict;
152- unordered_map <node_t , vector<int64_t >> root_time_dict;
148+ phmap::flat_hash_map <node_t , vector<int64_t >> samples_dict;
149+ phmap::flat_hash_map <node_t , phmap::flat_hash_map <int64_t , int64_t >> to_local_node_dict;
150+ phmap::flat_hash_map <node_t , vector<int64_t >> root_time_dict;
153151 for (const auto &node_type : node_types) {
154152 samples_dict[node_type];
155153 to_local_node_dict[node_type];
156154 root_time_dict[node_type];
157155 }
158156
159- unordered_map <rel_t , vector<int64_t >> rows_dict, cols_dict, edges_dict;
157+ phmap::flat_hash_map <rel_t , vector<int64_t >> rows_dict, cols_dict, edges_dict;
160158 for (const auto &kv : colptr_dict) {
161159 const auto &rel_type = kv.key ();
162160 rows_dict[rel_type];
@@ -188,7 +186,7 @@ hetero_sample(const vector<node_t> &node_types,
188186 }
189187 }
190188
191- unordered_map <node_t , pair<int64_t , int64_t >> slice_dict;
189+ phmap::flat_hash_map <node_t , pair<int64_t , int64_t >> slice_dict;
192190 for (const auto &kv : samples_dict)
193191 slice_dict[kv.first ] = {0 , kv.second .size ()};
194192
@@ -339,7 +337,7 @@ hetero_sample(const vector<node_t> &node_types,
339337 }
340338
341339 if (!directed) { // Construct the subgraph among the sampled nodes:
342- unordered_map <int64_t , int64_t >::iterator iter;
340+ phmap::flat_hash_map <int64_t , int64_t >::iterator iter;
343341 for (const auto &kv : colptr_dict) {
344342 const auto &rel_type = kv.key ();
345343 const auto &edge_type = to_edge_type[rel_type];
@@ -455,4 +453,4 @@ hetero_temporal_neighbor_sample_cpu(
455453 node_types, edge_types, colptr_dict, row_dict, input_node_dict,
456454 num_neighbors_dict, node_time_dict, num_hops);
457455 }
458- }
456+ }
0 commit comments