Skip to content

Commit

Permalink
Fix issues addressed in pr
Browse files Browse the repository at this point in the history
  • Loading branch information
ol-imorozko authored and chernishev committed Jan 30, 2025
1 parent 1ef9f7e commit d522641
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 57 deletions.
8 changes: 6 additions & 2 deletions src/core/algorithms/dc/FastADC/fastadc.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "algorithms/dc/FastADC/fastadc.h"

#include <stdexcept>
#include <vector>

#include <easylogging++.h>

#include "config/names_and_descriptions.h"
Expand All @@ -11,6 +14,7 @@
#include "dc/FastADC/util/evidence_aux_structures_builder.h"
#include "dc/FastADC/util/evidence_set_builder.h"
#include "dc/FastADC/util/predicate_builder.h"
#include "model/table/column_layout_typed_relation_data.h"

namespace algos::dc {

Expand Down Expand Up @@ -41,8 +45,8 @@ void FastADC::MakeExecuteOptsAvailable() {
}

void FastADC::LoadDataInternal() {
typed_relation_ = model::ColumnLayoutTypedRelationData::CreateFrom(
*input_table_, true, true); // kMixed type will be treated as a string type
// kMixed type will be treated as a string type
typed_relation_ = model::ColumnLayoutTypedRelationData::CreateFrom(*input_table_, true, true);

if (typed_relation_->GetColumnData().empty()) {
throw std::runtime_error("Got an empty dataset: DC mining is meaningless.");
Expand Down
14 changes: 7 additions & 7 deletions src/core/algorithms/dc/FastADC/model/denial_constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ class DenialConstraint {
return DenialConstraint(predicate_set_.GetInvTS(predicate_provider));
}

PredicateSet const& GetPredicateSet() const {
PredicateSet const& GetPredicateSet() const noexcept {
return predicate_set_;
}

size_t GetPredicateCount() const {
size_t GetPredicateCount() const noexcept {
return predicate_set_.Size();
}

std::string ToString() const {
std::string const c_not = "\u00AC";
std::string const c_and = "";
std::string ToString() const noexcept {
static std::string const kCNot = "\u00AC";
static std::string const kCAnd = "";
std::ostringstream sb;
sb << c_not << "{ ";
sb << kCNot << "{ ";
std::string separator;
for (PredicatePtr predicate : predicate_set_) {
sb << separator << predicate->ToString();
separator = c_and;
separator = kCAnd;
}
sb << " }";
return sb.str();
Expand Down
82 changes: 41 additions & 41 deletions src/core/algorithms/dc/FastADC/model/operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,47 +62,47 @@ class Operator {
static constexpr OperatorType kLeTransitives[] = {OperatorType::kLess, OperatorType::kLessEqual,
OperatorType::kEqual};

static constexpr auto kInverseMap =
::frozen::make_unordered_map<OperatorType, OperatorType, 6>({
{OperatorType::kEqual, OperatorType::kUnequal},
{OperatorType::kUnequal, OperatorType::kEqual},
{OperatorType::kGreater, OperatorType::kLessEqual},
{OperatorType::kLess, OperatorType::kGreaterEqual},
{OperatorType::kGreaterEqual, OperatorType::kLess},
{OperatorType::kLessEqual, OperatorType::kGreater},
});

static constexpr auto kSymmetricMap =
::frozen::make_unordered_map<OperatorType, OperatorType, 6>({
{OperatorType::kEqual, OperatorType::kEqual},
{OperatorType::kUnequal, OperatorType::kUnequal},
{OperatorType::kGreater, OperatorType::kLess},
{OperatorType::kLess, OperatorType::kGreater},
{OperatorType::kGreaterEqual, OperatorType::kLessEqual},
{OperatorType::kLessEqual, OperatorType::kGreaterEqual},
});

static constexpr auto kImplicationsMap =
::frozen::make_unordered_map<OperatorType, OperatorSpan, 6>({
{OperatorType::kEqual, OperatorSpan(kEqImplications, 3)},
{OperatorType::kUnequal, OperatorSpan(kUneqImplications, 1)},
{OperatorType::kGreater, OperatorSpan(kGtImplications, 3)},
{OperatorType::kLess, OperatorSpan(kLtImplications, 3)},
{OperatorType::kGreaterEqual, OperatorSpan(kGeImplications, 1)},
{OperatorType::kLessEqual, OperatorSpan(kLeImplications, 1)},
});

static constexpr auto kTransitivesMap =
::frozen::make_unordered_map<OperatorType, OperatorSpan, 6>({
{OperatorType::kEqual, OperatorSpan(kEqTransitives, 1)},
{OperatorType::kUnequal, OperatorSpan(kUneqTransitives, 1)},
{OperatorType::kGreater, OperatorSpan(kGtTransitives, 3)},
{OperatorType::kLess, OperatorSpan(kLtTransitives, 3)},
{OperatorType::kGreaterEqual, OperatorSpan(kGeTransitives, 3)},
{OperatorType::kLessEqual, OperatorSpan(kLeTransitives, 3)},
});

static constexpr frozen::unordered_map<OperatorType, frozen::string, 6> kOperatorTypeToString{
using OperatorMapType = frozen::unordered_map<OperatorType, OperatorType, 6>;
using OperatorMapSpan = frozen::unordered_map<OperatorType, OperatorSpan, 6>;
using OperatorMapString = frozen::unordered_map<OperatorType, frozen::string, 6>;

static constexpr OperatorMapType kInverseMap{
{OperatorType::kEqual, OperatorType::kUnequal},
{OperatorType::kUnequal, OperatorType::kEqual},
{OperatorType::kGreater, OperatorType::kLessEqual},
{OperatorType::kLess, OperatorType::kGreaterEqual},
{OperatorType::kGreaterEqual, OperatorType::kLess},
{OperatorType::kLessEqual, OperatorType::kGreater},
};

static constexpr OperatorMapType kSymmetricMap{
{OperatorType::kEqual, OperatorType::kEqual},
{OperatorType::kUnequal, OperatorType::kUnequal},
{OperatorType::kGreater, OperatorType::kLess},
{OperatorType::kLess, OperatorType::kGreater},
{OperatorType::kGreaterEqual, OperatorType::kLessEqual},
{OperatorType::kLessEqual, OperatorType::kGreaterEqual},
};

static constexpr OperatorMapSpan kImplicationsMap{
{OperatorType::kEqual, OperatorSpan(kEqImplications, 3)},
{OperatorType::kUnequal, OperatorSpan(kUneqImplications, 1)},
{OperatorType::kGreater, OperatorSpan(kGtImplications, 3)},
{OperatorType::kLess, OperatorSpan(kLtImplications, 3)},
{OperatorType::kGreaterEqual, OperatorSpan(kGeImplications, 1)},
{OperatorType::kLessEqual, OperatorSpan(kLeImplications, 1)},
};

static constexpr OperatorMapSpan kTransitivesMap{
{OperatorType::kEqual, OperatorSpan(kEqTransitives, 1)},
{OperatorType::kUnequal, OperatorSpan(kUneqTransitives, 1)},
{OperatorType::kGreater, OperatorSpan(kGtTransitives, 3)},
{OperatorType::kLess, OperatorSpan(kLtTransitives, 3)},
{OperatorType::kGreaterEqual, OperatorSpan(kGeTransitives, 3)},
{OperatorType::kLessEqual, OperatorSpan(kLeTransitives, 3)},
};

static constexpr OperatorMapString kOperatorTypeToString{
{OperatorType::kEqual, "=="}, {OperatorType::kUnequal, "!="},
{OperatorType::kGreater, ">"}, {OperatorType::kLess, "<"},
{OperatorType::kGreaterEqual, ">="}, {OperatorType::kLessEqual, "<="}};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ namespace algos::fastadc {

inline boost::dynamic_bitset<>& operator&=(boost::dynamic_bitset<>& lhs,
PredicateBitset const& rhs) {
size_t rhs_size = rhs.size();
for (size_t i = 0; i < rhs_size && i < lhs.size(); ++i) {
if (!rhs.test(i)) {
lhs.reset(i);
}
for (size_t i = 0; i < std::min(rhs.size(), lhs.size()); ++i) {
lhs[i] &= rhs[i];
}
return lhs;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/algorithms/dc/model/operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <stdexcept>
#include <string>

#include "frozen/string.h"
#include "frozen/unordered_map.h"
#include <frozen/string.h>
#include <frozen/unordered_map.h>

namespace algos::dc {

Expand Down

0 comments on commit d522641

Please sign in to comment.