Skip to content

Commit

Permalink
Add method for calculating PLI of several columns
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelS239 committed Aug 2, 2023
1 parent 654aa54 commit 85a0f01
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/algorithms/fd_verifier/fd_verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,8 @@ unsigned long long FDVerifier::ExecuteInternal() {
}

void FDVerifier::VerifyFD() const {
std::shared_ptr<util::PLI const> lhs_pli =
relation_->GetColumnData(lhs_indices_[0]).GetPliOwnership();

for (size_t i = 1; i < lhs_indices_.size(); ++i) {
lhs_pli = lhs_pli->Intersect(
relation_->GetColumnData(lhs_indices_[i]).GetPositionListIndex());
}

std::shared_ptr<util::PLI const> rhs_pli =
relation_->GetColumnData(rhs_indices_[0]).GetPliOwnership();

for (size_t i = 1; i < rhs_indices_.size(); ++i) {
rhs_pli = rhs_pli->Intersect(
relation_->GetColumnData(rhs_indices_[i]).GetPositionListIndex());
}
std::shared_ptr<util::PLI const> lhs_pli = CalculatePLI(lhs_indices_);
std::shared_ptr<util::PLI const> rhs_pli = CalculatePLI(rhs_indices_);

std::unique_ptr<util::PLI const> intersection_pli = lhs_pli->Intersect(rhs_pli.get());
if (lhs_pli->GetNumCluster() == intersection_pli->GetNumCluster()) {
Expand All @@ -86,6 +73,16 @@ void FDVerifier::VerifyFD() const {
stats_calculator_->CalculateStatistics(lhs_pli.get(), rhs_pli.get());
}

std::shared_ptr<util::PLI const> FDVerifier::CalculatePLI(
util::config::IndicesType const& indices) const {
std::shared_ptr<util::PLI const> pli = relation_->GetColumnData(indices[0]).GetPliOwnership();

for (size_t i = 1; i < indices.size(); ++i) {
pli = pli->Intersect(relation_->GetColumnData(indices[i]).GetPositionListIndex());
}
return pli;
}

void FDVerifier::SortHighlightsByProportionAscending() const {
assert(stats_calculator_);
stats_calculator_->SortHighlights(StatsCalculator::CompareHighlightsByProportionAscending());
Expand Down
1 change: 1 addition & 0 deletions src/algorithms/fd_verifier/fd_verifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class FDVerifier : public Algorithm {
std::unique_ptr<StatsCalculator> stats_calculator_;

void VerifyFD() const;
std::shared_ptr<util::PLI const> CalculatePLI(util::config::IndicesType const& indices) const;
void RegisterOptions();
void ResetState() final {
if (stats_calculator_) {
Expand Down

0 comments on commit 85a0f01

Please sign in to comment.