| 419 | |
| 420 | template <unsigned sum_items_num, template <typename, typename Enable = void> class OBJECT_BUFFER> |
| 421 | void load_behaviour_graph_cache( |
| 422 | OBJECT_BUFFER<plato::vertex_unit_t<behaviour_state_content_t<sum_items_num>>>& behaviour_cache, |
| 423 | plato::graph_info_t& behaviour_graph_info, |
| 424 | OBJECT_BUFFER<degree_unit>& behaviour_degree_cache, plato::bitmap_t<>& behaviour_bitmap) { |
| 425 | |
| 426 | auto& cluster_info = plato::cluster_info_t::get_instance(); |
| 427 | plato::stop_watch_t watch; |
| 428 | watch.mark("t0"); |
| 429 | watch.mark("t1"); |
| 430 | |
| 431 | constexpr size_t mem_size = sizeof(plato::vid_t) * (size_t(std::numeric_limits<plato::vid_t>::max()) + 1); |
| 432 | std::unique_ptr<plato::vid_t, plato::mmap_deleter> out_degree( |
| 433 | (plato::vid_t*)mmap(nullptr, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0), |
| 434 | plato::mmap_deleter{mem_size}); |
| 435 | CHECK(MAP_FAILED != out_degree.get()) |
| 436 | << boost::format("WARNING: mmap failed, err code: %d, err msg: %s") % errno % strerror(errno); |
| 437 | |
| 438 | plato::vid_t max_vid = 0; |
| 439 | size_t edges = 0; |
| 440 | { |
| 441 | plato::thread_local_counter max_vid_counter; |
| 442 | std::mutex mutex; |
| 443 | std::vector<std::string> files = plato::get_files(FLAGS_input_behaviour_edges); |
| 444 | |
| 445 | plato::thread_local_buffer input_buffer; |
| 446 | |
| 447 | auto __send = [&] (plato::bsp_send_callback_t<plato::vertex_unit_t<behaviour_state_content_t<sum_items_num>>> send) { |
| 448 | while (true) { |
| 449 | std::string filename; |
| 450 | { |
| 451 | std::lock_guard<std::mutex> lock(mutex); |
| 452 | if (files.empty()) break; |
| 453 | filename = std::move(files.back()); |
| 454 | files.pop_back(); |
| 455 | } |
| 456 | |
| 457 | plato::with_file(filename, [&] (boost::iostreams::filtering_istream& is) { |
| 458 | plato::vertex_csv_parser<boost::iostreams::filtering_istream, behaviour_state_content_t<sum_items_num>>( |
| 459 | is, |
| 460 | [&] (plato::vertex_unit_t<behaviour_state_content_t<sum_items_num>>* input, size_t size) { |
| 461 | __sync_fetch_and_add(&edges, size); |
| 462 | for (size_t i = 0; i < size; ++i) { |
| 463 | plato::vertex_unit_t<behaviour_state_content_t<sum_items_num>>& v = input[i]; |
| 464 | send(get_behaviour_partition_id(v.vdata_.behaviour_id_), v); |
| 465 | } |
| 466 | return true; |
| 467 | }, |
| 468 | [] (behaviour_state_content_t<sum_items_num>* output, char* s_input) { |
| 469 | char* pSave = nullptr; |
| 470 | char* pLog = s_input; |
| 471 | char* pToken = strtok_r(pLog, ", \t", &pSave); |
| 472 | if (nullptr == pToken) { |
| 473 | LOG(WARNING) << boost::format("can not extract behaviour id from (%s)") % pLog; |
| 474 | return false; |
| 475 | } |
| 476 | output->behaviour_id_ = strtoul(pToken, nullptr, 10); |
| 477 | |
| 478 | for (unsigned i = 0; i < sum_items_num; ++i) { |
nothing calls this directly
no test coverage detected