2
2
3
3
#include " utils.h"
4
4
5
- #include " parallel_hashmap/phmap.h"
6
-
7
5
#ifdef _WIN32
8
6
#include < process.h>
9
7
#endif
@@ -142,21 +140,21 @@ hetero_sample(const vector<node_t> &node_types,
142
140
const int64_t num_hops) {
143
141
144
142
// 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;
146
144
for (const auto &k : edge_types)
147
145
to_edge_type[get<0 >(k) + " __" + get<1 >(k) + " __" + get<2 >(k)] = k;
148
146
149
147
// 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;
153
151
for (const auto &node_type : node_types) {
154
152
samples_dict[node_type];
155
153
to_local_node_dict[node_type];
156
154
root_time_dict[node_type];
157
155
}
158
156
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;
160
158
for (const auto &kv : colptr_dict) {
161
159
const auto &rel_type = kv.key ();
162
160
rows_dict[rel_type];
@@ -188,7 +186,7 @@ hetero_sample(const vector<node_t> &node_types,
188
186
}
189
187
}
190
188
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;
192
190
for (const auto &kv : samples_dict)
193
191
slice_dict[kv.first ] = {0 , kv.second .size ()};
194
192
@@ -339,7 +337,7 @@ hetero_sample(const vector<node_t> &node_types,
339
337
}
340
338
341
339
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;
343
341
for (const auto &kv : colptr_dict) {
344
342
const auto &rel_type = kv.key ();
345
343
const auto &edge_type = to_edge_type[rel_type];
@@ -455,4 +453,4 @@ hetero_temporal_neighbor_sample_cpu(
455
453
node_types, edge_types, colptr_dict, row_dict, input_node_dict,
456
454
num_neighbors_dict, node_time_dict, num_hops);
457
455
}
458
- }
456
+ }
0 commit comments