Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

Expand All @@ -39,6 +38,7 @@
#include "perfetto/trace_processor/basic_types.h"
#include "src/trace_processor/containers/string_pool.h"
#include "src/trace_processor/core/dataframe/specs.h"
#include "src/trace_processor/core/dataframe/typed_cursor.h"
#include "src/trace_processor/perfetto_sql/intrinsics/table_functions/static_table_function.h"
#include "src/trace_processor/perfetto_sql/intrinsics/table_functions/tables_py.h"
#include "src/trace_processor/storage/trace_storage.h"
Expand Down Expand Up @@ -78,11 +78,12 @@ bool ExperimentalSliceLayout::Cursor::Run(
}

const char* filter_string = arguments[0].string_value;
std::unordered_set<TrackId> selected_tracks;
using FilterValue = dataframe::TypedCursor::FilterValue;
std::vector<FilterValue> selected_track_ids;
for (base::StringSplitter sp(filter_string, ','); sp.Next();) {
std::optional<uint32_t> maybe = base::CStringToUInt32(sp.cur_token());
if (maybe) {
selected_tracks.insert(TrackId{maybe.value()});
selected_track_ids.emplace_back(static_cast<int64_t>(maybe.value()));
}
}

Expand All @@ -96,13 +97,18 @@ bool ExperimentalSliceLayout::Cursor::Run(
return OnSuccess(&table_.dataframe());
}

// Find all the slices for the tracks we want to filter and create a vector of
// row numbers out of them.
// Find all the slices for the tracks we want to filter using an In filter
// on track_id to avoid a full table scan.
auto track_cursor = slice_table_->CreateCursor(
{dataframe::FilterSpec{tables::SliceTable::ColumnIndex::track_id, 0,
dataframe::In{}, std::nullopt}});
track_cursor.SetFilterValueListUnchecked(
0, selected_track_ids.data(),
static_cast<uint32_t>(selected_track_ids.size()));

std::vector<tables::SliceTable::RowNumber> rows;
for (auto it = slice_table_->IterateRows(); it; ++it) {
if (selected_tracks.count(it.track_id())) {
rows.emplace_back(it.row_number());
}
for (track_cursor.Execute(); !track_cursor.Eof(); track_cursor.Next()) {
rows.emplace_back(track_cursor.ToRowNumber());
}

// Compute the table and add it to the cache for future use.
Expand Down
Loading