Skip to content

Commit

Permalink
Use column schema in FDAlgorithm::GetKeys
Browse files Browse the repository at this point in the history
Uses a more robust way of getting the number of columns. Avoids the
reliance on `input_table_` being set to the table being processed now,
indirectly inherited from the old implementation. Previously, there was
a possibility that `input_table_` would not be set to the table being
processed in `PliBasedFdAlgorithm` because of its `LoadData` overload,
but the only scenario which used it was using `TypoMiner`, and that
class would always set the option correctly.
  • Loading branch information
BUYT-1 committed Jun 20, 2023
1 parent 58e841a commit 1c0b878
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/algorithms/fd_algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ std::vector<Column const*> FDAlgorithm::GetKeys() const {
}
}

size_t const number_of_columns = input_table_->GetNumberOfColumns();
if (fds_count_per_col.empty()) return keys;
assert(fds_count_per_col.begin()->first->GetSchema() != nullptr);
size_t const number_of_columns = fds_count_per_col.begin()->first->GetSchema()->GetNumColumns();
assert(std::all_of(
++fds_count_per_col.begin(), fds_count_per_col.end(),
[first_schema = fds_count_per_col.begin()->first->GetSchema()](auto const& kv_pair) {
return kv_pair.first->GetSchema() == first_schema;
}));
for (auto const& [col, num]: fds_count_per_col) {
if (num + 1 + cols_of_equal_values == number_of_columns) {
keys.push_back(col);
Expand Down

0 comments on commit 1c0b878

Please sign in to comment.