Skip to content

Commit

Permalink
Improve report reader node filter performances. (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien4193 authored Jun 3, 2024
1 parent 7580c24 commit 58359ea
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/report_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include <bbp/sonata/report_reader.h>
#include <fmt/format.h>

#include <algorithm> // std::copy, std::find, std::lower_bound, std::upper_bound
#include <iterator> // std::advance, std::next
#include <algorithm> // std::copy, std::find, std::lower_bound, std::upper_bound
#include <iterator> // std::advance, std::next
#include <unordered_set> // std::unordered_set

constexpr double EPSILON = 1e-6;

Expand All @@ -27,9 +28,10 @@ using bbp::sonata::Spikes;

void filterNodeIDUnsorted(Spikes& spikes, const Selection& node_ids) {
const auto values = node_ids.flatten();
const auto selected_values = std::unordered_set<Selection::Value>(values.begin(), values.end());
const auto new_end =
std::remove_if(spikes.begin(), spikes.end(), [&values](const Spike& spike) {
return std::find(values.cbegin(), values.cend(), spike.first) == values.cend();
std::remove_if(spikes.begin(), spikes.end(), [&selected_values](const Spike& spike) {
return selected_values.find(spike.first) == selected_values.end();
});
spikes.erase(new_end, spikes.end());
}
Expand Down

0 comments on commit 58359ea

Please sign in to comment.