Skip to content

Commit

Permalink
Use direct-list-initialization instead of aggregate initialization
Browse files Browse the repository at this point in the history
Aggregate initialization isn't availible on Apple Clang. Use direct-list-initialization
instead wherewer possible:
- Split::IndexSearchSpace
- MinPickerLattice::AddGeneralizations
- OneByOnePicker::AddGeneralizations
- md_lattice/Specializer
- MdLattice::GetAll
- hymd::LhsNode
-     ::BatchValidator
- SimilarityData::Creator
- BatchValidator::MultiCardPartitionElementProvider
- MD::GetDescription
- order::GetIndexedByteData
- python_bindings::BindOd
- model::DD

Define constructor elsewhere:
- test_algo_interfaces/KeysTestParams
- test_dc_verifier/DCTestParams
- test_ind_verifier/INDVerifierTestConfig
- test_pfdtane/PFDTaneValidationParams
- test_tane_afd_measures/TaneValidationParams
-                       /PdepSelfValidationParams
- test_typed_column_data/TypeParsingParams
  • Loading branch information
p-senichenkov committed Jan 13, 2025
1 parent f0a732c commit a39e86e
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 25 deletions.
10 changes: 5 additions & 5 deletions src/core/algorithms/dd/split/split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ std::vector<DFConstraint> Split::IndexSearchSpace(model::ColumnIndex index) {
// differential functions should be put in this exact order for further reducing
for (int i = num_dfs_per_column_ - 1; i >= 0; i--) {
if (min_max_dif_[index].IsWithinExclusive(i)) {
dfs.emplace_back(min_max_dif_[index].lower_bound, i);
dfs.push_back({min_max_dif_[index].lower_bound, static_cast<double>(i)});
}
}
return dfs;
Expand Down Expand Up @@ -616,7 +616,7 @@ std::list<DD> Split::NegativePruningReduce(DF const& rhs, std::vector<DF> const&
auto const [prune, remainder] = NegativeSplit(search, last_df);

std::list<DD> dds = NegativePruningReduce(rhs, prune, cnt);
if (dds.empty() && IsFeasible(last_df)) dds.emplace_back(last_df, rhs);
if (dds.empty() && IsFeasible(last_df)) dds.push_back({last_df, rhs});
std::list<DD> const remaining_dds = NegativePruningReduce(rhs, remainder, cnt);

std::list<DD> merged_dds = MergeReducedResults(dds, remaining_dds);
Expand All @@ -635,7 +635,7 @@ std::list<DD> Split::HybridPruningReduce(DF const& rhs, std::vector<DF> const& s

cnt++;
if (VerifyDD(first_df, rhs)) {
if (IsFeasible(first_df)) dds.emplace_back(first_df, rhs);
if (IsFeasible(first_df)) dds.push_back({first_df, rhs});
std::vector<DF> remainder = DoPositivePruning(search, first_df);
std::list<DD> remaining_dds = HybridPruningReduce(rhs, remainder, cnt);
dds.splice(dds.end(), remaining_dds);
Expand Down Expand Up @@ -685,7 +685,7 @@ std::list<DD> Split::InstanceExclusionReduce(std::vector<std::size_t> const& tup
}

if (no_pairs_left) {
if (IsFeasible(first_df)) dds.emplace_back(first_df, rhs);
if (IsFeasible(first_df)) dds.push_back({first_df, rhs});
std::vector<DF> remainder = DoPositivePruning(search, first_df);
std::list<DD> remaining_dds =
InstanceExclusionReduce(tuple_pair_indices, remainder, rhs, cnt);
Expand Down Expand Up @@ -749,7 +749,7 @@ model::DDString Split::DDToDDString(DD const& dd) const {
std::list<model::DDString> Split::GetDDStringList() const {
std::list<model::DDString> dd_strings;
for (auto const& result_dd : dd_collection_) {
dd_strings.emplace_back(DDToDDString(result_dd));
dd_strings.push_back(DDToDDString(result_dd));
}
return dd_strings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ void MinPickerLattice::AddGeneralizations(MdLattice::MdVerificationMessenger& me
if (considered_indices.none()) return;
}
RemoveSpecializations(root_, messenger, lhs.begin(), considered_indices);
ValidationInfo& added_ref = info_.emplace_back(&messenger, std::move(considered_indices));
Add(&added_ref);
info_.push_back({&messenger, std::move(considered_indices)});
Add(&info_.back());
}

std::vector<ValidationInfo> MinPickerLattice::GetAll() noexcept(kNeedsEmptyRemoval) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void OneByOnePicker::AddGeneralizations(MdLattice::MdVerificationMessenger& mess
}
}
assert(!considered_indices.none());
currently_picked_.emplace_back(&messenger, std::move(considered_indices));
currently_picked_.push_back({&messenger, std::move(considered_indices)});
}

std::vector<ValidationInfo> OneByOnePicker::GetAll() noexcept {
Expand Down
7 changes: 4 additions & 3 deletions src/core/algorithms/md/hymd/lattice/md_lattice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ class Specializer {
get_lhs_ccv_id_(std::move(get_lhs_ccv_id)),
get_nonlhs_ccv_id_(std::move(get_nonlhs_ccv_id)),
prune_nondisjoint_(prune_nondisjoint),
current_specialization_({lhs, {lhs.begin(), {}}}, rhs) {}
current_specialization_(
{LhsSpecialization{lhs, SpecializationData{lhs.begin(), LhsNode{}}}, rhs}) {}

void Specialize() {
if (GetLhs().Cardinality() == cardinality_limit_) {
Expand Down Expand Up @@ -674,7 +675,7 @@ void MdLattice::TryDeleteEmptyNode(MdLhs const& lhs) {
} else {
DESBORDANTE_ASSUME(it != map.end());
}
path_to_node.emplace_back(cur_node_ptr, &map, it);
path_to_node.push_back({cur_node_ptr, &map, it});
cur_node_ptr = &it->second;
}

Expand Down Expand Up @@ -875,7 +876,7 @@ std::vector<MdLatticeNodeInfo> MdLattice::GetAll() {
std::vector<MdLatticeNodeInfo> collected;
MdLhs current_lhs(column_matches_size_);
GetAll(md_root_, current_lhs, [&collected](MdLhs& cur_node_lhs, MdNode& cur_node) {
collected.emplace_back(cur_node_lhs, &cur_node);
collected.push_back({cur_node_lhs, &cur_node});
});
assert(std::ranges::none_of(collected, [this](MdLatticeNodeInfo const& node_info) {
return IsUnsupported(node_info.lhs);
Expand Down
5 changes: 3 additions & 2 deletions src/core/algorithms/md/hymd/md_lhs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace algos::hymd {
struct LhsNode {
model::Index offset;
ColumnClassifierValueId ccv_id;
ColumnClassifierValueId ccv_id = 0;

friend bool operator==(LhsNode const& l, LhsNode const& r) {
return l.offset == r.offset && l.ccv_id == r.ccv_id;
Expand All @@ -34,7 +34,8 @@ class MdLhs {
}

ColumnClassifierValueId& AddNext(model::Index offset) {
return values_.emplace_back(offset).ccv_id;
values_.push_back({offset});
return values_.back().ccv_id;
}

void RemoveLast() {
Expand Down
2 changes: 1 addition & 1 deletion src/core/algorithms/md/hymd/similarity_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SimilarityData::Creator {
column_match_index);
} else {
non_trivial_indices.push_back(column_match_index);
column_matches_info.emplace_back(std::move(indexes), left_col_index, right_col_index);
column_matches_info.push_back({std::move(indexes), left_col_index, right_col_index});
all_lhs_ccv_ids_info.push_back(std::move(lhs_ccv_id_info));
short_sampling_enable.push_back(column_match->IsSymmetricalAndEqIsMax());
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/algorithms/md/hymd/validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ class BatchValidator::MultiCardPartitionElementProvider {
kSLTVPartitionColumn;
// LHS has cardinality greater than 1, so is not empty.
DESBORDANTE_ASSUME(lhs_iter_ != lhs_end_);
rhs_records_matching_criteria_.emplace_back(cur_col_match_index_, kSLTVPartitionColumn,
lhs_iter_->ccv_id);
rhs_records_matching_criteria_.push_back(
{cur_col_match_index_, kSLTVPartitionColumn, lhs_iter_->ccv_id});
++cur_col_match_index_;
++lhs_iter_;
}
Expand All @@ -333,8 +333,8 @@ class BatchValidator::MultiCardPartitionElementProvider {
sltvpe_partition_key_.push_back(left_column_index);
}

rhs_records_matching_criteria_.emplace_back(cur_col_match_index_,
partition_key_index, ccv_id);
rhs_records_matching_criteria_.push_back(
{cur_col_match_index_, partition_key_index, ccv_id});
++cur_col_match_index_;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/algorithms/md/hymd/validator.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ class BatchValidator {
void AddRecommendations(RecordCluster const& same_left_value_records,
CompressedRecord const& right_record) {
for (RecPtr left_record_ptr : same_left_value_records) {
recommendations_->emplace_back(left_record_ptr, &right_record);
recommendations_->push_back({left_record_ptr, &right_record});
}
}

void RhsIsInvalid(RecordCluster const& same_left_value_records,
CompressedRecord const& right_record) {
current_ccv_id_ = kLowestCCValueId;
for (RecPtr left_record_ptr : same_left_value_records) {
recommendations_->emplace_back(left_record_ptr, &right_record);
recommendations_->push_back({left_record_ptr, &right_record});
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/algorithms/md/md.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ MDDescription MD::GetDescription() const {
std::vector<LhsSimilarityClassifierDesctription> lhs_description =
util::GetPreallocatedVector<LhsSimilarityClassifierDesctription>(lhs_.size());
for (md::LhsColumnSimilarityClassifier const& lhs_classifier : lhs_) {
lhs_description.emplace_back(
GetColumnMatchDescription(lhs_classifier.GetColumnMatchIndex()),
lhs_classifier.GetDecisionBoundary(), lhs_classifier.GetMaxDisprovedBound());
lhs_description.push_back({GetColumnMatchDescription(lhs_classifier.GetColumnMatchIndex()),
lhs_classifier.GetDecisionBoundary(),
lhs_classifier.GetMaxDisprovedBound()});
}
return {left_schema_->GetName(),
right_schema_->GetName(),
Expand Down
2 changes: 1 addition & 1 deletion src/core/algorithms/od/order/order_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ std::vector<IndexedByteData> GetIndexedByteData(
if (null_rows.find(k) != null_rows.end()) {
continue;
}
indexed_byte_data.emplace_back(k, byte_data[k]);
indexed_byte_data.push_back({k, byte_data[k]});
}
return indexed_byte_data;
}
Expand Down
2 changes: 1 addition & 1 deletion src/python_bindings/od/bind_od.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void BindOd(py::module_& main_module) {
std::vector<ListOD> res;
for (auto const& [lhs, rhs_list] : map_res) {
for (AttributeList const& rhs : rhs_list) {
res.emplace_back(lhs, rhs);
res.push_back({lhs, rhs});
}
}
return res;
Expand Down
3 changes: 3 additions & 0 deletions src/tests/test_algo_interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ namespace tests {
struct KeysTestParams {
std::vector<unsigned int> const expected;
CSVConfig const& csv_config;

KeysTestParams(std::vector<unsigned int>&& expected, CSVConfig const& csv_config)
: expected(expected), csv_config(csv_config) {}
};

class KeysTest : public ::testing::TestWithParam<KeysTestParams> {};
Expand Down
3 changes: 3 additions & 0 deletions src/tests/test_dc_verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ struct DCTestParams {
std::string dc_string;
CSVConfig csv_config;
bool expected;

DCTestParams(std::string&& dc_string, CSVConfig const& csv_config, bool expected)
: dc_string(dc_string), csv_config(csv_config), expected(expected) {}
};

class TestDCVerifier : public ::testing::TestWithParam<DCTestParams> {};
Expand Down
4 changes: 4 additions & 0 deletions src/tests/test_ind_verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ struct INDVerifierTestConfig {
algos::INDVerifier::RawIND ind;
/* `std::nullopt` iff IND holds */
std::optional<INDVerifierErrorInfo> error_opt{};

INDVerifierTestConfig(CSVConfigs const& csv_configs, algos::INDVerifier::RawIND&& ind,
std::optional<INDVerifierErrorInfo>&& error_opt = {})
: csv_configs(csv_configs), ind(std::move(ind)), error_opt(error_opt) {}
};

namespace {
Expand Down
4 changes: 4 additions & 0 deletions src/tests/test_pfdtane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ struct PFDTaneValidationParams {
std::vector<PFD> fds;
algos::PfdErrorMeasure error_measure;
CSVConfig csv_config;

PFDTaneValidationParams(std::vector<PFD>&& fds, algos::PfdErrorMeasure const& error_measure,
CSVConfig const& csv_config)
: fds(fds), error_measure(error_measure), csv_config(csv_config) {}
};

class TestPFDTaneMining : public ::testing::TestWithParam<PFDTaneMiningParams> {};
Expand Down
7 changes: 7 additions & 0 deletions src/tests/test_tane_afd_measures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ struct TaneValidationParams {
algos::AfdErrorMeasure error_measure;
std::vector<AFD> afds;
CSVConfig csv_config;

TaneValidationParams(algos::AfdErrorMeasure error_measure, std::vector<AFD>&& afds,
CSVConfig const& csv_config)
: error_measure(error_measure), afds(afds), csv_config(csv_config) {}
};

struct ColumnErr {
Expand All @@ -47,6 +51,9 @@ struct ColumnErr {
struct PdepSelfValidationParams {
std::vector<ColumnErr> errors;
CSVConfig csv_config;

PdepSelfValidationParams(std::vector<ColumnErr>&& errors, CSVConfig const& csv_config)
: errors(errors), csv_config(csv_config) {}
};

class TestTanePdepSelfValidation : public ::testing::TestWithParam<PdepSelfValidationParams> {};
Expand Down
3 changes: 3 additions & 0 deletions src/tests/test_typed_column_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ using mo::TypeId;
struct TypeParsingParams {
std::vector<mo::TypeId> expected;
CSVConfig const& csv_config;

TypeParsingParams(std::vector<mo::TypeId>&& expected, CSVConfig const& csv_config)
: expected(std::move(expected)), csv_config(csv_config) {}
};

class TestTypeParsing : public ::testing::TestWithParam<TypeParsingParams> {};
Expand Down

0 comments on commit a39e86e

Please sign in to comment.