diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c29951147..c8ccfd9667 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,10 +49,10 @@ include_directories( "src/algorithms/association_rules" "src/algorithms/depminer" "src/algorithms/statistics" - "src/algorithms/options" "src/model" "src/model/types" "src/util" + "src/util/config" "src/parser" "src/parser/json" "src/core" diff --git a/python_bindings/py_algorithm.cpp b/python_bindings/py_algorithm.cpp index 8451320b5b..1518c984d5 100644 --- a/python_bindings/py_algorithm.cpp +++ b/python_bindings/py_algorithm.cpp @@ -18,14 +18,12 @@ namespace python_bindings { namespace py = pybind11; void PyAlgorithmBase::Configure(py::kwargs const& kwargs) { - auto params = kwargs.cast>(); - std::unordered_map any_map{}; - for (auto const& [opt_name, obj] : params) { - std::type_index type_index = algorithm_->GetTypeIndex(opt_name); - if (type_index == void_index) continue; - any_map[opt_name] = PyToAny(type_index, obj); - } - algos::ConfigureFromMap(*algorithm_, any_map); + algos::ConfigureFromFunction(*algorithm_, [this, &kwargs](std::string_view option_name) { + std::type_index type_index = algorithm_->GetTypeIndex(option_name); + assert(type_index != void_index); + return kwargs.contains(option_name) ? PyToAny(type_index, kwargs[py::str{option_name}]) + : boost::any{}; + }); } void PyAlgorithmBase::SetOption(std::string const& option_name, py::object const& option_value) { diff --git a/python_bindings/py_fd.cpp b/python_bindings/py_fd.cpp index a212db6ef7..4a37c519e7 100644 --- a/python_bindings/py_fd.cpp +++ b/python_bindings/py_fd.cpp @@ -14,7 +14,7 @@ PyFD::PyFD(RawFD const& fd) : rhs_index_(fd.rhs_) { std::string PyFD::ToString() const { std::stringstream stream; stream << "( "; - for (algos::config::IndexType index : lhs_indices_) { + for (util::config::IndexType index : lhs_indices_) { stream << index << " "; } stream << ") -> "; diff --git a/python_bindings/py_fd.h b/python_bindings/py_fd.h index 1a3e403578..744030021b 100644 --- a/python_bindings/py_fd.h +++ b/python_bindings/py_fd.h @@ -3,26 +3,26 @@ #include #include -#include "algorithms/options/indices/type.h" #include "model/raw_fd.h" +#include "util/config/indices/type.h" namespace python_bindings { class PyFD { private: - algos::config::IndicesType lhs_indices_{}; - algos::config::IndexType rhs_index_; + util::config::IndicesType lhs_indices_{}; + util::config::IndexType rhs_index_; public: explicit PyFD(RawFD const& fd); [[nodiscard]] std::string ToString() const; - [[nodiscard]] algos::config::IndexType GetRhs() const { + [[nodiscard]] util::config::IndexType GetRhs() const { return rhs_index_; } - [[nodiscard]] algos::config::IndicesType GetLhs() const { + [[nodiscard]] util::config::IndicesType GetLhs() const { return lhs_indices_; } }; diff --git a/src/algorithms/algo_factory.h b/src/algorithms/algo_factory.h index 5c0e51726c..eee6ef9521 100644 --- a/src/algorithms/algo_factory.h +++ b/src/algorithms/algo_factory.h @@ -10,8 +10,8 @@ #include "algorithms/algorithms.h" #include "algorithms/create_algorithm.h" #include "algorithms/legacy_algorithms.h" -#include "algorithms/options/names.h" #include "algorithms/typo_miner.h" +#include "util/config/names.h" namespace algos { @@ -20,7 +20,7 @@ using StdParamsMap = std::unordered_map; namespace details { template -boost::any ExtractAnyFromMap(OptionMap&& options, std::string_view option_name) { +boost::any ExtractAnyFromMap(OptionMap& options, std::string_view option_name) { using std::is_same_v, std::decay, boost::program_options::variables_map; const std::string string_opt{option_name}; auto it = options.find(string_opt); @@ -41,7 +41,7 @@ T ExtractOptionValue(OptionMap&& options, std::string const& option_name) { template ACAlgorithm::Config CreateAcAlgorithmConfigFromMap(ParamsMap params) { - namespace onam = config::names; + namespace onam = util::config::names; ACAlgorithm::Config c; c.data = ExtractOptionValue(params, onam::kData); @@ -82,27 +82,32 @@ std::unique_ptr CreateAcAlgorithmInstance(ParamsMap&& params) { } // namespace details -template -void ConfigureFromMap(Algorithm& algorithm, OptionMap&& options) { +template +void ConfigureFromFunction(Algorithm& algorithm, FuncType get_opt_value_by_name) { std::unordered_set needed; while (!(needed = algorithm.GetNeededOptions()).empty()) { for (std::string_view option_name : needed) { - if (options.find(std::string{option_name}) == options.end()) { - algorithm.SetOption(option_name); - } else { - algorithm.SetOption(option_name, details::ExtractAnyFromMap(options, option_name)); - } + algorithm.SetOption(option_name, get_opt_value_by_name(option_name)); } } } +template +void ConfigureFromMap(Algorithm& algorithm, OptionMap&& options) { + ConfigureFromFunction(algorithm, [&options](std::string_view option_name) -> boost::any { + auto it = options.find(std::string{option_name}); + return it == options.end() ? boost::any{} + : details::ExtractAnyFromMap(options, option_name); + }); +} + template void LoadAlgorithm(Algorithm& algorithm, OptionMap&& options) { ConfigureFromMap(algorithm, options); auto parser = CSVParser{ - details::ExtractOptionValue(options, config::names::kData), - details::ExtractOptionValue(options, config::names::kSeparator), - details::ExtractOptionValue(options, config::names::kHasHeader)}; + details::ExtractOptionValue(options, util::config::names::kData), + details::ExtractOptionValue(options, util::config::names::kSeparator), + details::ExtractOptionValue(options, util::config::names::kHasHeader)}; algorithm.LoadData(parser); ConfigureFromMap(algorithm, options); } @@ -123,8 +128,8 @@ std::unique_ptr CreateAlgorithm(AlgorithmType algorithm_enum, OptionM template std::unique_ptr CreateTypoMiner(OptionMap&& options) { - using config::names::kPreciseAlgorithm, config::names::kApproximateAlgorithm; using details::ExtractOptionValue; + using util::config::names::kPreciseAlgorithm, util::config::names::kApproximateAlgorithm; AlgorithmType precise_algo = ExtractOptionValue(options, kPreciseAlgorithm); AlgorithmType approx_algo = ExtractOptionValue(options, kApproximateAlgorithm); std::unique_ptr typo_miner = std::make_unique(precise_algo, approx_algo); diff --git a/src/algorithms/algorithm.cpp b/src/algorithms/algorithm.cpp index 2165d2989a..683d6c6d25 100644 --- a/src/algorithms/algorithm.cpp +++ b/src/algorithms/algorithm.cpp @@ -4,15 +4,11 @@ namespace algos { -bool Algorithm::HandleUnknownOption([[maybe_unused]] std::string_view option_name, - [[maybe_unused]] boost::any const& value) { +bool Algorithm::SetExternalOption([[maybe_unused]] std::string_view option_name, + [[maybe_unused]] boost::any const& value) { return false; } -bool Algorithm::DataLoaded() const { - return data_loaded_; -} - void Algorithm::AddSpecificNeededOptions( [[maybe_unused]] std::unordered_set& previous_options) const {} @@ -88,16 +84,19 @@ unsigned long long Algorithm::Execute() { } void Algorithm::SetOption(std::string_view option_name, boost::any const& value) { + // Currently, it is assumed that if both the pipeline and its algorithms + // have options with the same name, they should all be set to the same + // value. + bool ext_opt_set = SetExternalOption(option_name, value); auto it = possible_options_.find(option_name); if (it == possible_options_.end()) { - if (!HandleUnknownOption(option_name, value)) { - throw std::invalid_argument("Unknown option \"" + std::string{option_name} + '"'); - } - return; + if (ext_opt_set) return; + throw std::invalid_argument("Unknown option \"" + std::string{option_name} + '"'); } std::string_view name = it->first; - config::IOption& option = *it->second; + util::config::IOption& option = *it->second; if (available_options_.find(name) == available_options_.end()) { + if (ext_opt_set) return; throw std::invalid_argument("Invalid option \"" + std::string{name} + '"'); } diff --git a/src/algorithms/algorithm.h b/src/algorithms/algorithm.h index 2fc014b8c0..4e3b18b7a5 100644 --- a/src/algorithms/algorithm.h +++ b/src/algorithms/algorithm.h @@ -10,10 +10,10 @@ #include -#include "algorithms/options/ioption.h" -#include "algorithms/options/option.h" #include "model/idataset_stream.h" #include "parser/csv_parser.h" +#include "util/config/ioption.h" +#include "util/config/option.h" #include "util/progress.h" namespace algos { @@ -22,11 +22,11 @@ class Algorithm { private: util::Progress progress_; // All options the algorithm may use - std::unordered_map> possible_options_{}; + std::unordered_map> possible_options_; // All options that can be set at the moment std::unordered_set available_options_; // Maps a parameter that added other parameters to their names. - std::unordered_map> opt_parents_{}; + std::unordered_map> opt_parents_; bool data_loaded_ = false; @@ -53,15 +53,15 @@ class Algorithm { void MakeOptionsAvailable(std::vector const& option_names); template - void RegisterOption(config::Option option) { + void RegisterOption(util::config::Option option) { auto name = option.GetName(); assert(possible_options_.find(name) == possible_options_.end()); - possible_options_[name] = std::make_unique>(std::move(option)); + possible_options_[name] = std::make_unique>(std::move(option)); } // Overload this if you want to work with options outside of // possible_options_ map. Useful for pipelines. - virtual bool HandleUnknownOption(std::string_view option_name, boost::any const& value); + virtual bool SetExternalOption(std::string_view option_name, boost::any const& value); virtual void AddSpecificNeededOptions( std::unordered_set& previous_options) const; void ExecutePrepare(); @@ -84,7 +84,6 @@ class Algorithm { explicit Algorithm(std::vector phase_names); void LoadData(model::IDatasetStream& data_stream); - bool DataLoaded() const; unsigned long long Execute(); diff --git a/src/algorithms/ar_algorithm.cpp b/src/algorithms/ar_algorithm.cpp index 0423ccef03..2ef6fd3323 100644 --- a/src/algorithms/ar_algorithm.cpp +++ b/src/algorithms/ar_algorithm.cpp @@ -5,21 +5,20 @@ #include -#include "algorithms/options/names_and_descriptions.h" +#include "util/config/names_and_descriptions.h" +#include "util/config/option_using.h" namespace algos { ARAlgorithm::ARAlgorithm(std::vector phase_names) : Algorithm(std::move(phase_names)) { - using namespace config::names; + using namespace util::config::names; RegisterOptions(); MakeOptionsAvailable({kInputFormat}); } void ARAlgorithm::RegisterOptions() { - using namespace config::names; - using namespace config::descriptions; - using config::Option; + DESBORDANTE_OPTION_USING; auto sing_eq = [](InputFormat input_format) { return input_format == +InputFormat::singular; }; auto tab_eq = [](InputFormat input_format) { return input_format == +InputFormat::tabular; }; @@ -38,7 +37,7 @@ void ARAlgorithm::ResetState() { } void ARAlgorithm::MakeExecuteOptsAvailable() { - using namespace config::names; + using namespace util::config::names; MakeOptionsAvailable({kMinimumSupport, kMinimumConfidence}); } diff --git a/src/algorithms/dfd/dfd.cpp b/src/algorithms/dfd/dfd.cpp index 9ed3f244a5..29c20729b0 100644 --- a/src/algorithms/dfd/dfd.cpp +++ b/src/algorithms/dfd/dfd.cpp @@ -4,9 +4,9 @@ #include #include "algorithms/dfd/lattice_traversal/lattice_traversal.h" -#include "algorithms/options/thread_number/option.h" #include "model/column_layout_relation_data.h" #include "model/relational_schema.h" +#include "util/config/thread_number/option.h" #include "util/position_list_index.h" namespace algos { @@ -16,11 +16,11 @@ DFD::DFD() : PliBasedFDAlgorithm({kDefaultPhaseName}) { } void DFD::RegisterOptions() { - RegisterOption(config::ThreadNumberOpt(&number_of_threads_)); + RegisterOption(util::config::ThreadNumberOpt(&number_of_threads_)); } void DFD::MakeExecuteOptsAvailable() { - MakeOptionsAvailable({config::ThreadNumberOpt.GetName()}); + MakeOptionsAvailable({util::config::ThreadNumberOpt.GetName()}); } void DFD::ResetStateFd() { diff --git a/src/algorithms/dfd/dfd.h b/src/algorithms/dfd/dfd.h index 05c5de72a0..c80b28a08b 100644 --- a/src/algorithms/dfd/dfd.h +++ b/src/algorithms/dfd/dfd.h @@ -4,9 +4,9 @@ #include #include "algorithms/dfd/partition_storage/partition_storage.h" -#include "algorithms/options/thread_number/type.h" #include "algorithms/pli_based_fd_algorithm.h" #include "model/vertical.h" +#include "util/config/thread_number/type.h" namespace algos { @@ -14,7 +14,7 @@ class DFD : public PliBasedFDAlgorithm { private: std::vector unique_columns_; - config::ThreadNumType number_of_threads_; + util::config::ThreadNumType number_of_threads_; void MakeExecuteOptsAvailable() final; void RegisterOptions(); diff --git a/src/algorithms/fastfds.cpp b/src/algorithms/fastfds.cpp index e155043319..410fbc5eb5 100644 --- a/src/algorithms/fastfds.cpp +++ b/src/algorithms/fastfds.cpp @@ -10,9 +10,9 @@ #include #include -#include "algorithms/options/max_lhs/option.h" -#include "algorithms/options/thread_number/option.h" #include "util/agree_set_factory.h" +#include "util/config/max_lhs/option.h" +#include "util/config/thread_number/option.h" #include "util/parallel_for.h" namespace algos { @@ -24,12 +24,13 @@ FastFDs::FastFDs() : PliBasedFDAlgorithm({"Agree sets generation", "Finding mini } void FastFDs::RegisterOptions() { - RegisterOption(config::MaxLhsOpt(&max_lhs_)); - RegisterOption(config::ThreadNumberOpt(&threads_num_)); + RegisterOption(util::config::MaxLhsOpt(&max_lhs_)); + RegisterOption(util::config::ThreadNumberOpt(&threads_num_)); } void FastFDs::MakeExecuteOptsAvailable() { - MakeOptionsAvailable({config::MaxLhsOpt.GetName(), config::ThreadNumberOpt.GetName()}); + MakeOptionsAvailable( + {util::config::MaxLhsOpt.GetName(), util::config::ThreadNumberOpt.GetName()}); } void FastFDs::ResetStateFd() { diff --git a/src/algorithms/fastfds.h b/src/algorithms/fastfds.h index e59628b1c6..f8bdd9eed6 100644 --- a/src/algorithms/fastfds.h +++ b/src/algorithms/fastfds.h @@ -5,11 +5,11 @@ #include -#include "algorithms/options/max_lhs/type.h" -#include "algorithms/options/thread_number/type.h" #include "algorithms/pli_based_fd_algorithm.h" #include "model/column_layout_relation_data.h" #include "model/vertical.h" +#include "util/config/max_lhs/type.h" +#include "util/config/thread_number/type.h" namespace algos { @@ -70,8 +70,8 @@ class FastFDs : public PliBasedFDAlgorithm { RelationalSchema const* schema_; std::vector diff_sets_; - config::ThreadNumType threads_num_; - config::MaxLhsType max_lhs_; + util::config::ThreadNumType threads_num_; + util::config::MaxLhsType max_lhs_; double percent_per_col_; }; diff --git a/src/algorithms/fd_algorithm.cpp b/src/algorithms/fd_algorithm.cpp index 0c59e998a5..f117476f1d 100644 --- a/src/algorithms/fd_algorithm.cpp +++ b/src/algorithms/fd_algorithm.cpp @@ -2,18 +2,18 @@ #include -#include "algorithms/options/equal_nulls/option.h" +#include "util/config/equal_nulls/option.h" namespace algos { FDAlgorithm::FDAlgorithm(std::vector phase_names) : Algorithm(std::move(phase_names)) { RegisterOptions(); - MakeOptionsAvailable({config::EqualNullsOpt.GetName()}); + MakeOptionsAvailable({util::config::EqualNullsOpt.GetName()}); } void FDAlgorithm::RegisterOptions() { - RegisterOption(config::EqualNullsOpt(&is_null_equal_null_)); + RegisterOption(util::config::EqualNullsOpt(&is_null_equal_null_)); } void FDAlgorithm::LoadDataInternal(model::IDatasetStream& data_stream) { diff --git a/src/algorithms/fd_algorithm.h b/src/algorithms/fd_algorithm.h index 64571c9f50..4586ba2f44 100644 --- a/src/algorithms/fd_algorithm.h +++ b/src/algorithms/fd_algorithm.h @@ -7,9 +7,9 @@ #include #include "algorithms/algorithm.h" -#include "algorithms/options/equal_nulls/type.h" #include "model/column_layout_typed_relation_data.h" #include "model/fd.h" +#include "util/config/equal_nulls/type.h" #include "util/primitive_collection.h" namespace util { @@ -37,7 +37,7 @@ class FDAlgorithm : public algos::Algorithm { * accessing this field directly, use RegisterFd methods instead */ util::PrimitiveCollection fd_collection_; - config::EqNullsType is_null_equal_null_; + util::config::EqNullsType is_null_equal_null_; /* Registers new FD. * Should be overrided if custom behavior is needed diff --git a/src/algorithms/fd_verifier/fd_verifier.cpp b/src/algorithms/fd_verifier/fd_verifier.cpp index 4705fc8156..2e6e15745e 100644 --- a/src/algorithms/fd_verifier/fd_verifier.cpp +++ b/src/algorithms/fd_verifier/fd_verifier.cpp @@ -4,36 +4,35 @@ #include #include -#include "algorithms/options/equal_nulls/option.h" -#include "algorithms/options/indices/option.h" -#include "algorithms/options/indices/validate_index.h" -#include "algorithms/options/names_and_descriptions.h" +#include "util/config/equal_nulls/option.h" +#include "util/config/indices/option.h" +#include "util/config/indices/validate_index.h" +#include "util/config/names_and_descriptions.h" +#include "util/config/option_using.h" namespace algos::fd_verifier { FDVerifier::FDVerifier() : Algorithm({}) { RegisterOptions(); - MakeOptionsAvailable({config::EqualNullsOpt.GetName()}); + MakeOptionsAvailable({util::config::EqualNullsOpt.GetName()}); } void FDVerifier::RegisterOptions() { - using namespace config::names; - using namespace config::descriptions; - using config::Option; + DESBORDANTE_OPTION_USING; auto get_schema_cols = [this]() { return relation_->GetSchema()->GetNumColumns(); }; - auto check_rhs = [this](config::IndexType rhs_index) { - config::ValidateIndex(rhs_index, relation_->GetSchema()->GetNumColumns()); + auto check_rhs = [this](util::config::IndexType rhs_index) { + util::config::ValidateIndex(rhs_index, relation_->GetSchema()->GetNumColumns()); }; - RegisterOption(config::EqualNullsOpt(&is_null_equal_null_)); - RegisterOption(config::LhsIndicesOpt(&lhs_indices_, get_schema_cols)); + RegisterOption(util::config::EqualNullsOpt(&is_null_equal_null_)); + RegisterOption(util::config::LhsIndicesOpt(&lhs_indices_, get_schema_cols)); RegisterOption(Option{&rhs_index_, kRhsIndex, kDRhsIndex}.SetValueCheck(check_rhs)); } void FDVerifier::MakeExecuteOptsAvailable() { - using namespace config::names; - MakeOptionsAvailable({config::LhsIndicesOpt.GetName(), kRhsIndex}); + using namespace util::config::names; + MakeOptionsAvailable({util::config::LhsIndicesOpt.GetName(), kRhsIndex}); } void FDVerifier::LoadDataInternal(model::IDatasetStream& data_stream) { diff --git a/src/algorithms/fd_verifier/fd_verifier.h b/src/algorithms/fd_verifier/fd_verifier.h index 99c4049527..e78aa971a0 100644 --- a/src/algorithms/fd_verifier/fd_verifier.h +++ b/src/algorithms/fd_verifier/fd_verifier.h @@ -7,8 +7,8 @@ #include "algorithms/algorithm.h" #include "algorithms/fd_verifier/stats_calculator.h" -#include "algorithms/options/equal_nulls/type.h" -#include "algorithms/options/indices/type.h" +#include "util/config/equal_nulls/type.h" +#include "util/config/indices/type.h" namespace algos::fd_verifier { @@ -16,9 +16,9 @@ namespace algos::fd_verifier { * case it doesn't hold */ class FDVerifier : public Algorithm { private: - config::IndicesType lhs_indices_; - config::IndexType rhs_index_; - config::EqNullsType is_null_equal_null_; + util::config::IndicesType lhs_indices_; + util::config::IndexType rhs_index_; + util::config::EqNullsType is_null_equal_null_; std::shared_ptr relation_; std::shared_ptr typed_relation_; diff --git a/src/algorithms/fd_verifier/stats_calculator.h b/src/algorithms/fd_verifier/stats_calculator.h index d4b01968c5..16bd7da0da 100644 --- a/src/algorithms/fd_verifier/stats_calculator.h +++ b/src/algorithms/fd_verifier/stats_calculator.h @@ -6,9 +6,9 @@ #include #include "algorithms/fd_verifier/highlight.h" -#include "algorithms/options/indices/type.h" #include "model/column_layout_relation_data.h" #include "model/column_layout_typed_relation_data.h" +#include "util/config/indices/type.h" namespace algos::fd_verifier { @@ -19,8 +19,8 @@ class StatsCalculator { std::shared_ptr relation_; std::shared_ptr typed_relation_; - config::IndicesType lhs_indices_; - config::IndexType rhs_index_; + util::config::IndicesType lhs_indices_; + util::config::IndexType rhs_index_; size_t num_error_rows_ = 0; long double error_ = 0; @@ -87,7 +87,8 @@ class StatsCalculator { explicit StatsCalculator(std::shared_ptr relation, std::shared_ptr typed_relation, - config::IndicesType lhs_indices, config::IndexType rhs_index) + util::config::IndicesType lhs_indices, + util::config::IndexType rhs_index) : relation_(std::move(relation)), typed_relation_(std::move(typed_relation)), lhs_indices_(std::move(lhs_indices)), diff --git a/src/algorithms/metric/highlight_calculator.h b/src/algorithms/metric/highlight_calculator.h index ad00aaf5ed..abccf83b60 100644 --- a/src/algorithms/metric/highlight_calculator.h +++ b/src/algorithms/metric/highlight_calculator.h @@ -2,8 +2,8 @@ #include "algorithms/metric/highlight.h" #include "algorithms/metric/points.h" -#include "algorithms/options/indices/type.h" #include "model/column_layout_typed_relation_data.h" +#include "util/config/indices/type.h" namespace algos::metric { @@ -11,7 +11,7 @@ class HighlightCalculator { private: std::vector> highlights_; std::shared_ptr typed_relation_; - config::IndicesType rhs_indices_; + util::config::IndicesType rhs_indices_; template void SortHighlights(Compare compare) { @@ -52,7 +52,7 @@ class HighlightCalculator { explicit HighlightCalculator( std::shared_ptr typed_relation, - config::IndicesType rhs_indices) + util::config::IndicesType rhs_indices) : typed_relation_(std::move(typed_relation)), rhs_indices_(std::move(rhs_indices)){}; }; diff --git a/src/algorithms/metric/metric_verifier.cpp b/src/algorithms/metric/metric_verifier.cpp index add5b911c7..28929bf84d 100644 --- a/src/algorithms/metric/metric_verifier.cpp +++ b/src/algorithms/metric/metric_verifier.cpp @@ -10,21 +10,22 @@ #include -#include "algorithms/options/equal_nulls/option.h" -#include "algorithms/options/indices/option.h" -#include "algorithms/options/names_and_descriptions.h" +#include "util/config/equal_nulls/option.h" +#include "util/config/indices/option.h" +#include "util/config/names_and_descriptions.h" +#include "util/config/option_using.h" namespace algos::metric { MetricVerifier::MetricVerifier() : Algorithm({}) { RegisterOptions(); - MakeOptionsAvailable({config::EqualNullsOpt.GetName()}); + MakeOptionsAvailable({util::config::EqualNullsOpt.GetName()}); } -void MetricVerifier::ValidateRhs(config::IndicesType const& rhs_indices) { +void MetricVerifier::ValidateRhs(util::config::IndicesType const& rhs_indices) { assert(!rhs_indices.empty()); if (rhs_indices.size() == 1) { - config::IndexType column_index = rhs_indices[0]; + util::config::IndexType column_index = rhs_indices[0]; model::TypedColumnData const& column = typed_relation_->GetColumnData(column_index); model::TypeId type_id = column.GetTypeId(); if (type_id == +model::TypeId::kUndefined) { @@ -47,7 +48,7 @@ void MetricVerifier::ValidateRhs(config::IndicesType const& rhs_indices) { throw std::invalid_argument("The chosen metric is available only for string columns."); } if (metric_ == +Metric::euclidean) { - for (config::IndexType column_index : rhs_indices) { + for (util::config::IndexType column_index : rhs_indices) { model::TypedColumnData const& column = typed_relation_->GetColumnData(column_index); model::TypeId type_id = column.GetTypeId(); if (type_id == +model::TypeId::kUndefined) { @@ -71,19 +72,19 @@ void MetricVerifier::ValidateRhs(config::IndicesType const& rhs_indices) { } void MetricVerifier::RegisterOptions() { - using namespace config::names; - using namespace config::descriptions; - using config::Option; + DESBORDANTE_OPTION_USING; auto check_parameter = [](long double parameter) { if (parameter < 0) throw std::invalid_argument("Parameter out of range"); }; auto get_schema_columns = [this]() { return relation_->GetSchema()->GetNumColumns(); }; - auto check_rhs = [this](config::IndicesType const& rhs_indices) { ValidateRhs(rhs_indices); }; - auto need_algo_and_q = [this]([[maybe_unused]] config::IndicesType const& _) { + auto check_rhs = [this](util::config::IndicesType const& rhs_indices) { + ValidateRhs(rhs_indices); + }; + auto need_algo_and_q = [this]([[maybe_unused]] util::config::IndicesType const& _) { return metric_ == +Metric::cosine; }; - auto need_algo_only = [this](config::IndicesType const& rhs_indices) { + auto need_algo_only = [this](util::config::IndicesType const& rhs_indices) { assert(metric_ == +Metric::levenshtein || metric_ == +Metric::euclidean); return metric_ == +Metric::levenshtein || rhs_indices.size() != 1; }; @@ -99,24 +100,24 @@ void MetricVerifier::RegisterOptions() { if (q <= 0) throw std::invalid_argument("Q-gram length should be greater than zero."); }; - RegisterOption(config::EqualNullsOpt(&is_null_equal_null_)); - RegisterOption(config::LhsIndicesOpt(&lhs_indices_, get_schema_columns)); + RegisterOption(util::config::EqualNullsOpt(&is_null_equal_null_)); + RegisterOption(util::config::LhsIndicesOpt(&lhs_indices_, get_schema_columns)); RegisterOption(Option{&algo_, kMetricAlgorithm, kDMetricAlgorithm}.SetValueCheck(algo_check)); RegisterOption(Option{&dist_from_null_is_infinity_, kDistFromNullIsInfinity, kDDistFromNullIsInfinity, false}); RegisterOption(Option{¶meter_, kParameter, kDParameter}.SetValueCheck(check_parameter)); RegisterOption(Option{&q_, kQGramLength, kDQGramLength, 2u}.SetValueCheck(q_check)); - RegisterOption(config::RhsIndicesOpt(&rhs_indices_, get_schema_columns, check_rhs) + RegisterOption(util::config::RhsIndicesOpt(&rhs_indices_, get_schema_columns, check_rhs) .SetConditionalOpts({{need_algo_and_q, {kMetricAlgorithm, kQGramLength}}, {need_algo_only, {kMetricAlgorithm}}})); RegisterOption(Option{&metric_, kMetric, kDMetric}.SetConditionalOpts( - {{{}, {config::RhsIndicesOpt.GetName()}}})); + {{{}, {util::config::RhsIndicesOpt.GetName()}}})); } void MetricVerifier::MakeExecuteOptsAvailable() { - using namespace config::names; + using namespace util::config::names; MakeOptionsAvailable( - {kDistFromNullIsInfinity, kParameter, kMetric, config::LhsIndicesOpt.GetName()}); + {kDistFromNullIsInfinity, kParameter, kMetric, util::config::LhsIndicesOpt.GetName()}); } void MetricVerifier::LoadDataInternal(model::IDatasetStream& data_stream) { @@ -158,7 +159,7 @@ unsigned long long MetricVerifier::ExecuteInternal() { return elapsed_milliseconds.count(); } -std::string MetricVerifier::GetStringValue(config::IndicesType const& index_vec, +std::string MetricVerifier::GetStringValue(util::config::IndicesType const& index_vec, ClusterIndex row_index) const { model::TypedColumnData const& col = typed_relation_->GetColumnData(index_vec[0]); if (col.IsNull(row_index)) { diff --git a/src/algorithms/metric/metric_verifier.h b/src/algorithms/metric/metric_verifier.h index 6184639e6d..ff164b3f1a 100644 --- a/src/algorithms/metric/metric_verifier.h +++ b/src/algorithms/metric/metric_verifier.h @@ -15,10 +15,10 @@ #include "algorithms/metric/highlight_calculator.h" #include "algorithms/metric/points.h" #include "algorithms/metric/points_calculator.h" -#include "algorithms/options/equal_nulls/type.h" -#include "algorithms/options/indices/type.h" #include "model/column_layout_relation_data.h" #include "model/column_layout_typed_relation_data.h" +#include "util/config/equal_nulls/type.h" +#include "util/config/indices/type.h" #include "util/convex_hull.h" #include "util/qgram_vector.h" @@ -28,12 +28,12 @@ class MetricVerifier : public algos::Algorithm { private: Metric metric_ = Metric::_values()[0]; MetricAlgo algo_ = MetricAlgo::_values()[0]; - config::IndicesType lhs_indices_; - config::IndicesType rhs_indices_; + util::config::IndicesType lhs_indices_; + util::config::IndicesType rhs_indices_; long double parameter_; unsigned int q_; bool dist_from_null_is_infinity_; - config::EqNullsType is_null_equal_null_; + util::config::EqNullsType is_null_equal_null_; bool metric_fd_holds_ = false; @@ -72,9 +72,10 @@ class MetricVerifier : public algos::Algorithm { ClusterFunction GetClusterFunctionForOneDimension(); ClusterFunction GetClusterFunction(); void VerifyMetricFD(); - std::string GetStringValue(config::IndicesType const& index_vec, ClusterIndex row_index) const; + std::string GetStringValue(util::config::IndicesType const& index_vec, + ClusterIndex row_index) const; void VisualizeHighlights() const; - void ValidateRhs(config::IndicesType const& rhs_indices); + void ValidateRhs(util::config::IndicesType const& rhs_indices); void RegisterOptions(); void ResetState() final; @@ -89,11 +90,11 @@ class MetricVerifier : public algos::Algorithm { return metric_fd_holds_; } - config::IndicesType const& GetLhsIndices() const { + util::config::IndicesType const& GetLhsIndices() const { return lhs_indices_; } - config::IndicesType const& GetRhsIndices() const { + util::config::IndicesType const& GetRhsIndices() const { return rhs_indices_; } diff --git a/src/algorithms/metric/points_calculator.h b/src/algorithms/metric/points_calculator.h index 67363602ce..4f5f25dfa5 100644 --- a/src/algorithms/metric/points_calculator.h +++ b/src/algorithms/metric/points_calculator.h @@ -1,8 +1,8 @@ #pragma once #include "algorithms/metric/points.h" -#include "algorithms/options/indices/type.h" #include "model/column_layout_typed_relation_data.h" +#include "util/config/indices/type.h" #include "util/convex_hull.h" namespace algos::metric { @@ -11,7 +11,7 @@ class PointsCalculator { private: bool dist_from_null_is_infinity_; std::shared_ptr typed_relation_; - config::IndicesType rhs_indices_; + util::config::IndicesType rhs_indices_; long double GetCoordinate(bool& has_values, ClusterIndex row_index, bool& has_nulls, unsigned col_index, bool& has_empties) const; @@ -45,7 +45,7 @@ class PointsCalculator { explicit PointsCalculator(bool dist_from_null_is_infinity, std::shared_ptr typed_relation, - config::IndicesType rhs_indices) + util::config::IndicesType rhs_indices) : dist_from_null_is_infinity_(dist_from_null_is_infinity), typed_relation_(std::move(typed_relation)), rhs_indices_(std::move(rhs_indices)){}; diff --git a/src/algorithms/options/equal_nulls/option.cpp b/src/algorithms/options/equal_nulls/option.cpp deleted file mode 100644 index 19dc6ba5ef..0000000000 --- a/src/algorithms/options/equal_nulls/option.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "algorithms/options/equal_nulls/option.h" - -#include "algorithms/options/names_and_descriptions.h" - -namespace algos::config { -using names::kEqualNulls, descriptions::kDEqualNulls; -extern const CommonOption EqualNullsOpt{kEqualNulls, kDEqualNulls, true}; -} // namespace algos::config diff --git a/src/algorithms/options/equal_nulls/option.h b/src/algorithms/options/equal_nulls/option.h deleted file mode 100644 index be315952ce..0000000000 --- a/src/algorithms/options/equal_nulls/option.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include "algorithms/options/common_option.h" -#include "algorithms/options/equal_nulls/type.h" - -namespace algos::config { -extern const CommonOption EqualNullsOpt; -} // namespace algos::config diff --git a/src/algorithms/options/equal_nulls/type.h b/src/algorithms/options/equal_nulls/type.h deleted file mode 100644 index d9e973cf5d..0000000000 --- a/src/algorithms/options/equal_nulls/type.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -namespace algos::config { -using EqNullsType = bool; -} // namespace algos::config diff --git a/src/algorithms/options/error/option.h b/src/algorithms/options/error/option.h deleted file mode 100644 index ead5eeda74..0000000000 --- a/src/algorithms/options/error/option.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "algorithms/options/common_option.h" -#include "algorithms/options/error/type.h" - -namespace algos::config { - -extern const CommonOption ErrorOpt; - -} // namespace algos::config diff --git a/src/algorithms/options/error/type.h b/src/algorithms/options/error/type.h deleted file mode 100644 index adfd667c67..0000000000 --- a/src/algorithms/options/error/type.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -namespace algos::config { -using ErrorType = double; -} // namespace algos::config diff --git a/src/algorithms/options/indices/validate_index.h b/src/algorithms/options/indices/validate_index.h deleted file mode 100644 index 078d6e248c..0000000000 --- a/src/algorithms/options/indices/validate_index.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include - -#include "algorithms/options/indices/type.h" - -namespace algos::config { -void ValidateIndex(IndexType value, size_t cols_count); -} // namespace algos::config diff --git a/src/algorithms/options/max_lhs/option.h b/src/algorithms/options/max_lhs/option.h deleted file mode 100644 index 1d81d10519..0000000000 --- a/src/algorithms/options/max_lhs/option.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include "algorithms/options/common_option.h" -#include "algorithms/options/max_lhs/type.h" - -namespace algos::config { -extern const CommonOption MaxLhsOpt; -} // namespace algos::config diff --git a/src/algorithms/options/max_lhs/type.h b/src/algorithms/options/max_lhs/type.h deleted file mode 100644 index 65fcc4e0bc..0000000000 --- a/src/algorithms/options/max_lhs/type.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -namespace algos::config { -using MaxLhsType = unsigned int; -} // namespace algos::config diff --git a/src/algorithms/options/names_and_descriptions.h b/src/algorithms/options/names_and_descriptions.h deleted file mode 100644 index 5e1e04c61c..0000000000 --- a/src/algorithms/options/names_and_descriptions.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -#include "algorithms/options/descriptions.h" -#include "algorithms/options/names.h" diff --git a/src/algorithms/options/thread_number/option.h b/src/algorithms/options/thread_number/option.h deleted file mode 100644 index 087a833f30..0000000000 --- a/src/algorithms/options/thread_number/option.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include - -#include "algorithms/options/common_option.h" -#include "algorithms/options/thread_number/type.h" - -namespace algos::config { -extern const CommonOption ThreadNumberOpt; -} // namespace algos::config diff --git a/src/algorithms/options/thread_number/type.h b/src/algorithms/options/thread_number/type.h deleted file mode 100644 index 7eecb7424a..0000000000 --- a/src/algorithms/options/thread_number/type.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -namespace algos::config { -using ThreadNumType = unsigned short; -} // namespace algos::config diff --git a/src/algorithms/pyro.cpp b/src/algorithms/pyro.cpp index 2ade9a4338..dfa548d261 100644 --- a/src/algorithms/pyro.cpp +++ b/src/algorithms/pyro.cpp @@ -6,12 +6,13 @@ #include -#include "algorithms/options/error/option.h" -#include "algorithms/options/max_lhs/option.h" -#include "algorithms/options/names_and_descriptions.h" -#include "algorithms/options/thread_number/option.h" #include "core/fd_g1_strategy.h" #include "core/key_g1_strategy.h" +#include "util/config/error/option.h" +#include "util/config/max_lhs/option.h" +#include "util/config/names_and_descriptions.h" +#include "util/config/option_using.h" +#include "util/config/thread_number/option.h" namespace algos { @@ -29,20 +30,18 @@ Pyro::Pyro() : PliBasedFDAlgorithm({kDefaultPhaseName}) { } void Pyro::RegisterOptions() { - using namespace config::names; - using namespace config::descriptions; - using config::Option; + DESBORDANTE_OPTION_USING; - RegisterOption(config::ErrorOpt(&configuration_.max_ucc_error)); - RegisterOption(config::MaxLhsOpt(&configuration_.max_lhs)); - RegisterOption(config::ThreadNumberOpt(&configuration_.parallelism)); + RegisterOption(util::config::ErrorOpt(&configuration_.max_ucc_error)); + RegisterOption(util::config::MaxLhsOpt(&configuration_.max_lhs)); + RegisterOption(util::config::ThreadNumberOpt(&configuration_.parallelism)); RegisterOption(Option{&configuration_.seed, kSeed, kDSeed, 0}); } void Pyro::MakeExecuteOptsAvailable() { - using namespace config::names; - MakeOptionsAvailable({config::MaxLhsOpt.GetName(), config::ErrorOpt.GetName(), - config::ThreadNumberOpt.GetName(), kSeed}); + using namespace util::config::names; + MakeOptionsAvailable({util::config::MaxLhsOpt.GetName(), util::config::ErrorOpt.GetName(), + util::config::ThreadNumberOpt.GetName(), kSeed}); } void Pyro::ResetStateFd() { diff --git a/src/algorithms/statistics/data_stats.cpp b/src/algorithms/statistics/data_stats.cpp index eccd8af3d4..390dabe204 100644 --- a/src/algorithms/statistics/data_stats.cpp +++ b/src/algorithms/statistics/data_stats.cpp @@ -4,8 +4,8 @@ #include #include -#include "algorithms/options/equal_nulls/option.h" -#include "algorithms/options/thread_number/option.h" +#include "util/config/equal_nulls/option.h" +#include "util/config/thread_number/option.h" namespace algos { @@ -14,16 +14,16 @@ namespace mo = model; DataStats::DataStats() : Algorithm({"Calculating statistics"}) { RegisterOptions(); - MakeOptionsAvailable({config::EqualNullsOpt.GetName()}); + MakeOptionsAvailable({util::config::EqualNullsOpt.GetName()}); } void DataStats::RegisterOptions() { - RegisterOption(config::EqualNullsOpt(&is_null_equal_null_)); - RegisterOption(config::ThreadNumberOpt(&threads_num_)); + RegisterOption(util::config::EqualNullsOpt(&is_null_equal_null_)); + RegisterOption(util::config::ThreadNumberOpt(&threads_num_)); } void DataStats::MakeExecuteOptsAvailable() { - MakeOptionsAvailable({config::ThreadNumberOpt.GetName()}); + MakeOptionsAvailable({util::config::ThreadNumberOpt.GetName()}); } void DataStats::ResetState() { diff --git a/src/algorithms/statistics/data_stats.h b/src/algorithms/statistics/data_stats.h index 7752ee0506..d106a49488 100644 --- a/src/algorithms/statistics/data_stats.h +++ b/src/algorithms/statistics/data_stats.h @@ -1,16 +1,16 @@ #pragma once #include "algorithms/fd_algorithm.h" -#include "algorithms/options/equal_nulls/type.h" -#include "algorithms/options/thread_number/type.h" #include "algorithms/statistics/statistic.h" #include "model/column_layout_typed_relation_data.h" +#include "util/config/equal_nulls/type.h" +#include "util/config/thread_number/type.h" namespace algos { class DataStats : public Algorithm { - config::EqNullsType is_null_equal_null_; - config::ThreadNumType threads_num_; + util::config::EqNullsType is_null_equal_null_; + util::config::ThreadNumType threads_num_; std::vector col_data_; std::vector all_stats_; diff --git a/src/algorithms/tane.cpp b/src/algorithms/tane.cpp index 3f8afa143c..ef01a200d2 100644 --- a/src/algorithms/tane.cpp +++ b/src/algorithms/tane.cpp @@ -7,12 +7,12 @@ #include -#include "algorithms/options/error/option.h" -#include "algorithms/options/max_lhs/option.h" #include "model/column_combination.h" #include "model/column_data.h" #include "model/column_layout_relation_data.h" #include "model/relational_schema.h" +#include "util/config/error/option.h" +#include "util/config/max_lhs/option.h" #include "util/lattice_level.h" #include "util/lattice_vertex.h" @@ -23,12 +23,12 @@ Tane::Tane() : PliBasedFDAlgorithm({kDefaultPhaseName}) { } void Tane::RegisterOptions() { - RegisterOption(config::ErrorOpt(&max_ucc_error_)); - RegisterOption(config::MaxLhsOpt(&max_lhs_)); + RegisterOption(util::config::ErrorOpt(&max_ucc_error_)); + RegisterOption(util::config::MaxLhsOpt(&max_lhs_)); } void Tane::MakeExecuteOptsAvailable() { - MakeOptionsAvailable({config::MaxLhsOpt.GetName(), config::ErrorOpt.GetName()}); + MakeOptionsAvailable({util::config::MaxLhsOpt.GetName(), util::config::ErrorOpt.GetName()}); } void Tane::ResetStateFd() { diff --git a/src/algorithms/tane.h b/src/algorithms/tane.h index e0b3497a44..7a5ba0abc1 100644 --- a/src/algorithms/tane.h +++ b/src/algorithms/tane.h @@ -2,10 +2,10 @@ #include -#include "algorithms/options/error/type.h" -#include "algorithms/options/max_lhs/type.h" #include "algorithms/pli_based_fd_algorithm.h" #include "model/relation_data.h" +#include "util/config/error/type.h" +#include "util/config/max_lhs/type.h" #include "util/position_list_index.h" namespace algos { @@ -19,9 +19,9 @@ class Tane : public PliBasedFDAlgorithm { unsigned long long ExecuteInternal() final; public: - config::ErrorType max_fd_error_; - config::ErrorType max_ucc_error_; - config::MaxLhsType max_lhs_; + util::config::ErrorType max_fd_error_; + util::config::ErrorType max_ucc_error_; + util::config::MaxLhsType max_lhs_; int count_of_fd_ = 0; int count_of_ucc_ = 0; diff --git a/src/algorithms/typo_miner.cpp b/src/algorithms/typo_miner.cpp index 501b2d6d45..00fd40e5af 100644 --- a/src/algorithms/typo_miner.cpp +++ b/src/algorithms/typo_miner.cpp @@ -1,8 +1,9 @@ #include "algorithms/typo_miner.h" -#include "algorithms/options/equal_nulls/option.h" -#include "algorithms/options/error/option.h" -#include "algorithms/options/names_and_descriptions.h" +#include "util/config/equal_nulls/option.h" +#include "util/config/error/option.h" +#include "util/config/names_and_descriptions.h" +#include "util/config/option_using.h" namespace algos { @@ -17,13 +18,11 @@ TypoMiner::TypoMiner(std::unique_ptr precise_algo, precise_algo_(std::move(precise_algo)), approx_algo_(std::move(approx_algo)) { RegisterOptions(); - MakeOptionsAvailable({config::EqualNullsOpt.GetName()}); + MakeOptionsAvailable({util::config::EqualNullsOpt.GetName()}); } void TypoMiner::RegisterOptions() { - using namespace config::names; - using namespace config::descriptions; - using config::Option; + DESBORDANTE_OPTION_USING; auto radius_check = [](double radius) { if (!(radius == -1 || radius >= 0)) { @@ -39,13 +38,13 @@ void TypoMiner::RegisterOptions() { } }; - RegisterOption(config::EqualNullsOpt(&is_null_equal_null_)); + RegisterOption(util::config::EqualNullsOpt(&is_null_equal_null_)); RegisterOption(Option{&radius_, kRadius, kDRadius, -1.0}.SetValueCheck(radius_check)); RegisterOption(Option{&ratio_, kRatio, kDRatio, {ratio_default}}.SetValueCheck(ratio_check)); } void TypoMiner::MakeExecuteOptsAvailable() { - using namespace config::names; + using namespace util::config::names; MakeOptionsAvailable({kRadius, kRatio}); } @@ -53,18 +52,18 @@ void TypoMiner::ResetState() { approx_fds_.clear(); } -bool TypoMiner::HandleUnknownOption(std::string_view option_name, boost::any const& value) { - if (option_name == config::ErrorOpt.GetName()) { +bool TypoMiner::SetExternalOption(std::string_view option_name, boost::any const& value) { + if (option_name == util::config::ErrorOpt.GetName()) { if (value.empty()) { throw std::invalid_argument("Must specify error value when mining typos."); } - auto error = boost::any_cast(value); + auto error = boost::any_cast(value); if (error == 0.0) { throw std::invalid_argument("Typo mining with error 0 is meaningless"); } - return static_cast(TrySetOption(option_name, config::ErrorType{0.0}, value)); + return TrySetOption(option_name, util::config::ErrorType{0.0}, value) != 0; } - return static_cast(TrySetOption(option_name, value, value)); + return TrySetOption(option_name, value, value) != 0; } int TypoMiner::TrySetOption(std::string_view option_name, boost::any const& value_precise, @@ -84,11 +83,6 @@ int TypoMiner::TrySetOption(std::string_view option_name, boost::any const& valu void TypoMiner::AddSpecificNeededOptions(std::unordered_set& previous_options) const { auto precise_options = precise_algo_->GetNeededOptions(); auto approx_options = approx_algo_->GetNeededOptions(); - if (!DataLoaded()) { - // blocked by TypoMiner's is_null_equal_null option - precise_options.erase(config::names::kEqualNulls); - approx_options.erase(config::names::kEqualNulls); - } previous_options.insert(precise_options.begin(), precise_options.end()); previous_options.insert(approx_options.begin(), approx_options.end()); } @@ -98,22 +92,15 @@ void TypoMiner::LoadDataInternal(model::IDatasetStream& data_stream) { data_stream.Reset(); typed_relation_ = model::ColumnLayoutTypedRelationData::CreateFrom(data_stream, is_null_equal_null_); - data_stream.Reset(); - auto precise_pli = dynamic_cast(precise_algo_.get()); - auto approx_pli = dynamic_cast(approx_algo_.get()); - boost::any null_opt_any{is_null_equal_null_}; - TrySetOption(config::EqualNullsOpt.GetName(), null_opt_any, null_opt_any); - if (!precise_algo_->DataLoaded()) { - if (precise_pli != nullptr) - precise_pli->LoadData(relation_); - else - precise_algo_->LoadData(data_stream); - } - if (!approx_algo_->DataLoaded()) { - if (approx_pli != nullptr) - approx_pli->LoadData(relation_); - else - approx_algo_->LoadData(data_stream); + + for (Algorithm* algo : {precise_algo_.get(), approx_algo_.get()}) { + auto pli_algo = dynamic_cast(algo); + if (pli_algo == nullptr) { + data_stream.Reset(); + algo->LoadData(data_stream); + } else { + pli_algo->LoadData(relation_); + } } } diff --git a/src/algorithms/typo_miner.h b/src/algorithms/typo_miner.h index 4069e69041..abef88f45d 100644 --- a/src/algorithms/typo_miner.h +++ b/src/algorithms/typo_miner.h @@ -2,13 +2,13 @@ #include "algorithms/algorithm.h" #include "algorithms/create_algorithm.h" -#include "algorithms/options/equal_nulls/type.h" -#include "algorithms/options/names.h" #include "algorithms/pyro.h" #include "model/column_layout_typed_relation_data.h" #include "model/idataset_stream.h" #include "parser/csv_parser.h" #include "types.h" +#include "util/config/equal_nulls/type.h" +#include "util/config/names.h" namespace algos { @@ -23,7 +23,7 @@ class TypoMiner : public Algorithm { double radius_; /* Maximal distance between two values to consider one of them a typo */ double ratio_; /* Maximal fraction of deviations per cluster to flag the cluster as * containing typos */ - config::EqNullsType is_null_equal_null_; + util::config::EqNullsType is_null_equal_null_; void ResetState() final; @@ -47,7 +47,7 @@ class TypoMiner : public Algorithm { void MakeExecuteOptsAvailable() final; void AddSpecificNeededOptions( std::unordered_set& previous_options) const final; - bool HandleUnknownOption(std::string_view option_name, boost::any const& value) final; + bool SetExternalOption(std::string_view option_name, boost::any const& value) final; int TrySetOption(std::string_view option_name, boost::any const& value_precise, boost::any const& value_approx); @@ -110,11 +110,11 @@ class TypoMiner : public Algorithm { return ratio_; } double SetRadius(double radius) { - SetOption(config::names::kRadius, radius); + SetOption(util::config::names::kRadius, radius); return radius_; } double SetRatio(double ratio) { - SetOption(config::names::kRatio, ratio); + SetOption(util::config::names::kRatio, ratio); return ratio_; } ColumnLayoutRelationData const& GetRelationData() const noexcept { diff --git a/src/algorithms/ucc/ucc_algorithm.cpp b/src/algorithms/ucc/ucc_algorithm.cpp index e0eb790a90..264b0631f6 100644 --- a/src/algorithms/ucc/ucc_algorithm.cpp +++ b/src/algorithms/ucc/ucc_algorithm.cpp @@ -1,9 +1,11 @@ #include "algorithms/ucc/ucc_algorithm.h" +#include "util/config/equal_nulls/option.h" + namespace algos { void UCCAlgorithm::RegisterOptions() { - RegisterOption(config::EqualNullsOpt(&is_null_equal_null_)); + RegisterOption(util::config::EqualNullsOpt(&is_null_equal_null_)); } } // namespace algos diff --git a/src/algorithms/ucc/ucc_algorithm.h b/src/algorithms/ucc/ucc_algorithm.h index 1da1b2cf55..c4ea5c2ed1 100644 --- a/src/algorithms/ucc/ucc_algorithm.h +++ b/src/algorithms/ucc/ucc_algorithm.h @@ -5,9 +5,9 @@ #include #include "algorithms/algorithm.h" -#include "algorithms/options/equal_nulls/option.h" -#include "algorithms/options/equal_nulls/type.h" #include "model/ucc.h" +#include "util/config/equal_nulls/option.h" +#include "util/config/equal_nulls/type.h" #include "util/primitive_collection.h" namespace algos { @@ -27,7 +27,7 @@ class UCCAlgorithm : public Algorithm { protected: // Collection of all mined UCCs. Every UCC mining algorithm must register found uccs here. util::PrimitiveCollection ucc_collection_; - config::EqNullsType is_null_equal_null_{}; + util::config::EqNullsType is_null_equal_null_{}; // Pass this value as phase_names to the constructor if your algorithm has only one progress bar // phase. @@ -37,7 +37,7 @@ class UCCAlgorithm : public Algorithm { explicit UCCAlgorithm(std::vector phase_names) : Algorithm(std::move(phase_names)) { RegisterOptions(); - MakeOptionsAvailable({config::EqualNullsOpt.GetName()}); + MakeOptionsAvailable({util::config::EqualNullsOpt.GetName()}); } public: diff --git a/src/core/configuration.h b/src/core/configuration.h index c8e51b76c3..c4176f5a9e 100644 --- a/src/core/configuration.h +++ b/src/core/configuration.h @@ -2,30 +2,30 @@ #include -#include "algorithms/options/equal_nulls/type.h" -#include "algorithms/options/error/type.h" -#include "algorithms/options/max_lhs/type.h" -#include "algorithms/options/thread_number/type.h" +#include "util/config/equal_nulls/type.h" +#include "util/config/error/type.h" +#include "util/config/max_lhs/type.h" +#include "util/config/thread_number/type.h" struct Configuration { bool is_find_keys = true; bool is_find_fds = true; - algos::config::EqNullsType is_null_equal_null = true; + util::config::EqNullsType is_null_equal_null = true; std::string ucc_error_measure = "g1prime"; //Error settings - algos::config::ErrorType error_dev = 0; + util::config::ErrorType error_dev = 0; bool is_estimate_only = false; - algos::config::ErrorType max_ucc_error = 0.01; // both for FD and UCC actually + util::config::ErrorType max_ucc_error = 0.01; // both for FD and UCC actually //Traversal settings - algos::config::ThreadNumType parallelism = 0; - algos::config::ThreadNumType max_threads_per_search_space = -1; + util::config::ThreadNumType parallelism = 0; + util::config::ThreadNumType max_threads_per_search_space = -1; bool is_defer_failed_launch_pads = true; std::string launch_pad_order = "error"; - algos::config::MaxLhsType max_lhs = -1; + util::config::MaxLhsType max_lhs = -1; //Sampling settings unsigned int sample_size = 10000; diff --git a/src/main.cpp b/src/main.cpp index 154a5c109c..30e8a5d538 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,8 +5,8 @@ #include #include "algorithms/algo_factory.h" -#include "algorithms/options/all_options.h" -#include "algorithms/options/enum_to_available_values.h" +#include "util/config/all_options.h" +#include "util/config/enum_to_available_values.h" INITIALIZE_EASYLOGGINGPP @@ -27,11 +27,11 @@ boost::program_options::options_description InfoOptions() { int main(int argc, char const* argv[]) { namespace po = boost::program_options; - using namespace algos::config; + using namespace util::config; std::string algorithm; std::string const algo_desc = "algorithm to use for data profiling\n" + - algos::EnumToAvailableValues() + " + [ac]"; + util::EnumToAvailableValues() + " + [ac]"; auto general_options = GeneralOptions(); // clang-format off diff --git a/src/algorithms/options/all_options.cpp b/src/util/config/all_options.cpp similarity index 96% rename from src/algorithms/options/all_options.cpp rename to src/util/config/all_options.cpp index 01e4ae1883..cb1438b4a4 100644 --- a/src/algorithms/options/all_options.cpp +++ b/src/util/config/all_options.cpp @@ -6,7 +6,7 @@ #include "algorithms/ar_algorithm_enums.h" #include "algorithms/create_algorithm.h" #include "algorithms/metric/enums.h" -#include "algorithms/options/names_and_descriptions.h" +#include "util/config/names_and_descriptions.h" namespace algos { template @@ -25,13 +25,13 @@ using algos::validate; } // namespace metric } // namespace algos -namespace algos::config { +namespace util::config { boost::program_options::options_description GeneralOptions() { namespace po = boost::program_options; using namespace config::names; using namespace config::descriptions; - std::string const kSeparatorOpt = std::string(algos::config::names::kSeparator) + ",s"; + std::string const kSeparatorOpt = std::string(kSeparator) + ",s"; // clang-format off po::options_description general_options("General options"); @@ -142,4 +142,4 @@ boost::program_options::options_description AlgoOptions() { .add(fd_verification_options); return algorithm_options; } -} // namespace algos::config +} // namespace util::config diff --git a/src/algorithms/options/all_options.h b/src/util/config/all_options.h similarity index 75% rename from src/algorithms/options/all_options.h rename to src/util/config/all_options.h index 2c6e9d1754..62b08bd4f5 100644 --- a/src/algorithms/options/all_options.h +++ b/src/util/config/all_options.h @@ -2,7 +2,7 @@ #include -namespace algos::config { +namespace util::config { boost::program_options::options_description GeneralOptions(); boost::program_options::options_description AlgoOptions(); -} // namespace algos::config +} // namespace util::config diff --git a/src/algorithms/options/common_option.h b/src/util/config/common_option.h similarity index 93% rename from src/algorithms/options/common_option.h rename to src/util/config/common_option.h index c34e3c5b69..67c15114ea 100644 --- a/src/algorithms/options/common_option.h +++ b/src/util/config/common_option.h @@ -3,9 +3,9 @@ #include #include -#include "algorithms/options/option.h" +#include "util/config/option.h" -namespace algos::config { +namespace util::config { // Aids in creating options that come up often in unrelated algorithms, like // null equality. @@ -43,4 +43,4 @@ class CommonOption { } }; -} // namespace algos::config +} // namespace util::config diff --git a/src/algorithms/options/descriptions.h b/src/util/config/descriptions.h similarity index 94% rename from src/algorithms/options/descriptions.h rename to src/util/config/descriptions.h index 9dc596c2d2..d6292a915a 100644 --- a/src/algorithms/options/descriptions.h +++ b/src/util/config/descriptions.h @@ -5,9 +5,9 @@ #include "algorithms/enums.h" #include "algorithms/metric/enums.h" -#include "algorithms/options/enum_to_available_values.h" +#include "util/config/enum_to_available_values.h" -namespace algos::config::descriptions { +namespace util::config::descriptions { constexpr auto kDData = "path to CSV file, relative to ./input_data"; constexpr auto kDSeparator = "CSV separator"; constexpr auto kDHasHeader = "CSV header presence flag [true|false]"; @@ -43,4 +43,4 @@ constexpr auto kDRatio = "ratio between the number of deviating values in a clus constexpr auto kDPreciseAlgorithm = "Algorithm that gives exact FDs for typo miner to compare " "against approximate FDs"; constexpr auto kDApproximateAlgorithm = "Algorithm which gets approximate FDs for typo miner"; -} // namespace algos::config::descriptions +} // namespace util::config::descriptions diff --git a/src/algorithms/options/enum_to_available_values.h b/src/util/config/enum_to_available_values.h similarity index 91% rename from src/algorithms/options/enum_to_available_values.h rename to src/util/config/enum_to_available_values.h index 019404124f..52e3f9e64d 100644 --- a/src/algorithms/options/enum_to_available_values.h +++ b/src/util/config/enum_to_available_values.h @@ -3,7 +3,7 @@ #include #include -namespace algos { +namespace util { template static std::string EnumToAvailableValues() { @@ -21,4 +21,4 @@ static std::string EnumToAvailableValues() { return avail_values.str(); } -} // namespace algos +} // namespace util diff --git a/src/util/config/equal_nulls/option.cpp b/src/util/config/equal_nulls/option.cpp new file mode 100644 index 0000000000..2005e428c6 --- /dev/null +++ b/src/util/config/equal_nulls/option.cpp @@ -0,0 +1,8 @@ +#include "util/config/equal_nulls/option.h" + +#include "util/config/names_and_descriptions.h" + +namespace util::config { +using names::kEqualNulls, descriptions::kDEqualNulls; +extern const CommonOption EqualNullsOpt{kEqualNulls, kDEqualNulls, true}; +} // namespace util::config diff --git a/src/util/config/equal_nulls/option.h b/src/util/config/equal_nulls/option.h new file mode 100644 index 0000000000..0b3a1288a9 --- /dev/null +++ b/src/util/config/equal_nulls/option.h @@ -0,0 +1,8 @@ +#pragma once + +#include "util/config/common_option.h" +#include "util/config/equal_nulls/type.h" + +namespace util::config { +extern const CommonOption EqualNullsOpt; +} // namespace util::config diff --git a/src/util/config/equal_nulls/type.h b/src/util/config/equal_nulls/type.h new file mode 100644 index 0000000000..b24852090f --- /dev/null +++ b/src/util/config/equal_nulls/type.h @@ -0,0 +1,5 @@ +#pragma once + +namespace util::config { +using EqNullsType = bool; +} // namespace util::config diff --git a/src/algorithms/options/error/option.cpp b/src/util/config/error/option.cpp similarity index 66% rename from src/algorithms/options/error/option.cpp rename to src/util/config/error/option.cpp index a62b2437a8..9b3c44be48 100644 --- a/src/algorithms/options/error/option.cpp +++ b/src/util/config/error/option.cpp @@ -1,8 +1,8 @@ -#include "algorithms/options/error/option.h" +#include "util/config/error/option.h" -#include "algorithms/options/names_and_descriptions.h" +#include "util/config/names_and_descriptions.h" -namespace algos::config { +namespace util::config { using names::kError, descriptions::kDError; extern const CommonOption ErrorOpt{ kError, kDError, 0.0, {}, [](ErrorType error) { @@ -10,4 +10,4 @@ extern const CommonOption ErrorOpt{ throw std::invalid_argument("ERROR: error should be between 0 and 1."); } }}; -} // namespace algos::config +} // namespace util::config diff --git a/src/util/config/error/option.h b/src/util/config/error/option.h new file mode 100644 index 0000000000..95285bcb34 --- /dev/null +++ b/src/util/config/error/option.h @@ -0,0 +1,10 @@ +#pragma once + +#include "util/config/common_option.h" +#include "util/config/error/type.h" + +namespace util::config { + +extern const CommonOption ErrorOpt; + +} // namespace util::config diff --git a/src/util/config/error/type.h b/src/util/config/error/type.h new file mode 100644 index 0000000000..4836926182 --- /dev/null +++ b/src/util/config/error/type.h @@ -0,0 +1,5 @@ +#pragma once + +namespace util::config { +using ErrorType = double; +} // namespace util::config diff --git a/src/algorithms/options/indices/option.cpp b/src/util/config/indices/option.cpp similarity index 88% rename from src/algorithms/options/indices/option.cpp rename to src/util/config/indices/option.cpp index dd5d613dde..d16bbda40b 100644 --- a/src/algorithms/options/indices/option.cpp +++ b/src/util/config/indices/option.cpp @@ -1,12 +1,12 @@ -#include "algorithms/options/indices/option.h" +#include "util/config/indices/option.h" #include #include -#include "algorithms/options/indices/validate_index.h" -#include "algorithms/options/names_and_descriptions.h" +#include "util/config/indices/validate_index.h" +#include "util/config/names_and_descriptions.h" -namespace algos::config { +namespace util::config { static void NormalizeIndices(config::IndicesType& indices) { std::sort(indices.begin(), indices.end()); @@ -44,4 +44,4 @@ using config::names::kRhsIndices, config::descriptions::kDRhsIndices; extern const IndicesOption LhsIndicesOpt{kLhsIndices, kDLhsIndices}; extern const IndicesOption RhsIndicesOpt{kRhsIndices, kDRhsIndices}; -} // namespace algos::config +} // namespace util::config diff --git a/src/algorithms/options/indices/option.h b/src/util/config/indices/option.h similarity index 84% rename from src/algorithms/options/indices/option.h rename to src/util/config/indices/option.h index 59c0274459..f6c200f647 100644 --- a/src/algorithms/options/indices/option.h +++ b/src/util/config/indices/option.h @@ -2,10 +2,10 @@ #include -#include "algorithms/options/common_option.h" -#include "algorithms/options/indices/type.h" +#include "util/config/common_option.h" +#include "util/config/indices/type.h" -namespace algos::config { +namespace util::config { // This class is meant for creating options that are collections of indices. struct IndicesOption { @@ -26,4 +26,4 @@ struct IndicesOption { extern const IndicesOption LhsIndicesOpt; extern const IndicesOption RhsIndicesOpt; -} // namespace algos::config +} // namespace util::config diff --git a/src/algorithms/options/indices/type.h b/src/util/config/indices/type.h similarity index 66% rename from src/algorithms/options/indices/type.h rename to src/util/config/indices/type.h index 19814bdc23..cff36b2afa 100644 --- a/src/algorithms/options/indices/type.h +++ b/src/util/config/indices/type.h @@ -2,7 +2,7 @@ #include -namespace algos::config { +namespace util::config { using IndexType = unsigned int; using IndicesType = std::vector; -} // namespace algos::config +} // namespace util::config diff --git a/src/algorithms/options/indices/validate_index.cpp b/src/util/config/indices/validate_index.cpp similarity index 68% rename from src/algorithms/options/indices/validate_index.cpp rename to src/util/config/indices/validate_index.cpp index 42fdae22fe..0ae22de88e 100644 --- a/src/algorithms/options/indices/validate_index.cpp +++ b/src/util/config/indices/validate_index.cpp @@ -1,8 +1,8 @@ -#include "algorithms/options/indices/validate_index.h" +#include "util/config/indices/validate_index.h" #include -namespace algos::config { +namespace util::config { void ValidateIndex(IndexType value, size_t cols_count) { if (value >= cols_count) { @@ -11,4 +11,4 @@ void ValidateIndex(IndexType value, size_t cols_count) { } } -} // namespace algos::config +} // namespace util::config diff --git a/src/util/config/indices/validate_index.h b/src/util/config/indices/validate_index.h new file mode 100644 index 0000000000..2b12846ef6 --- /dev/null +++ b/src/util/config/indices/validate_index.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +#include "util/config/indices/type.h" + +namespace util::config { +void ValidateIndex(IndexType value, size_t cols_count); +} // namespace util::config diff --git a/src/algorithms/options/ioption.h b/src/util/config/ioption.h similarity index 89% rename from src/algorithms/options/ioption.h rename to src/util/config/ioption.h index d5db9ac25b..01b9ed5ac0 100644 --- a/src/algorithms/options/ioption.h +++ b/src/util/config/ioption.h @@ -6,7 +6,7 @@ #include "boost/any.hpp" -namespace algos::config { +namespace util::config { class IOption { public: @@ -18,4 +18,4 @@ class IOption { virtual ~IOption() = default; }; -} // namespace algos::config +} // namespace util::config diff --git a/src/algorithms/options/max_lhs/option.cpp b/src/util/config/max_lhs/option.cpp similarity index 60% rename from src/algorithms/options/max_lhs/option.cpp rename to src/util/config/max_lhs/option.cpp index 47d205dfe9..e0f039a04c 100644 --- a/src/algorithms/options/max_lhs/option.cpp +++ b/src/util/config/max_lhs/option.cpp @@ -1,11 +1,11 @@ -#include "algorithms/options/max_lhs/option.h" +#include "util/config/max_lhs/option.h" #include -#include "algorithms/options/names_and_descriptions.h" +#include "util/config/names_and_descriptions.h" -namespace algos::config { +namespace util::config { using names::kMaximumLhs, descriptions::kDMaximumLhs; extern const CommonOption MaxLhsOpt{kMaximumLhs, kDMaximumLhs, std::numeric_limits::max()}; -} // namespace algos::config +} // namespace util::config diff --git a/src/util/config/max_lhs/option.h b/src/util/config/max_lhs/option.h new file mode 100644 index 0000000000..1f82d6ca8e --- /dev/null +++ b/src/util/config/max_lhs/option.h @@ -0,0 +1,8 @@ +#pragma once + +#include "util/config/common_option.h" +#include "util/config/max_lhs/type.h" + +namespace util::config { +extern const CommonOption MaxLhsOpt; +} // namespace util::config diff --git a/src/util/config/max_lhs/type.h b/src/util/config/max_lhs/type.h new file mode 100644 index 0000000000..408147004b --- /dev/null +++ b/src/util/config/max_lhs/type.h @@ -0,0 +1,5 @@ +#pragma once + +namespace util::config { +using MaxLhsType = unsigned int; +} // namespace util::config diff --git a/src/algorithms/options/names.h b/src/util/config/names.h similarity index 95% rename from src/algorithms/options/names.h rename to src/util/config/names.h index db55baadc2..8be9359b5b 100644 --- a/src/algorithms/options/names.h +++ b/src/util/config/names.h @@ -1,6 +1,6 @@ #pragma once -namespace algos::config::names { +namespace util::config::names { constexpr auto kData = "data"; constexpr auto kSeparator = "separator"; constexpr auto kHasHeader = "has_header"; @@ -35,4 +35,4 @@ constexpr auto kPairingRule = "pairing_rule"; constexpr auto kACSeed = "ac_seed"; constexpr auto kPreciseAlgorithm = "precise_algorithm"; constexpr auto kApproximateAlgorithm = "approximate_algorithm"; -} // namespace algos::config::names +} // namespace util::config::names diff --git a/src/util/config/names_and_descriptions.h b/src/util/config/names_and_descriptions.h new file mode 100644 index 0000000000..801a3def75 --- /dev/null +++ b/src/util/config/names_and_descriptions.h @@ -0,0 +1,4 @@ +#pragma once + +#include "util/config/descriptions.h" +#include "util/config/names.h" diff --git a/src/algorithms/options/option.h b/src/util/config/option.h similarity index 97% rename from src/algorithms/options/option.h rename to src/util/config/option.h index 75d0743852..67c53870b0 100644 --- a/src/algorithms/options/option.h +++ b/src/util/config/option.h @@ -7,9 +7,9 @@ #include -#include "algorithms/options/ioption.h" +#include "util/config/ioption.h" -namespace algos::config { +namespace util::config { // This class is responsible for configuration values. It is provided with a // pointer to a field of an algorithm object, option name, and option @@ -135,4 +135,4 @@ T Option::ConvertValue(boost::any const &value) const { } } -} // namespace algos::config +} // namespace util::config diff --git a/src/util/config/option_using.h b/src/util/config/option_using.h new file mode 100644 index 0000000000..fdcf688428 --- /dev/null +++ b/src/util/config/option_using.h @@ -0,0 +1,6 @@ +#pragma once + +#define DESBORDANTE_OPTION_USING \ + using namespace util::config::names; \ + using namespace util::config::descriptions; \ + using util::config::Option diff --git a/src/algorithms/options/thread_number/option.cpp b/src/util/config/thread_number/option.cpp similarity index 78% rename from src/algorithms/options/thread_number/option.cpp rename to src/util/config/thread_number/option.cpp index 5e251e87d4..cbbfbee020 100644 --- a/src/algorithms/options/thread_number/option.cpp +++ b/src/util/config/thread_number/option.cpp @@ -1,10 +1,10 @@ -#include "algorithms/options/thread_number/option.h" +#include "util/config/thread_number/option.h" #include -#include "algorithms/options/names_and_descriptions.h" +#include "util/config/names_and_descriptions.h" -namespace algos::config { +namespace util::config { using names::kThreads, descriptions::kDThreads; extern const CommonOption ThreadNumberOpt{ kThreads, kDThreads, 0, [](auto &value) { @@ -18,4 +18,4 @@ extern const CommonOption ThreadNumberOpt{ } } }}; -} // namespace algos::config +} // namespace util::config diff --git a/src/util/config/thread_number/option.h b/src/util/config/thread_number/option.h new file mode 100644 index 0000000000..29da15b92f --- /dev/null +++ b/src/util/config/thread_number/option.h @@ -0,0 +1,10 @@ +#pragma once + +#include + +#include "util/config/common_option.h" +#include "util/config/thread_number/type.h" + +namespace util::config { +extern const CommonOption ThreadNumberOpt; +} // namespace util::config diff --git a/src/util/config/thread_number/type.h b/src/util/config/thread_number/type.h new file mode 100644 index 0000000000..1c111506cc --- /dev/null +++ b/src/util/config/thread_number/type.h @@ -0,0 +1,5 @@ +#pragma once + +namespace util::config { +using ThreadNumType = unsigned short; +} // namespace util::config diff --git a/tests/test_algo_interfaces.cpp b/tests/test_algo_interfaces.cpp index e810743b8a..9b55954fb1 100644 --- a/tests/test_algo_interfaces.cpp +++ b/tests/test_algo_interfaces.cpp @@ -6,10 +6,10 @@ #include #include "algorithms/algo_factory.h" -#include "algorithms/options/error/type.h" -#include "algorithms/options/names.h" #include "algorithms/pyro.h" #include "datasets.h" +#include "util/config/error/type.h" +#include "util/config/names.h" namespace tests { @@ -32,16 +32,14 @@ class KeysTest : public ::testing::TestWithParam {}; template static inline void GetKeysTestImpl(KeysTestParams const& p) { - namespace onam = algos::config::names; + namespace onam = util::config::names; auto path = test_data_dir / p.dataset; std::vector actual; - StdParamsMap params_map{ - {onam::kData, path}, - {onam::kSeparator, p.sep}, - {onam::kHasHeader, p.has_header}, - {onam::kSeed, decltype(Configuration::seed){0}}, - {onam::kError, algos::config::ErrorType{0.0}} - }; + StdParamsMap params_map{{onam::kData, path}, + {onam::kSeparator, p.sep}, + {onam::kHasHeader, p.has_header}, + {onam::kSeed, decltype(Configuration::seed){0}}, + {onam::kError, util::config::ErrorType{0.0}}}; auto pyro_ptr = algos::CreateAndLoadAlgorithm(params_map); auto &pyro = *pyro_ptr; diff --git a/tests/test_apriori.cpp b/tests/test_apriori.cpp index 473602bf60..d16a04118c 100644 --- a/tests/test_apriori.cpp +++ b/tests/test_apriori.cpp @@ -4,8 +4,8 @@ #include "algorithms/algo_factory.h" #include "algorithms/association_rules/apriori.h" -#include "algorithms/options/names.h" #include "datasets.h" +#include "util/config/names.h" namespace fs = std::filesystem; @@ -60,7 +60,7 @@ class ARAlgorithmTest : public ::testing::Test { unsigned int tidColumnIndex, unsigned int itemColumnIndex, char separator = ',', bool hasHeader = true) { - using namespace algos::config::names; + using namespace util::config::names; return {{kData, path}, {kSeparator, separator}, {kHasHeader, hasHeader}, @@ -74,7 +74,7 @@ class ARAlgorithmTest : public ::testing::Test { static algos::StdParamsMap GetParamMap(double minsup, double minconf, const std::filesystem::path& path, bool firstColumnTid, char separator = ',', bool hasHeader = true) { - using namespace algos::config::names; + using namespace util::config::names; return {{kData, path}, {kSeparator, separator}, {kHasHeader, hasHeader}, diff --git a/tests/test_data_stats.cpp b/tests/test_data_stats.cpp index 3288a6e9f9..bd237539f8 100644 --- a/tests/test_data_stats.cpp +++ b/tests/test_data_stats.cpp @@ -17,7 +17,7 @@ static algos::StdParamsMap GetParamMap(std::string_view dataset, char const sepa bool const has_header = true, bool const is_null_equal_null = true, ushort thread_num = 1) { - using namespace algos::config::names; + using namespace util::config::names; return {{kData, test_data_dir / dataset}, {kHasHeader, has_header}, {kSeparator, separator}, diff --git a/tests/test_fd_mine.cpp b/tests/test_fd_mine.cpp index 1b37e3453a..621c9cfba3 100644 --- a/tests/test_fd_mine.cpp +++ b/tests/test_fd_mine.cpp @@ -8,12 +8,12 @@ #include "algorithms/algo_factory.h" #include "algorithms/fd_mine.h" -#include "algorithms/options/error/type.h" -#include "algorithms/options/names.h" #include "algorithms/pyro.h" #include "algorithms/tane.h" #include "datasets.h" #include "model/relational_schema.h" +#include "util/config/error/type.h" +#include "util/config/names.h" using ::testing::ContainerEq, ::testing::Eq; @@ -21,7 +21,7 @@ using algos::FDAlgorithm, algos::Fd_mine, algos::StdParamsMap; using std::string, std::vector; -namespace onam = algos::config::names; +namespace onam = util::config::names; std::unique_ptr ConfToLoadFD_Mine() { std::unique_ptr algorithm = std::make_unique(); @@ -150,7 +150,7 @@ void MinimizeFDs(std::list& fd_collection) { } TEST_F(AlgorithmTest, FD_Mine_ReturnsSameAsPyro) { - namespace onam = algos::config::names; + namespace onam = util::config::names; try { for (size_t i = 0; i < LightDatasets::DatasetQuantity(); i++) { @@ -167,7 +167,7 @@ TEST_F(AlgorithmTest, FD_Mine_ReturnsSameAsPyro) { {onam::kSeparator, LightDatasets::Separator(i)}, {onam::kHasHeader, LightDatasets::HasHeader(i)}, {onam::kSeed, decltype(Configuration::seed){0}}, - {onam::kError, algos::config::ErrorType{0.0}}}; + {onam::kError, util::config::ErrorType{0.0}}}; auto pyro_ptr = algos::CreateAndLoadAlgorithm(params_map); auto& pyro = *pyro_ptr; diff --git a/tests/test_fd_verifier.cpp b/tests/test_fd_verifier.cpp index 6be5acad07..261f8d4375 100644 --- a/tests/test_fd_verifier.cpp +++ b/tests/test_fd_verifier.cpp @@ -6,10 +6,10 @@ #include "algorithms/algo_factory.h" #include "algorithms/fd_verifier/fd_verifier.h" -#include "algorithms/options/indices/type.h" #include "builtin.h" #include "datasets.h" #include "fd_verifier/stats_calculator.h" +#include "util/config/indices/type.h" namespace { using namespace algos::fd_verifier; @@ -47,7 +47,7 @@ void TestSorting(std::unique_ptr verifier) { } // namespace namespace tests { -namespace onam = algos::config::names; +namespace onam = util::config::names; struct FDVerifyingParams { algos::StdParamsMap params; @@ -55,8 +55,8 @@ struct FDVerifyingParams { size_t const num_error_clusters = 0; size_t const num_error_rows = 0; - FDVerifyingParams(algos::config::IndicesType lhs_indices, - algos::config::IndexType const rhs_index, size_t const num_error_clusters = 0, + FDVerifyingParams(util::config::IndicesType lhs_indices, + util::config::IndexType const rhs_index, size_t const num_error_clusters = 0, size_t const num_error_rows = 0, long double const error = 0., char const* dataset = "TestFD.csv", char const separator = ',', bool const has_header = true) diff --git a/tests/test_metric_verifier.cpp b/tests/test_metric_verifier.cpp index 445c40f32b..37e3e2e5e3 100644 --- a/tests/test_metric_verifier.cpp +++ b/tests/test_metric_verifier.cpp @@ -10,11 +10,11 @@ #include "algorithms/algo_factory.h" #include "algorithms/metric/enums.h" #include "algorithms/metric/metric_verifier.h" -#include "algorithms/options/names.h" #include "datasets.h" +#include "util/config/names.h" namespace tests { -namespace onam = algos::config::names; +namespace onam = util::config::names; struct MetricVerifyingParams { algos::StdParamsMap params; diff --git a/tests/test_typo_miner.cpp b/tests/test_typo_miner.cpp index 67a62fb616..e1cde9e4ae 100644 --- a/tests/test_typo_miner.cpp +++ b/tests/test_typo_miner.cpp @@ -5,12 +5,12 @@ #include #include "algorithms/algo_factory.h" -#include "algorithms/options/names.h" #include "algorithms/typo_miner.h" #include "datasets.h" +#include "util/config/names.h" namespace tests { -namespace onam = algos::config::names; +namespace onam = util::config::names; struct TestingParam { algos::StdParamsMap params; diff --git a/tests/testing_utils.h b/tests/testing_utils.h index 3ca0367ee9..dbb55f9ba2 100644 --- a/tests/testing_utils.h +++ b/tests/testing_utils.h @@ -6,9 +6,9 @@ #include "algorithms/algo_factory.h" #include "algorithms/fd_algorithm.h" -#include "algorithms/options/error/type.h" -#include "algorithms/options/names.h" #include "datasets.h" +#include "util/config/error/type.h" +#include "util/config/names.h" template class AlgorithmTest : public ::testing::Test { @@ -26,12 +26,12 @@ class AlgorithmTest : public ::testing::Test { algos::StdParamsMap GetParamMap(const std::filesystem::path& path, char separator = ',', bool has_header = true) { - using namespace algos::config::names; + using namespace util::config::names; return { {kData, path}, {kSeparator, separator}, {kHasHeader, has_header}, - {kError, algos::config::ErrorType{0.0}}, + {kError, util::config::ErrorType{0.0}}, {kSeed, decltype(Configuration::seed){0}}, }; }