From eb9b0e90fd8fbd0320cdef01e54a89d906f4110d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Sun, 8 Oct 2023 11:44:13 -0400 Subject: [PATCH 1/6] Generalise 'bdd_restrict' API to use Generators and Iterators --- docs/example/queens.md | 16 +- example/queens.cpp | 16 +- src/adiar/CMakeLists.txt | 2 +- src/adiar/assignment.h | 20 -- src/adiar/bdd.h | 57 ++++- src/adiar/bdd/restrict.cpp | 64 +++--- src/adiar/functional.h | 34 ++- src/adiar/internal/algorithms/substitution.h | 2 +- src/adiar/types.h | 44 ++++ test/adiar/bdd/test_restrict.cpp | 221 ++++++------------- 10 files changed, 233 insertions(+), 243 deletions(-) delete mode 100644 src/adiar/assignment.h create mode 100644 src/adiar/types.h diff --git a/docs/example/queens.md b/docs/example/queens.md index f5d855cf5..928921bcc 100644 --- a/docs/example/queens.md +++ b/docs/example/queens.md @@ -218,21 +218,15 @@ uint64_t n_queens_list(uint64_t N, uint64_t column, partial_assignment.push_back(row_q); // Construct the assignment for this entire column - adiar::assignment_file column_assignment; + std::vector> column_assignment; - { // The assignment_writer has to be detached, before we call any - // bdd functions. It is automatically detached upon destruction, - // hence we have it in this little scope. - adiar::file_writer> aw(column_assignment); - - for (uint64_t row = 0; row < N; row++) { - aw << assignment(label_of_position(N, row, column), - row == row_q); - } + for (uint64_t row = 0; row < N; row++) { + column_assignment.push_back({label_of_position(N, row, column), row == row_q}); } adiar::bdd restricted_constraints = adiar::bdd_restrict(constraints, - column_assignment); + column_assignment.begin(), + column_assignment.end()); if (adiar::bdd_pathcount(restricted_constraints) == 1) { solutions += 1; diff --git a/example/queens.cpp b/example/queens.cpp index 22b20147e..cf691c065 100644 --- a/example/queens.cpp +++ b/example/queens.cpp @@ -248,19 +248,15 @@ uint64_t n_queens_list(uint64_t N, uint64_t column, partial_assignment.push_back(row_q); // Construct the assignment for this entire column - adiar::shared_file> column_assignment; + std::vector> column_assignment; - { // The assignment_writer has to be detached, before we call any bdd - // functions. It is automatically detached upon destruction, hence we have - // it in this little scope. - adiar::file_writer> aw(column_assignment); - - for (uint64_t row = 0; row < N; row++) { - aw << adiar::map_pair(label_of_position(N, row, column), row == row_q); - } + for (uint64_t row = 0; row < N; row++) { + column_assignment.push_back({label_of_position(N, row, column), row == row_q}); } - adiar::bdd restricted_constraints = adiar::bdd_restrict(constraints, column_assignment); + adiar::bdd restricted_constraints = adiar::bdd_restrict(constraints, + column_assignment.begin(), + column_assignment.end()); if (adiar::bdd_pathcount(restricted_constraints) == 1) { solutions += 1; diff --git a/src/adiar/CMakeLists.txt b/src/adiar/CMakeLists.txt index 7aeeb2714..a4cc868fc 100644 --- a/src/adiar/CMakeLists.txt +++ b/src/adiar/CMakeLists.txt @@ -6,7 +6,6 @@ set_property(GLOBAL PROPERTY USE_FOLDERS On) set(HEADERS # adiar adiar.h - assignment.h bool_op.h builder.h deprecated.h @@ -17,6 +16,7 @@ set(HEADERS functional.h map.h statistics.h + types.h # adiar/bdd bdd.h diff --git a/src/adiar/assignment.h b/src/adiar/assignment.h deleted file mode 100644 index 1fd4f8528..000000000 --- a/src/adiar/assignment.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef ADIAR_ASSIGNMENT_H -#define ADIAR_ASSIGNMENT_H - -#include -#include - -namespace adiar -{ - ////////////////////////////////////////////////////////////////////////////// - /// \brief Possible values to assign a variable. - ////////////////////////////////////////////////////////////////////////////// - enum class assignment : char - { - False = 0, // false - True = 1, // true - None = -1 - }; -} - -#endif // ADIAR_ASSIGNMENT_H diff --git a/src/adiar/bdd.h b/src/adiar/bdd.h index 3b5c4f7d7..65e48cb90 100644 --- a/src/adiar/bdd.h +++ b/src/adiar/bdd.h @@ -17,11 +17,13 @@ #include #include -#include #include #include -#include // <-- TODO: Remove #include +#include + +#include // <-- TODO: remove! +#include // <-- TODO: remove! #include #include @@ -456,10 +458,24 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// __bdd bdd_ite(const exec_policy &ep, const bdd &f, const bdd &g, const bdd &h); + /// \cond + ////////////////////////////////////////////////////////////////////////////// + /// \brief End marker for the BDD restrict generators. + ////////////////////////////////////////////////////////////////////////////// + template<> + struct generator_end> + { + using value_type = pair; + + static constexpr value_type value = + make_pair(static_cast(-1), false); + }; + /// \endcond + ////////////////////////////////////////////////////////////////////////////// /// \brief Restrict a subset of variables to constant values. /// - /// \details For each tuple (i,v) in the assignment `xs` the variable + /// \details For each tuple (i,v) in the assignment `xs`, the variable /// with label i is set to the constant value v. This binds the /// scope of the variables in `xs`, i.e. any later mention of /// a variable i is not the same as variable i in `xs`. @@ -470,17 +486,44 @@ namespace adiar /// /// \returns \f$ f|_{(i,v) \in xs : x_i = v} \f$ ////////////////////////////////////////////////////////////////////////////// - // TODO v2.0 : Replace with `generator>`. __bdd bdd_restrict(const bdd &f, - const shared_file> &xs); + const generator> &xs); ////////////////////////////////////////////////////////////////////////////// /// \brief Restrict a subset of variables to constant values. ////////////////////////////////////////////////////////////////////////////// - // TODO v2.0 : Replace with `generator>`. __bdd bdd_restrict(const exec_policy &ep, const bdd &f, - const shared_file> &xs); + const generator> &xs); + + ////////////////////////////////////////////////////////////////////////////// + /// \brief Restrict a subset of variables to constant values. + /// + /// \details For each tuple (i,v) provided by the iterator, the variable + /// with label i is set to the constant value v. + /// + /// \param f BDD to restrict + /// + /// \param begin Single-pass forward iterator that provides the to-be + /// restricted variables in \em ascending order. + /// + /// \param end Marks the end for `begin`. + /// + /// \returns \f$ f|_{(i,v) \in xs : x_i = v} \f$ + ////////////////////////////////////////////////////////////////////////////// + template + __bdd bdd_restrict(const bdd& f, ForwardIt begin, ForwardIt end) + { return bdd_restrict(f, make_generator(begin, end)); } + + ////////////////////////////////////////////////////////////////////////////// + /// \brief Restrict a subset of variables to constant values. + ////////////////////////////////////////////////////////////////////////////// + template + __bdd bdd_restrict(const exec_policy &ep, + const bdd& f, + ForwardIt begin, + ForwardIt end) + { return bdd_restrict(ep, f, make_generator(begin, end)); } ////////////////////////////////////////////////////////////////////////////// /// \brief Existential quantification of a single variable. diff --git a/src/adiar/bdd/restrict.cpp b/src/adiar/bdd/restrict.cpp index c446ca779..d08c387bf 100644 --- a/src/adiar/bdd/restrict.cpp +++ b/src/adiar/bdd/restrict.cpp @@ -1,7 +1,6 @@ #include #include -#include #include #include #include @@ -10,71 +9,72 @@ namespace adiar { - class substitute_assignment_file_mgr + class restrict_generator_mgr { - file_stream> mps; - map_pair mp; + const generator> &_generator; + pair _next_pair; public: - substitute_assignment_file_mgr(const shared_file> &mpf) - : mps(mpf) + restrict_generator_mgr(const generator> &g) + : _generator(g) { - mp = mps.pull(); + _next_pair = _generator(); } - assignment assignment_for_level(bdd::label_type level) { - while (mp.level() < level && mps.can_pull()) { - mp = mps.pull(); - } + bool empty() const + { + return bdd::max_label < _next_pair.first; + } - return mp.level() == level ? mp.value() : assignment::None; + assignment assignment_for_level(bdd::label_type level) + { + while (_next_pair.first < level) { + _next_pair = _generator(); + } + return _next_pair.first == level + ? static_cast(_next_pair.second) + : assignment::None; } }; ////////////////////////////////////////////////////////////////////////////// - // TODO: template on manager? class bdd_restrict_policy : public bdd_policy { public: - static internal::substitute_rec keep_node(const bdd::node_type &n, substitute_assignment_file_mgr &/*amgr*/) + template + static internal::substitute_rec keep_node(const bdd::node_type &n, AssignmentMgr &/*amgr*/) { return internal::substitute_rec_output { n }; } - static internal::substitute_rec fix_false(const bdd::node_type &n, substitute_assignment_file_mgr &/*amgr*/) + template + static internal::substitute_rec fix_false(const bdd::node_type &n, AssignmentMgr &/*amgr*/) { return internal::substitute_rec_skipto { n.low() }; } - static internal::substitute_rec fix_true(const bdd::node_type &n, substitute_assignment_file_mgr &/*amgr*/) + template + static internal::substitute_rec fix_true(const bdd::node_type &n, AssignmentMgr &/*amgr*/) { return internal::substitute_rec_skipto { n.high() }; } public: - static inline bdd terminal(bool terminal_val, substitute_assignment_file_mgr &/*amgr*/) + template + static inline bdd terminal(bool terminal_val, AssignmentMgr &/*amgr*/) { return bdd_terminal(terminal_val); } }; ////////////////////////////////////////////////////////////////////////////// - template<> - struct internal::level_stream_t>> - { - template - using stream_t = internal::file_stream>; - }; - __bdd bdd_restrict(const exec_policy &ep, const bdd &f, - const shared_file> &a) + const generator> &xs) { - if (a->size() == 0 - || bdd_isterminal(f) - || internal::disjoint_levels(a, f)) { + restrict_generator_mgr amgr(xs); + + if (amgr.empty() || bdd_isterminal(f)) { return f; } - - substitute_assignment_file_mgr amgr(a); return internal::substitute(ep, f, amgr); } __bdd bdd_restrict(const bdd &f, - const shared_file> &a) + const generator> &xs) { - return bdd_restrict(exec_policy(), f, a); + return bdd_restrict(exec_policy(), f, xs); } } diff --git a/src/adiar/functional.h b/src/adiar/functional.h index 2dd2d77bb..61e9da364 100644 --- a/src/adiar/functional.h +++ b/src/adiar/functional.h @@ -2,6 +2,7 @@ #define ADIAR_FUNCTIONAL_H #include +#include #include @@ -32,8 +33,8 @@ namespace adiar /// /// \tparam ret_type The type signature of the form `ret_t (args_t...)`. ////////////////////////////////////////////////////////////////////////////// - template - using function = std::function; + template + using function = std::function; ////////////////////////////////////////////////////////////////////////////// /// \brief Predicate function given value(s) of the `Args`. @@ -76,9 +77,6 @@ namespace adiar }; } - // TODO: Use template specialization to simplify the use of an end value, i.e. - // `generator::end` or `generator_end::value`. - ////////////////////////////////////////////////////////////////////////////// /// \brief Generator function that *produces* a new value of `ret_type` for /// each call. @@ -89,8 +87,25 @@ namespace adiar /// /// \tparam ret_type Type of each yielded value from the generator. ////////////////////////////////////////////////////////////////////////////// - template - using generator = function; + template + using generator = function; + + ////////////////////////////////////////////////////////////////////////////// + /// \brief Template specialization to derive the `end` (similar to `EOF`) + /// return-value for a generator function. + /// + /// \details By default, we provide the integer implementation of -1. + ////////////////////////////////////////////////////////////////////////////// + template + struct generator_end + { + using value_type = RetType; + + static_assert(std::is_integral::value); + static constexpr value_type value = static_cast(-1); + }; + + // TODO: Specialize for DDs (Both BDDs and ZDDs) to return an empty file. //////////////////////////////////////////////////////////////////////////// /// \brief Wrap a `begin` and `end` iterator pair into a generator function. @@ -101,8 +116,7 @@ namespace adiar { return [&begin, &end]() { if (begin == end) { - // TODO (DD Iterators): change return value depending on `value_type`. - return static_cast(-1); + return generator_end::value; } return *(begin++); }; @@ -117,7 +131,7 @@ namespace adiar { return [&s]() { if (!s.can_pull()) { - return static_cast(-1); + return generator_end::value; } return s.pull(); }; diff --git a/src/adiar/internal/algorithms/substitution.h b/src/adiar/internal/algorithms/substitution.h index cee62cb3a..11f1e18b6 100644 --- a/src/adiar/internal/algorithms/substitution.h +++ b/src/adiar/internal/algorithms/substitution.h @@ -3,8 +3,8 @@ #include -#include #include +#include #include #include diff --git a/src/adiar/types.h b/src/adiar/types.h new file mode 100644 index 000000000..1e00d3b49 --- /dev/null +++ b/src/adiar/types.h @@ -0,0 +1,44 @@ +#ifndef ADIAR_TYPES_H +#define ADIAR_TYPES_H + +#include +//#include + +namespace adiar +{ + ////////////////////////////////////////////////////////////////////////////// + /// \brief Possible values to assign a variable. + ////////////////////////////////////////////////////////////////////////////// + enum class assignment : char + { + False = 0, // false + True = 1, // true + None = -1 // TODO: change into '2'? + }; + + ////////////////////////////////////////////////////////////////////////////// + /// \brief A pair of values. + ////////////////////////////////////////////////////////////////////////////// + template + using pair = std::pair; + + ////////////////////////////////////////////////////////////////////////////// + /// \brief Create an `adiar::pair`, deducing the target type based on the + /// types of the arguments. + ////////////////////////////////////////////////////////////////////////////// + template + constexpr pair + make_pair(const T1 &t1, const T2 &t2) + { return std::make_pair(t1, t2); } + + ////////////////////////////////////////////////////////////////////////////// + /// \brief Create an `adiar::pair`, deducing the target type based on the + /// types of the arguments. + ////////////////////////////////////////////////////////////////////////////// + template + constexpr pair + make_pair(T1 &&t1, T2 &&t2) + { return std::make_pair(std::move(t1), std::move(t2)); } +} + +#endif // ADIAR_TYPES_H diff --git a/test/adiar/bdd/test_restrict.cpp b/test/adiar/bdd/test_restrict.cpp index 21f9bad6f..c9e39bbb0 100644 --- a/test/adiar/bdd/test_restrict.cpp +++ b/test/adiar/bdd/test_restrict.cpp @@ -23,11 +23,31 @@ go_bandit([]() { node n2 = node(1,0, n3.uid(), n4.uid()); node n1 = node(0,0, n3.uid(), n2.uid()); - shared_levelized_file bdd; + shared_levelized_file bdd_1; { // Garbage collect writer to free write-lock - node_writer bdd_w(bdd); - bdd_w << n5 << n4 << n3 << n2 << n1; + node_writer w(bdd_1); + w << n5 << n4 << n3 << n2 << n1; + } + + /* + // F + */ + shared_levelized_file bdd_F; + + { // Garbage collect writer to free write-lock + node_writer w(bdd_F); + w << node(false); + } + + /* + // T + */ + shared_levelized_file bdd_T; + + { // Garbage collect writer to free write-lock + node_writer w(bdd_T); + w << node(true); } it("should bridge level [1] Assignment: (_,_,T,_)", [&]() { @@ -43,14 +63,9 @@ go_bandit([]() { // F T */ - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(2, true); - } + std::vector> ass = { {2, true} }; - __bdd out = bdd_restrict(bdd, ass); + __bdd out = bdd_restrict(exec_policy(), bdd_1, ass.begin(), ass.end()); arc_test_stream arcs(out); @@ -104,14 +119,9 @@ go_bandit([]() { // F T */ - adiar::shared_file> ass; + std::vector> ass = { {1, false} }; - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(1, false); - } - - __bdd out = bdd_restrict(bdd, ass); + __bdd out = bdd_restrict(bdd_1, ass.begin(), ass.end()); arc_test_stream arcs(out); @@ -158,14 +168,9 @@ go_bandit([]() { // F T */ - adiar::shared_file> ass; + std::vector> ass = { {1,true} }; - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(1, true); - } - - __bdd out = bdd_restrict(bdd, ass); + __bdd out = bdd_restrict(bdd_1, ass.begin(), ass.end()); arc_test_stream arcs(out); @@ -224,15 +229,9 @@ go_bandit([]() { // F T T F */ - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(0, true) - << map_pair(3, false); - } + std::vector> ass = { {0,true}, {3,false} }; - __bdd out = bdd_restrict(bdd, ass); + __bdd out = bdd_restrict(bdd_1, ass.begin(), ass.end()); arc_test_stream arcs(out); @@ -279,16 +278,9 @@ go_bandit([]() { // F T */ - adiar::shared_file> ass; + std::vector> ass = { {0,false}, {1,true}, {3,false} }; - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(0, false) - << map_pair(1, true) - << map_pair(3, false); - } - - __bdd out = bdd_restrict(bdd, ass); + __bdd out = bdd_restrict(bdd_1, ass.begin(), ass.end()); arc_test_stream arcs(out); @@ -314,15 +306,9 @@ go_bandit([]() { }); it("should return F terminal. Assignment: (F,_,F,_)", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(0, false) - << map_pair(2, false); - } + std::vector> ass = { {0,false}, {2,false} }; - __bdd out = bdd_restrict(bdd, ass); + __bdd out = bdd_restrict(bdd_1, ass.begin(), ass.end()); node_test_stream out_nodes(out); @@ -343,16 +329,9 @@ go_bandit([]() { }); it("should return T terminal. Assignment: (T,T,F,_)", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(0, true) - << map_pair(1, true) - << map_pair(2, false); - } + std::vector> ass = { {0,true}, {1,true}, {2,false} }; - __bdd out = bdd_restrict(bdd, ass); + __bdd out = bdd_restrict(bdd_1, ass.begin(), ass.end()); node_test_stream out_nodes(out); @@ -373,73 +352,38 @@ go_bandit([]() { }); it("should return input unchanged when given a T terminal", [&]() { - shared_levelized_file T_file; - - { // Garbage collect writer to free write-lock - node_writer Tw(T_file); - Tw << node(true); - } + std::vector> ass = { {0,true}, {2,true}, {42,false} }; - adiar::shared_file> ass; + __bdd out = bdd_restrict(bdd_T, ass.begin(), ass.end()); - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(0, true) - << map_pair(2, true) - << map_pair(42, false); - } - - __bdd out = bdd_restrict(T_file, ass); - - AssertThat(out.get>(), Is().EqualTo(T_file)); + AssertThat(out.get>(), Is().EqualTo(bdd_T)); AssertThat(out.negate, Is().False()); }); it("should return input unchanged when given a F terminal", [&]() { - shared_levelized_file F_file; + std::vector> ass { {2,true}, {21,true}, {28,false} }; - { // Garbage collect writer to free write-lock - node_writer Fw(F_file); - Fw << node(false); - } + __bdd out = bdd_restrict(bdd_F, ass.begin(), ass.end()); - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(2, true) - << map_pair(21, true) - << map_pair(28, false); - } - - __bdd out = bdd_restrict(F_file, ass); - - AssertThat(out.get>(), Is().EqualTo(F_file)); + AssertThat(out.get>(), Is().EqualTo(bdd_F)); AssertThat(out.negate, Is().False()); }); it("should return input unchanged when given an empty assignment", [&]() { - adiar::shared_file> ass; + std::vector> ass; - __bdd out = bdd_restrict(bdd, ass); + __bdd out = bdd_restrict(bdd_1, ass.begin(), ass.end()); - AssertThat(out.get>(), Is().EqualTo(bdd)); + AssertThat(out.get>(), Is().EqualTo(bdd_1)); AssertThat(out.negate, Is().False()); }); - it("should return input unchanged when assignment that is disjoint of its live variables", [&]() { - adiar::shared_file> ass; - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(5, false) - << map_pair(6, true) - << map_pair(7, true) - ; - } + it("should return input unchanged if assignment is disjoint of its variables", [&]() { + std::vector> ass = { {5,false}, {6,true}, {7,true} }; - __bdd out = bdd_restrict(bdd, ass); + __bdd out = bdd_restrict(bdd_1, ass.begin(), ass.end()); - AssertThat(out.get>(), Is().EqualTo(bdd)); + AssertThat(out.get>(), Is().EqualTo(bdd_1)); AssertThat(out.negate, Is().False()); }); @@ -456,7 +400,7 @@ go_bandit([]() { ptr_uint64 terminal_T = ptr_uint64(true); ptr_uint64 terminal_F = ptr_uint64(false); - shared_levelized_file node_input; + shared_levelized_file in; node n4 = node(2,0, terminal_T, terminal_F); node n3 = node(1,1, terminal_T, terminal_F); @@ -464,18 +408,13 @@ go_bandit([]() { node n1 = node(0,0, n2.uid(), n3.uid()); { // Garbage collect writer to free write-lock - node_writer inw(node_input); + node_writer inw(in); inw << n4 << n3 << n2 << n1; } - adiar::shared_file> ass; + std::vector> ass = { {2,true} }; - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(2, true); - } - - __bdd out = bdd_restrict(node_input, ass); + __bdd out = bdd_restrict(in, ass.begin(), ass.end()); arc_test_stream arcs(out); @@ -530,7 +469,7 @@ go_bandit([]() { ptr_uint64 terminal_T = ptr_uint64(true); ptr_uint64 terminal_F = ptr_uint64(false); - shared_levelized_file node_input; + shared_levelized_file in; node n5 = node(2,1, terminal_F, terminal_T); node n4 = node(2,0, terminal_T, terminal_F); @@ -539,18 +478,13 @@ go_bandit([]() { node n1 = node(0,0, n2.uid(), n3.uid()); { // Garbage collect writer to free write-lock - node_writer inw(node_input); + node_writer inw(in); inw << n5 << n4 << n3 << n2 << n1; } - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(2, true); - } + std::vector> ass = { {2,true} }; - __bdd out = bdd_restrict(node_input, ass); + __bdd out = bdd_restrict(in, ass.begin(), ass.end()); arc_test_stream arcs(out); @@ -607,7 +541,7 @@ go_bandit([]() { // Here, node 4 and 6 are going to be dead, when x1 -> T. */ - shared_levelized_file dead_bdd; + shared_levelized_file in; node n9 = node(3,1, terminal_T, terminal_F); node n8 = node(3,0, terminal_F, terminal_T); @@ -620,18 +554,13 @@ go_bandit([]() { node n1 = node(0,0, n2.uid(), n3.uid()); { // Garbage collect writer to free write-lock - node_writer dead_w(dead_bdd); + node_writer dead_w(in); dead_w << n9 << n8 << n7 << n6 << n5 << n4 << n3 << n2 << n1; } - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(1, true); - } + std::vector> ass = { {1,true} }; - __bdd out = bdd_restrict(dead_bdd, ass); + __bdd out = bdd_restrict(in, ass.begin(), ass.end()); arc_test_stream arcs(out); @@ -689,24 +618,19 @@ go_bandit([]() { }); it("should return terminal-child of restricted root [assignment = T]", [&]() { - shared_levelized_file terminal_child_of_root_bdd; + shared_levelized_file in; node n2 = node(2, node::max_id, terminal_T, terminal_T); node n1 = node(1, node::max_id, n2.uid(), terminal_F); { // Garbage collect writer to free write-lock - node_writer dead_w(terminal_child_of_root_bdd); + node_writer dead_w(in); dead_w << n2 << n1; } - adiar::shared_file> ass; + std::vector> ass = { {1,true} }; - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(1, true); - } - - __bdd out = bdd_restrict(terminal_child_of_root_bdd, ass); + __bdd out = bdd_restrict(in, ass.begin(), ass.end()); node_test_stream out_nodes(out); @@ -727,24 +651,19 @@ go_bandit([]() { }); it("should return terminal-child of restricted root [assignment = F]", [&]() { - shared_levelized_file terminal_child_of_root_bdd; + shared_levelized_file in; node n2 = node(2, node::max_id, terminal_T, terminal_T); node n1 = node(0, node::max_id, terminal_T, n2.uid()); { // Garbage collect writer to free write-lock - node_writer dead_w(terminal_child_of_root_bdd); + node_writer dead_w(in); dead_w << n2 << n1; } - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - aw << map_pair(0, false); - } + std::vector> ass = { {0,false} }; - __bdd out = bdd_restrict(terminal_child_of_root_bdd, ass); + __bdd out = bdd_restrict(in, ass.begin(), ass.end()); node_test_stream out_nodes(out); From 1b0efa388c5e3a5a26c0379452844ab70c75c11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Sun, 8 Oct 2023 12:08:53 -0400 Subject: [PATCH 2/6] Generalise 'bdd_eval' API to use Generators and Iterators --- src/adiar/bdd.h | 59 +++--- src/adiar/bdd/evaluate.cpp | 36 ++-- test/adiar/bdd/test_evaluate.cpp | 297 ++++++++++++------------------- 3 files changed, 173 insertions(+), 219 deletions(-) diff --git a/src/adiar/bdd.h b/src/adiar/bdd.h index 65e48cb90..81fa77506 100644 --- a/src/adiar/bdd.h +++ b/src/adiar/bdd.h @@ -35,6 +35,20 @@ namespace adiar /// /// \{ + /// \cond + ////////////////////////////////////////////////////////////////////////////// + /// \brief End marker for the BDD assignment generators. + ////////////////////////////////////////////////////////////////////////////// + template<> + struct generator_end> + { + using value_type = pair; + + static constexpr value_type value = + make_pair(static_cast(-1), false); + }; + /// \endcond + ////////////////////////////////////////////////////////////////////////////// /// \name Basic BDD Constructors /// @@ -458,20 +472,6 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// __bdd bdd_ite(const exec_policy &ep, const bdd &f, const bdd &g, const bdd &h); - /// \cond - ////////////////////////////////////////////////////////////////////////////// - /// \brief End marker for the BDD restrict generators. - ////////////////////////////////////////////////////////////////////////////// - template<> - struct generator_end> - { - using value_type = pair; - - static constexpr value_type value = - make_pair(static_cast(-1), false); - }; - /// \endcond - ////////////////////////////////////////////////////////////////////////////// /// \brief Restrict a subset of variables to constant values. /// @@ -480,9 +480,9 @@ namespace adiar /// scope of the variables in `xs`, i.e. any later mention of /// a variable i is not the same as variable i in `xs`. /// - /// \param f BDD to restrict + /// \param f BDD to restrict. /// - /// \param xs Assignments (i,v) to variables in (in ascending order) + /// \param xs Assignments (i,v) to variables in (in ascending order). /// /// \returns \f$ f|_{(i,v) \in xs : x_i = v} \f$ ////////////////////////////////////////////////////////////////////////////// @@ -1059,9 +1059,9 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// /// \brief Evaluate a BDD according to an assignment to its variables. /// - /// \param f The BDD to evaluate + /// \param f The BDD to evaluate. /// - /// \param xs A list of tuples `(i,v)` in ascending order of `i`. + /// \param xs Assignments (i,v) to variables in (in ascending order). /// /// \pre Assignment tuples in `xs` is in ascending order /// @@ -1070,9 +1070,26 @@ namespace adiar /// /// \throws invalid_argument If a level in the BDD does not exist in `xs`. ////////////////////////////////////////////////////////////////////////////// - // TODO v2.0 : Replace with `generator>` - bool bdd_eval(const bdd &f, - const shared_file> &xs); + bool bdd_eval(const bdd &f, const generator> &xs); + + ////////////////////////////////////////////////////////////////////////////// + /// \brief Evaluate a BDD according to an assignment to its variables. + /// + /// \param f The BDD to evaluate. + /// + /// \param begin Single-pass forward iterator that provides the assignment in + /// \em ascending order. + /// + /// \param end Marks the end for `begin`. + /// + /// \throws out_of_range If traversal of the BDD leads to going beyond the end + /// of the content of `xs`. + /// + /// \throws invalid_argument If a level in the BDD does not exist in `xs`. + ////////////////////////////////////////////////////////////////////////////// + template + bool bdd_eval(const bdd &f, ForwardIt begin, ForwardIt end) + { return bdd_eval(f, make_generator(begin, end)); } ////////////////////////////////////////////////////////////////////////////// /// \brief Get the labels of the levels of the BDD. diff --git a/src/adiar/bdd/evaluate.cpp b/src/adiar/bdd/evaluate.cpp index 9b1192ec1..ebd395090 100644 --- a/src/adiar/bdd/evaluate.cpp +++ b/src/adiar/bdd/evaluate.cpp @@ -45,37 +45,42 @@ namespace adiar } ////////////////////////////////////////////////////////////////////////////// - class bdd_eval_file_visitor + class bdd_eval_generator_visitor { - internal::file_stream> mps; - map_pair mp; + const generator> &_generator; + pair _next_pair; bool result = false; public: - bdd_eval_file_visitor(const shared_file>& msf) - : mps(msf) - { if (mps.can_pull()) { mp = mps.pull(); } } + bdd_eval_generator_visitor(const generator>& g) + : _generator(g) + { + _next_pair = _generator(); + } inline bdd::pointer_type visit(const bdd::node_type &n) { const bdd::label_type level = n.label(); - while (mp.level() < level) { - if (!mps.can_pull()) { + + while (_next_pair.first < level) { + const pair p = _generator(); + + if (bdd::max_label < p.first) { throw out_of_range("Labels are insufficient to traverse BDD"); } - if (mps.peek().level() <= mp.level()) { + if (p.first <= _next_pair.first) { throw invalid_argument("Labels are not in ascending order"); } - mp = mps.pull(); + _next_pair = p; } - if (mp.level() != level) { + if (_next_pair.first != level) { throw invalid_argument("Missing assignment for node visited in BDD"); } - return mp.value() ? n.high() : n.low(); + return n.child(_next_pair.second); } inline void visit(const bool s) @@ -85,10 +90,9 @@ namespace adiar { return result; } }; - bool bdd_eval(const bdd &bdd, - const shared_file> &mpf) + bool bdd_eval(const bdd &bdd, const generator> &xs) { - bdd_eval_file_visitor v(mpf); + bdd_eval_generator_visitor v(xs); internal::traverse(bdd, v); return v.get_result(); } @@ -96,7 +100,7 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// class bdd_sat_bdd_callback { - // TODO: replace with TPIE's external stack + // TODO: replace with TPIE's external stack / an internal stack using e = map_pair; shared_file ef; diff --git a/test/adiar/bdd/test_evaluate.cpp b/test/adiar/bdd/test_evaluate.cpp index 3570fb79f..5ee8b941d 100644 --- a/test/adiar/bdd/test_evaluate.cpp +++ b/test/adiar/bdd/test_evaluate.cpp @@ -81,258 +81,191 @@ go_bandit([]() { nw << node(true); } - describe("bdd_eval(bdd, adiar::shared_file<...>)", [&]() { + describe("bdd_eval(bdd, adiar::generator<...>)", [&]() { it("returns F on test BDD with assignment (F,F,F,T)", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, false) - << map_pair(1, false) - << map_pair(2, false) - << map_pair(3, true); - } + std::vector> ass = { + {0, false}, + {1, false}, + {2, false}, + {3, true} + }; - AssertThat(bdd_eval(bdd, ass), Is().False()); + AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().False()); }); it("returns F on test BDD with assignment (F,_,F,T)", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, false) - << map_pair(2, false) - << map_pair(3, true); - } + std::vector> ass = { + {0, false}, + {2, false}, + {3, true} + }; - AssertThat(bdd_eval(bdd, ass), Is().False()); + AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().False()); }); it("returns T on test BDD with assignment (F,T,T,T)", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, false) - << map_pair(1, true) - << map_pair(2, true) - << map_pair(3, true); - } + std::vector> ass = { + {0, false}, + {1, true}, + {2, true}, + {3, true} + }; - AssertThat(bdd_eval(bdd, ass), Is().True()); + AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().True()); }); it("returns F on test BDD with assignment (T,F,F,T)", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, true) - << map_pair(1, false) - << map_pair(2, false) - << map_pair(3, true); - } + std::vector> ass = { + {0, true}, + {1, false}, + {2, false}, + {3, true} + }; - AssertThat(bdd_eval(bdd, ass), Is().False()); + AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().False()); }); it("returns T on test BDD with assignment (T,F,T,F)", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, true) - << map_pair(1, false) - << map_pair(2, true) - << map_pair(3, false); - } + std::vector> ass = { + {0, true}, + {1, false}, + {2, true}, + {3, false} + }; - AssertThat(bdd_eval(bdd, ass), Is().True()); + AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().True()); }); it("returns T on test BDD with assignment (T,T,F,T)", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, true) - << map_pair(1, true) - << map_pair(2, false) - << map_pair(3, true); - } + std::vector> ass = { + {0, true}, + {1, true}, + {2, false}, + {3, true} + }; - AssertThat(bdd_eval(bdd, ass), Is().True()); + AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().True()); }); it("returns T on test BDD with assignment (T,T,T,F)", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, true) - << map_pair(1, true) - << map_pair(2, true) - << map_pair(3, false); - } + std::vector> ass = { + {0, true}, + {1, true}, + {2, true}, + {3, false} + }; - AssertThat(bdd_eval(bdd, ass), Is().False()); + AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().False()); }); it("returns T on test BDD with assignment (T,T,T,T)", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, true) - << map_pair(1, true) - << map_pair(2, true) - << map_pair(3, true); - } + std::vector> ass = { + {0, true}, + {1, true}, + {2, true}, + {3, true} + }; - AssertThat(bdd_eval(bdd, ass), Is().True()); + AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().True()); }); it("should be able to evaluate BDD that skips level [1]", [&skip_bdd]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, false) - << map_pair(1, true) - << map_pair(2, false) - << map_pair(3, true) - << map_pair(4, true); - } + std::vector> ass = { + {0, false}, + {1, true}, + {2, false}, + {3, true}, + {4, true} + }; - AssertThat(bdd_eval(skip_bdd, ass), Is().False()); + AssertThat(bdd_eval(skip_bdd, ass.begin(), ass.end()), Is().False()); }); it("should be able to evaluate BDD that skips level [2]", [&skip_bdd]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, true) - << map_pair(1, false) - << map_pair(2, true) - << map_pair(3, true) - << map_pair(4, false); - } + std::vector> ass = { + {0, true}, + {1, false}, + {2, true}, + {3, true}, + {4, false} + }; - AssertThat(bdd_eval(skip_bdd, ass), Is().False()); + AssertThat(bdd_eval(skip_bdd, ass.begin(), ass.end()), Is().False()); }); it("returns T on BDD with non-zero root with assignment (F,T)", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, false) - << map_pair(1, true); - } + std::vector> ass = { + {0, false}, + {1, true} + }; - AssertThat(bdd_eval(non_zero_bdd, ass), Is().True()); + AssertThat(bdd_eval(non_zero_bdd, ass.begin(), ass.end()), Is().True()); }); it("returns F on F terminal-only BDD", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, true) - << map_pair(1, false) - << map_pair(2, false) - << map_pair(3, true); - } + std::vector> ass = { + {0, true}, + {1, false}, + {2, false}, + {3, true} + }; - AssertThat(bdd_eval(bdd_F, ass), Is().False()); + AssertThat(bdd_eval(bdd_F, ass.begin(), ass.end()), Is().False()); }); it("returns F on F terminal-only BDD with empty assignment", [&]() { - adiar::shared_file> ass; + std::vector> ass = { }; - AssertThat(bdd_eval(bdd_F, ass), Is().False()); + AssertThat(bdd_eval(bdd_F, ass.begin(), ass.end()), Is().False()); }); it("returns T on T terminal-only BDD", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, true) - << map_pair(1, true) - << map_pair(2, false) - << map_pair(3, true); - } + std::vector> ass = { + {0, true}, + {1, true}, + {2, false}, + {3, true} + }; - AssertThat(bdd_eval(bdd_T, ass), Is().True()); + AssertThat(bdd_eval(bdd_T, ass.begin(), ass.end()), Is().True()); }); it("returns T on T terminal-only BDD with empty assignment", [&]() { - adiar::shared_file> ass; + std::vector> ass; - AssertThat(bdd_eval(bdd_T, ass), Is().True()); + AssertThat(bdd_eval(bdd_T, ass.begin(), ass.end()), Is().True()); }); it("throws exception when given non-ascending list of assignments", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, true) - << map_pair(2, true) - << map_pair(1, true) - << map_pair(3, true) - << map_pair(4, true) - ; - } + std::vector> ass = { + {0, true}, + {2, true}, + {1, true}, + {3, true}, + {4, true} + }; - AssertThrows(invalid_argument, bdd_eval(skip_bdd, ass)); + AssertThrows(invalid_argument, bdd_eval(skip_bdd, ass.begin(), ass.end())); }); it("throws exception when running out of assignments", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, true) - << map_pair(1, true) - ; - } + std::vector> ass = { + {0, true}, + {1, true} + }; - AssertThrows(out_of_range, bdd_eval(skip_bdd, ass)); + AssertThrows(out_of_range, bdd_eval(skip_bdd, ass.begin(), ass.end())); }); it("throws exception when list is missing a needed assignment", [&]() { - adiar::shared_file> ass; - - { // Garbage collect writer to free write-lock - adiar::file_writer> aw(ass); - - aw << map_pair(0, true) - << map_pair(1, true) - << map_pair(3, true) - << map_pair(4, true) - ; - } + std::vector> ass = { + {0, true}, + {1, true}, + {3, true}, + {4, true} + }; - AssertThrows(invalid_argument, bdd_eval(skip_bdd, ass)); + AssertThrows(invalid_argument, bdd_eval(skip_bdd, ass.begin(), ass.end())); }); }); From 928309fb2df1f78da7a54c56e9c84ddde2ee7764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Sun, 8 Oct 2023 12:57:45 -0400 Subject: [PATCH 3/6] Add 'domain_size()' as a safe-to-call API function In multiple places, we want to compare the domain size, where a missing domain is treated as having size 0. We might as well just put this piece of code in one place --- src/adiar/bdd/count.cpp | 4 +--- src/adiar/domain.cpp | 23 ++++++++++++++++------ src/adiar/domain.h | 7 +++++++ test/adiar/test_domain.cpp | 39 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 9 deletions(-) diff --git a/src/adiar/bdd/count.cpp b/src/adiar/bdd/count.cpp index 77fafa9ef..19b800d62 100644 --- a/src/adiar/bdd/count.cpp +++ b/src/adiar/bdd/count.cpp @@ -114,9 +114,7 @@ namespace adiar uint64_t bdd_satcount(const exec_policy &ep, const bdd &f) { - const bdd::label_type domain_size = domain_isset() ? domain_get()->size() : 0; - const bdd::label_type varcount = bdd_varcount(f); - return bdd_satcount(ep, f, std::max(domain_size, varcount)); + return bdd_satcount(ep, f, std::max(domain_size(), bdd_varcount(f))); }; uint64_t bdd_satcount(const bdd &f) diff --git a/src/adiar/domain.cpp b/src/adiar/domain.cpp index 2a494bc99..189e4f8e3 100644 --- a/src/adiar/domain.cpp +++ b/src/adiar/domain.cpp @@ -11,7 +11,8 @@ namespace adiar shared_ptr> domain_ptr; - void domain_set(const domain_var varcount) { + void domain_set(const domain_var varcount) + { shared_file dom; { // Garbage collect writer to free write-lock internal::file_writer lw(dom); @@ -20,7 +21,8 @@ namespace adiar domain_set(dom); } - void domain_set(const generator &gen) { + void domain_set(const generator &gen) + { shared_file dom; { // Garbage collect writer to free write-lock internal::file_writer lw(dom); @@ -32,23 +34,32 @@ namespace adiar domain_set(dom); } - void domain_set(const shared_file &dom) { + void domain_set(const shared_file &dom) + { domain_ptr = dom; } - void domain_unset() { + void domain_unset() + { domain_ptr.reset(); } - bool domain_isset() { + bool domain_isset() + { return domain_ptr ? true : false; } - shared_file domain_get() { + shared_file domain_get() + { if(!domain_isset()) { throw domain_error("Domain must be set before it can be used"); } return domain_ptr; } + + domain_var domain_size() + { + return domain_isset() ? domain_get()->size() : 0u; + } } diff --git a/src/adiar/domain.h b/src/adiar/domain.h index 97aed97f1..933fb48d4 100644 --- a/src/adiar/domain.h +++ b/src/adiar/domain.h @@ -104,6 +104,13 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// shared_file domain_get(); + ////////////////////////////////////////////////////////////////////////////// + /// \brief The size of the domain. + /// + /// \details Returns `0` if `domain_isset() == false`. + ////////////////////////////////////////////////////////////////////////////// + domain_var domain_size(); + /// \} ////////////////////////////////////////////////////////////////////////////// } diff --git a/test/adiar/test_domain.cpp b/test/adiar/test_domain.cpp index e248a8752..ba4198bbe 100644 --- a/test/adiar/test_domain.cpp +++ b/test/adiar/test_domain.cpp @@ -294,6 +294,45 @@ go_bandit([]() { }); }); + describe("domain_set(), domain_unset(), domain_size()", []() { + it("has zero-sized domain if none is set", []() { + domain_unset(); + + AssertThat(domain_isset(), Is().False()); + AssertThat(domain_size(), Is().EqualTo(0u)); + }); + + it("reports domain has no elements when set to the empty domain", []() { + domain_unset(); + AssertThat(domain_isset(), Is().False()); + + domain_set(0); + AssertThat(domain_isset(), Is().True()); + + AssertThat(domain_size(), Is().EqualTo(0u)); + }); + + it("can report having a domain of 1 element", []() { + domain_unset(); + AssertThat(domain_isset(), Is().False()); + + domain_set(1); + AssertThat(domain_isset(), Is().True()); + + AssertThat(domain_size(), Is().EqualTo(1u)); + }); + + it("can report having a domain of 42 element", []() { + domain_unset(); + AssertThat(domain_isset(), Is().False()); + + domain_set(42); + AssertThat(domain_isset(), Is().True()); + + AssertThat(domain_size(), Is().EqualTo(42u)); + }); + }); + // TODO: more tests when 'https://github.com/thomasmoelhave/tpie/issues/265' // is resolved. }); From 7604e478283c604cfd495fe54a1969ea52ff58cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Sun, 8 Oct 2023 13:03:59 -0400 Subject: [PATCH 4/6] Replace 'bdd_satmin' and 'bdd_satmax' implementation to use an internal memory stack There is no need to make an external memory file for this algorithm. Adiar has a minimum requirement of 128 MiB of memory, and even if all levels are present, then they would only require up to 8 MiB of memory. This leaves enough space to open all relevant streams and it will be considerably faster (since we do no unecessary read/writes of tiny files to the disk) --- src/adiar/bdd/evaluate.cpp | 43 ++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/adiar/bdd/evaluate.cpp b/src/adiar/bdd/evaluate.cpp index ebd395090..fbf209b8c 100644 --- a/src/adiar/bdd/evaluate.cpp +++ b/src/adiar/bdd/evaluate.cpp @@ -1,5 +1,8 @@ #include +#include +#include + #include #include #include @@ -100,41 +103,45 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// class bdd_sat_bdd_callback { - // TODO: replace with TPIE's external stack / an internal stack - using e = map_pair; + // Reserve an internal memory vector (of up to 8 MiB) for the result. + // TODO: Abstract the stack into . + using value_type = pair; + using stack_type = tpie::internal_stack; - shared_file ef; - internal::file_writer ew; + stack_type _stack; public: - bdd_sat_bdd_callback() : ew(ef) + bdd_sat_bdd_callback(const size_t stack_size) + : _stack(std::min(stack_size, bdd::max_label+1)) { } void operator() (bdd::label_type x, bool v) - { ew << map_pair(x, v); } + { + _stack.push({x, v}); + } bdd get_bdd() { - assert(ew.size() > 0); - ew.detach(); - internal::file_stream es(ef); + adiar_assert(!_stack.empty()); + + // TODO: generalise into `bdd_cube(generator)` (#533) internal::shared_levelized_file nf; internal::node_writer nw(nf); bdd::pointer_type latest = bdd::pointer_type(true); + while (!_stack.empty()) { + const value_type& b = _stack.top(); - while (es.can_pull()) { - const e kv = es.pull(); - - const bdd::node_type n(kv.key(), bdd::max_id, - kv.value() ? bdd::pointer_type(false) : latest, - kv.value() ? latest : bdd::pointer_type(false)); + const bdd::node_type n(b.first, bdd::max_id, + b.second ? bdd::pointer_type(false) : latest, + b.second ? latest : bdd::pointer_type(false)); nw.unsafe_push(n); - nw.unsafe_push(internal::level_info(kv.key(), 1u)); + nw.unsafe_push(internal::level_info(b.first, 1u)); latest = n.uid(); + _stack.pop(); } nf->max_1level_cut[internal::cut::Internal] = 1u; @@ -225,7 +232,7 @@ namespace adiar { if (bdd_isterminal(f)) { return f; } - bdd_sat_bdd_callback _cb; + bdd_sat_bdd_callback _cb(f->levels() + domain_size()); __bdd_satX(f, _cb); return _cb.get_bdd(); } @@ -240,7 +247,7 @@ namespace adiar { if (bdd_isterminal(f)) { return f; } - bdd_sat_bdd_callback _cb; + bdd_sat_bdd_callback _cb(f->levels() + domain_size()); __bdd_satX(f, _cb); return _cb.get_bdd(); } From acda930bb3afb4221ebf6a6816349f49ca08cb8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Sun, 8 Oct 2023 13:20:47 -0400 Subject: [PATCH 5/6] Remove 'map_pair' class --- makefile | 3 - src/adiar/CMakeLists.txt | 1 - src/adiar/bdd.h | 1 - src/adiar/map.h | 164 ------------------------- test/adiar/CMakeLists.txt | 1 - test/adiar/test_map.cpp | 252 -------------------------------------- test/test.cpp | 1 - test/test.h | 11 -- 8 files changed, 434 deletions(-) delete mode 100644 src/adiar/map.h delete mode 100644 test/adiar/test_map.cpp diff --git a/makefile b/makefile index 2f0781e65..5a3911c2a 100644 --- a/makefile +++ b/makefile @@ -72,9 +72,6 @@ test/adiar/domain: test/adiar/exec_policy: make $(MAKE_FLAGS) test TEST_FOLDER=test/adiar TEST_NAME=exec_policy -test/adiar/map: - make $(MAKE_FLAGS) test TEST_FOLDER=test/adiar TEST_NAME=map - test/adiar/bdd/apply: make $(MAKE_FLAGS) test TEST_FOLDER=test/adiar/bdd TEST_NAME=apply diff --git a/src/adiar/CMakeLists.txt b/src/adiar/CMakeLists.txt index a4cc868fc..57571aab6 100644 --- a/src/adiar/CMakeLists.txt +++ b/src/adiar/CMakeLists.txt @@ -14,7 +14,6 @@ set(HEADERS exec_policy.h file.h functional.h - map.h statistics.h types.h diff --git a/src/adiar/bdd.h b/src/adiar/bdd.h index 81fa77506..344bb568a 100644 --- a/src/adiar/bdd.h +++ b/src/adiar/bdd.h @@ -23,7 +23,6 @@ #include #include // <-- TODO: remove! -#include // <-- TODO: remove! #include #include diff --git a/src/adiar/map.h b/src/adiar/map.h deleted file mode 100644 index 11084c828..000000000 --- a/src/adiar/map.h +++ /dev/null @@ -1,164 +0,0 @@ -// TODO: Remove entire file! - -#ifndef ADIAR_MAP_H -#define ADIAR_MAP_H - -#include - -#include - -namespace adiar -{ - ////////////////////////////////////////////////////////////////////////////// - /// \brief Minimal enum for `map_pair`. - /// - /// \see map_pair - ////////////////////////////////////////////////////////////////////////////// - enum boolean : bool - { - False = false, - True = true - }; - - ////////////////////////////////////////////////////////////////////////////// - /// \brief A (x,v) tuple representing the single association - /// \f$ x \mapsto v \f$ where \f$v\f$ is a value of enum type. - /// - /// \tparam key_type The (integral) type for the map's key. - /// - /// \tparam value_enum An enum type that has the two values 'False' with the - /// integral value '0' and 'True' with the integral value - /// '1', e.g. `bool_enum`. - ////////////////////////////////////////////////////////////////////////////// - template - class map_pair - { - /* ================================= TYPES ============================== */ - public: - //////////////////////////////////////////////////////////////////////////// - /// \brief Type of the key. - //////////////////////////////////////////////////////////////////////////// - // TODO: Turn into size_t? - using key_t = key_type; - - //////////////////////////////////////////////////////////////////////////// - /// \brief Type (enum) with the values one can assign to a key. - //////////////////////////////////////////////////////////////////////////// - using value_t = value_enum; - static_assert(std::is_enum::value); - - //////////////////////////////////////////////////////////////////////////// - /// \brief The raw integral type used for the value enum. - //////////////////////////////////////////////////////////////////////////// - using raw_t = typename std::underlying_type::type; - - private: - /* ================================= CHECKS ============================= */ - static_assert(std::is_integral::value); - static_assert(std::is_integral::value); - static_assert(static_cast(value_t::False) == static_cast(0u)); - static_assert(static_cast(value_t::True) == static_cast(1u)); - - /* =============================== VARIABLES ============================ */ - private: - key_t _key; - value_t _val; - - /* ============================== CONSTRUCTORS ========================== */ - public: - //////////////////////////////////////////////////////////////////////////// - // Provide 'default' constructors to ensure it being a 'POD' inside of TPIE. - map_pair() = default; - map_pair(const map_pair &a) = default; - ~map_pair() = default; - - //////////////////////////////////////////////////////////////////////////// - /// \brief Constructs map_pair pair (key, value). - //////////////////////////////////////////////////////////////////////////// - map_pair(const key_t key, const value_t val) - : _key(key), _val(val) - { - } - - //////////////////////////////////////////////////////////////////////////// - /// \brief Constructs map_pair pair (key, value) from a boolean - /// value. - //////////////////////////////////////////////////////////////////////////// - map_pair(const key_t key, const bool val) - : map_pair(key, static_cast(val)) - { } - - /* =============================== ACCESSORS ============================ */ - public: - //////////////////////////////////////////////////////////////////////////// - /// \brief Obtain the key of this pair. - //////////////////////////////////////////////////////////////////////////// - inline key_t key() const - { return _key; } - - //////////////////////////////////////////////////////////////////////////// - /// \copydoc key() - //////////////////////////////////////////////////////////////////////////// - inline key_t level() const - { return key(); } - - //////////////////////////////////////////////////////////////////////////// - /// \brief Get the value of this pair. - //////////////////////////////////////////////////////////////////////////// - inline value_t value() const - { return _val; } - - //////////////////////////////////////////////////////////////////////////// - /// \brief Get the *raw* value of this pair. - //////////////////////////////////////////////////////////////////////////// - inline raw_t raw_value() const - { return static_cast(_val); } - - //////////////////////////////////////////////////////////////////////////// - /// \brief Obtain whether the value is 'False'. - //////////////////////////////////////////////////////////////////////////// - inline bool is_false() const - { return value() == value_t::False; } - - //////////////////////////////////////////////////////////////////////////// - /// \brief Obtain whether the value is 'True'. - //////////////////////////////////////////////////////////////////////////// - inline bool is_true() const - { - return value() == value_t::True; - } - - /* ============================== COMPARATORS =========================== */ - public: - inline bool operator< (const map_pair &o) const - { return this->_key < o._key; } - - inline bool operator> (const map_pair &o) const - { return o < *this; } - - inline bool operator== (const map_pair &o) const - { return this->_key == o._key && this->_val == o._val; } - - inline bool operator!= (const map_pair &o) const - { return !(*this == o); } - - /* =============================== OPERATORS ============================ */ - public: - //////////////////////////////////////////////////////////////////////////// - /// \brief Obtain the negated value assigned to the same key. - //////////////////////////////////////////////////////////////////////////// - map_pair operator~ () const - { - const raw_t value_raw = static_cast(this->_val); - - return { - this->_key, - (value_raw & 1) == (value_raw) - ? static_cast(value_raw ^ 1u) - : this->_val - }; - } - }; -} - -#endif // ADIAR_MAP_H diff --git a/test/adiar/CMakeLists.txt b/test/adiar/CMakeLists.txt index d1a493231..7b1561748 100644 --- a/test/adiar/CMakeLists.txt +++ b/test/adiar/CMakeLists.txt @@ -2,7 +2,6 @@ add_test(adiar-bool_op test_bool_op.cpp) add_test(adiar-builder test_builder.cpp) add_test(adiar-domain test_domain.cpp) add_test(adiar-exec_policy test_exec_policy.cpp) -add_test(adiar-map test_map.cpp) add_subdirectory (bdd) add_subdirectory (internal) diff --git a/test/adiar/test_map.cpp b/test/adiar/test_map.cpp deleted file mode 100644 index 6c8ebf3f7..000000000 --- a/test/adiar/test_map.cpp +++ /dev/null @@ -1,252 +0,0 @@ -#include "../test.h" - -enum class test_map_value -{ - False = 0, - True = 1, - Other_1 = 2, - Other_2 = 4, -}; - -using test_map_pair = map_pair; - -go_bandit([]() { - describe("adiar/map.h", []() { - describe("map_pair", []() { - describe("var_mapping<...>(label_type, enum), .key(), .value(), .raw_value()", []() { - it("provides access to variable [42]", []() { - test_map_pair a(42, test_map_value::False); - AssertThat(a.key(), Is().EqualTo(42)); - }); - - it("provides access to variable [21]", []() { - test_map_pair a(21, test_map_value::True); - AssertThat(a.key(), Is().EqualTo(21)); - }); - - it("provides access to value [0]", []() { - test_map_pair a(21, test_map_value::False); - AssertThat(a.value(), Is().EqualTo(test_map_value::False)); - }); - - it("provides access to value [1]", []() { - test_map_pair a(21, test_map_value::True); - AssertThat(a.value(), Is().EqualTo(test_map_value::True)); - }); - - it("provides access to value [2]", []() { - test_map_pair a(42, test_map_value::Other_1); - AssertThat(a.value(), Is().EqualTo(test_map_value::Other_1)); - }); - - it("provides access to value [4]", []() { - test_map_pair a(42, test_map_value::Other_2); - AssertThat(a.value(), Is().EqualTo(test_map_value::Other_2)); - }); - - it("provides access to raw value [0]", []() { - test_map_pair a(21, test_map_value::False); - AssertThat(a.raw_value(), Is().EqualTo(0)); - }); - - it("provides access to raw value [1]", []() { - test_map_pair a(21, test_map_value::True); - AssertThat(a.raw_value(), Is().EqualTo(1)); - }); - - it("provides access to raw value [2]", []() { - test_map_pair a(42, test_map_value::Other_1); - AssertThat(a.raw_value(), Is().EqualTo(2)); - }); - - it("provides access to raw value [4]", []() { - test_map_pair a(42, test_map_value::Other_2); - AssertThat(a.raw_value(), Is().EqualTo(4)); - }); - }); - - describe(".is_false()", []() { - it("is true for 'False'", []() { - test_map_pair a(0, test_map_value::False); - AssertThat(a.is_false(), Is().True()); - }); - - it("is false for 'False'", []() { - test_map_pair a(0, test_map_value::True); - AssertThat(a.is_false(), Is().False()); - }); - - it("is false for other", []() { - test_map_pair a1(0, test_map_value::Other_1); - AssertThat(a1.is_false(), Is().False()); - - test_map_pair a2(0, test_map_value::Other_2); - AssertThat(a2.is_false(), Is().False()); - - }); - }); - - describe(".is_true()", []() { - it("is false for 'False'", []() { - test_map_pair a(0, test_map_value::False); - AssertThat(a.is_true(), Is().False()); - }); - - it("is true for 'False'", []() { - test_map_pair a(0, test_map_value::True); - AssertThat(a.is_true(), Is().True()); - }); - - it("is false for other", []() { - test_map_pair a1(0, test_map_value::Other_1); - AssertThat(a1.is_true(), Is().False()); - - test_map_pair a2(0, test_map_value::Other_1); - AssertThat(a2.is_true(), Is().False()); - }); - }); - - describe("test_map_pair(label_type, bool)", []() { - it("converts correctly from boolean value [0]", []() { - test_map_pair a(42, false); - AssertThat(a.key(), Is().EqualTo(42)); - AssertThat(a.value(), Is().EqualTo(test_map_value::False)); - AssertThat(a.raw_value(), Is().EqualTo(0)); - }); - - it("converts correctly from boolean value [1]", []() { - test_map_pair a(42, true); - AssertThat(a.key(), Is().EqualTo(42)); - AssertThat(a.value(), Is().EqualTo(test_map_value::True)); - AssertThat(a.raw_value(), Is().EqualTo(1)); - }); - }); - - describe("ordering '<' and '>'", []() { - /* - it("has 'False' values precede 'True' [<]", []() { - AssertThat(test_map_pair(42, test_map_value::False), - Is().LessThan(test_map_pair(42, test_map_value::True))); - AssertThat(test_map_pair(42, test_map_value::True), - Is().Not().LessThan(test_map_pair(42, test_map_value::False))); - }); - - it("has 'False' values precede 'True' [>]", []() { - AssertThat(test_map_pair(42, test_map_value::True), - Is().GreaterThan(test_map_pair(42, test_map_value::False))); - AssertThat(test_map_pair(42, test_map_value::False), - Is().Not().GreaterThan(test_map_pair(42, test_map_value::True))); - }); - */ - - it("sorts based on the variable order [1], [<]", []() { - AssertThat(test_map_pair(21, test_map_value::True), - Is().LessThan(test_map_pair(42, test_map_value::Other_1))); - AssertThat(test_map_pair(42, test_map_value::Other_1), - Is().Not().LessThan(test_map_pair(21, test_map_value::True))); - }); - - it("sorts based on the variable order [1], [>]", []() { - AssertThat(test_map_pair(42, test_map_value::Other_1), - Is().GreaterThan(test_map_pair(21, test_map_value::True))); - AssertThat(test_map_pair(21, test_map_value::True), - Is().Not().GreaterThan(test_map_pair(42, test_map_value::Other_1))); - }); - - it("sorts based on the variable order [2], [<]", []() { - AssertThat(test_map_pair(20, test_map_value::False), - Is().LessThan(test_map_pair(21, test_map_value::Other_1))); - AssertThat(test_map_pair(21, test_map_value::Other_1), - Is().Not().LessThan(test_map_pair(20, test_map_value::False))); - }); - - it("sorts based on the variable order [2], [>]", []() { - AssertThat(test_map_pair(21, test_map_value::Other_1), - Is().GreaterThan(test_map_pair(20, test_map_value::False))); - AssertThat(test_map_pair(20, test_map_value::False), - Is().Not().GreaterThan(test_map_pair(21, test_map_value::Other_1))); - }); - }); - - describe("equality '=='", []() { - it("is true when both variable and value match [1]", [&]() { - AssertThat(test_map_pair(1, test_map_value::Other_1), - Is().EqualTo(test_map_pair(1, test_map_value::Other_1))); - }); - - it("is true when both variable and value match [2]", [&]() { - AssertThat(test_map_pair(2, test_map_value::False), - Is().EqualTo(test_map_pair(2, test_map_value::False))); - }); - - it("is true when both variable and value match [3]", [&]() { - AssertThat(test_map_pair(42, test_map_value::True), - Is().EqualTo(test_map_pair(42, test_map_value::True))); - }); - - it("is false when the variable mismatches [1]", [&]() { - AssertThat(test_map_pair(42, test_map_value::True), - Is().Not().EqualTo(test_map_pair(21, test_map_value::True))); - }); - - it("is false when the variable mismatches [2]", [&]() { - AssertThat(test_map_pair(8, test_map_value::False), - Is().Not().EqualTo(test_map_pair(10, test_map_value::False))); - }); - - it("is false when the value mismatches [1]", [&]() { - AssertThat(test_map_pair(42, test_map_value::Other_1), - Is().Not().EqualTo(test_map_pair(42, test_map_value::False))); - AssertThat(test_map_pair(42, test_map_value::Other_1), - Is().Not().EqualTo(test_map_pair(42, test_map_value::True))); - }); - - it("is false when the value mismatches [2]", [&]() { - AssertThat(test_map_pair(8, test_map_value::False), - Is().Not().EqualTo(test_map_pair(8, test_map_value::Other_1))); - AssertThat(test_map_pair(8, test_map_value::False), - Is().Not().EqualTo(test_map_pair(8, test_map_value::True))); - }); - - it("is false when the value mismatches [3]", [&]() { - AssertThat(test_map_pair(8, test_map_value::True), - Is().Not().EqualTo(test_map_pair(8, test_map_value::Other_1))); - AssertThat(test_map_pair(13, test_map_value::True), - Is().Not().EqualTo(test_map_pair(13, test_map_value::False))); - }); - }); - - describe("negation '~", []() { - it("turns 'False' into 'True' [1]", [&]() { - AssertThat(~test_map_pair(1, test_map_value::False), - Is().EqualTo(test_map_pair(1, test_map_value::True))); - }); - - it("turns 'False' into 'True' [2]", [&]() { - AssertThat(~test_map_pair(2, test_map_value::False), - Is().EqualTo(test_map_pair(2, test_map_value::True))); - }); - - it("turns 'True' into 'False' [1]", [&]() { - AssertThat(~test_map_pair(3, test_map_value::False), - Is().EqualTo(test_map_pair(3, test_map_value::True))); - }); - - it("turns 'True' into 'False' [2]", [&]() { - AssertThat(~test_map_pair(4, test_map_value::False), - Is().EqualTo(test_map_pair(4, test_map_value::True))); - }); - - it("keeps 'None' as-is [1]", [&]() { - AssertThat(~test_map_pair(5, test_map_value::Other_1), - Is().EqualTo(test_map_pair(5, test_map_value::Other_1))); - }); - - it("keeps 'None' as-is [2]", [&]() { - AssertThat(~test_map_pair(6, test_map_value::Other_1), - Is().EqualTo(test_map_pair(6, test_map_value::Other_1))); - }); - }); - }); - }); - }); diff --git a/test/test.cpp b/test/test.cpp index 88379224c..927362200 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -82,7 +82,6 @@ go_bandit([]() { //////////////////////////////////////////////////////////////////////////////// // Adiar Core unit tests #include "adiar/test_bool_op.cpp" -#include "adiar/test_map.cpp" #include "adiar/test_domain.cpp" #include "adiar/test_builder.cpp" diff --git a/test/test.h b/test/test.h index cfbc5b035..c46b80c98 100644 --- a/test/test.h +++ b/test/test.h @@ -151,17 +151,6 @@ namespace snowhouse return stream.str(); } }; - - template<> - struct Stringizer> - { - static std::string ToString(const adiar::map_pair& a) - { - std::stringstream stream; - stream << "assignment: [x" << a.key() << "|->" << static_cast(a.value()) << "]"; - return stream.str(); - } - }; } //////////////////////////////////////////////////////////////////////////////// From 0b985310df82136c134b883163340f8761868ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Sun, 8 Oct 2023 13:33:43 -0400 Subject: [PATCH 6/6] Remove The entire public API does not make use of Adiar's files (with the exception of 'domain_get()' and one overload of 'domain_set(...)', both of which are really only intended for an internal use-case anyway). --- src/adiar/CMakeLists.txt | 1 - src/adiar/adiar.h | 1 - src/adiar/bdd.h | 2 - src/adiar/bdd/bdd.cpp | 2 +- src/adiar/domain.cpp | 11 +- src/adiar/domain.h | 8 +- src/adiar/file.h | 52 --- src/adiar/zdd/build.cpp | 6 +- src/adiar/zdd/complement.cpp | 4 +- src/adiar/zdd/zdd.cpp | 2 +- test/adiar/bdd/test_count.cpp | 4 +- .../data_structures/test_level_merger.cpp | 10 +- .../test_levelized_priority_queue.cpp | 422 +++++++++--------- test/adiar/internal/io/test_file.cpp | 124 ++--- .../internal/io/test_shared_file_ptr.cpp | 74 +-- test/adiar/test_domain.cpp | 26 +- test/adiar/zdd/test_project.cpp | 16 +- test/adiar/zdd/test_zdd.cpp | 4 +- 18 files changed, 357 insertions(+), 412 deletions(-) delete mode 100644 src/adiar/file.h diff --git a/src/adiar/CMakeLists.txt b/src/adiar/CMakeLists.txt index 57571aab6..1269e2918 100644 --- a/src/adiar/CMakeLists.txt +++ b/src/adiar/CMakeLists.txt @@ -12,7 +12,6 @@ set(HEADERS domain.h exception.h exec_policy.h - file.h functional.h statistics.h types.h diff --git a/src/adiar/adiar.h b/src/adiar/adiar.h index 73a5bdcb6..9c18ca12f 100644 --- a/src/adiar/adiar.h +++ b/src/adiar/adiar.h @@ -14,7 +14,6 @@ #include #include #include -#include // <-- TODO: Remove! //////////////////////////////////////////////////////////////////////////////// /// Global Domain diff --git a/src/adiar/bdd.h b/src/adiar/bdd.h index 344bb568a..e700db81d 100644 --- a/src/adiar/bdd.h +++ b/src/adiar/bdd.h @@ -22,8 +22,6 @@ #include #include -#include // <-- TODO: remove! - #include #include diff --git a/src/adiar/bdd/bdd.cpp b/src/adiar/bdd/bdd.cpp index bde61200a..b43e4d4ce 100644 --- a/src/adiar/bdd/bdd.cpp +++ b/src/adiar/bdd/bdd.cpp @@ -186,7 +186,7 @@ namespace adiar __bdd bdd_from(const exec_policy &ep, const zdd &A) { - const shared_file dom = domain_get(); + const internal::shared_file dom = domain_get(); internal::file_stream ds(dom); return bdd_from(ep, A, make_generator(ds)); diff --git a/src/adiar/domain.cpp b/src/adiar/domain.cpp index 189e4f8e3..088616c2e 100644 --- a/src/adiar/domain.cpp +++ b/src/adiar/domain.cpp @@ -1,8 +1,7 @@ #include "domain.h" #include -#include -#include +#include namespace adiar { @@ -13,7 +12,7 @@ namespace adiar void domain_set(const domain_var varcount) { - shared_file dom; + internal::shared_file dom; { // Garbage collect writer to free write-lock internal::file_writer lw(dom); for (domain_var v = 0; v < varcount; v++) { lw << v; } @@ -23,7 +22,7 @@ namespace adiar void domain_set(const generator &gen) { - shared_file dom; + internal::shared_file dom; { // Garbage collect writer to free write-lock internal::file_writer lw(dom); @@ -34,7 +33,7 @@ namespace adiar domain_set(dom); } - void domain_set(const shared_file &dom) + void domain_set(const internal::shared_file &dom) { domain_ptr = dom; } @@ -49,7 +48,7 @@ namespace adiar return domain_ptr ? true : false; } - shared_file domain_get() + internal::shared_file domain_get() { if(!domain_isset()) { throw domain_error("Domain must be set before it can be used"); diff --git a/src/adiar/domain.h b/src/adiar/domain.h index 933fb48d4..77f0a2c81 100644 --- a/src/adiar/domain.h +++ b/src/adiar/domain.h @@ -12,9 +12,11 @@ //////////////////////////////////////////////////////////////////////////////// #include -#include // <-- TODO: Replace with #include +#include +#include + // TODO: Make 'domain_var' independent of node type. Then remove this include. #include @@ -75,7 +77,7 @@ namespace adiar /// /// \see domain_get() ////////////////////////////////////////////////////////////////////////////// - void domain_set(const shared_file &dom); + void domain_set(const internal::shared_file &dom); ////////////////////////////////////////////////////////////////////////////// /// \brief Removes any globally shared domain variables (if any). @@ -102,7 +104,7 @@ namespace adiar /// /// \see domain_set(const shared_file &dom) ////////////////////////////////////////////////////////////////////////////// - shared_file domain_get(); + internal::shared_file domain_get(); ////////////////////////////////////////////////////////////////////////////// /// \brief The size of the domain. diff --git a/src/adiar/file.h b/src/adiar/file.h deleted file mode 100644 index 42f839095..000000000 --- a/src/adiar/file.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef ADIAR_FILE_H -#define ADIAR_FILE_H - -#include -#include -#include -#include - -namespace adiar -{ - // Lifting 'adiar/internal/io/file_stream' to the 'adiar' namespace. - - ////////////////////////////////////////////////////////////////////////////// - /// \copydoc adiar::internal::file_stream - ////////////////////////////////////////////////////////////////////////////// - template - using file_stream = internal::file_stream; - - // Lifting 'adiar/internal/io/file_writer' to the 'adiar' namespace. - - ////////////////////////////////////////////////////////////////////////////// - /// \copydoc adiar::internal::file_writer - ////////////////////////////////////////////////////////////////////////////// - template - using file_writer = internal::file_writer; - - // Lifting 'adiar/internal/io/shared_file_ptr' to the 'adiar' namespace. - - ////////////////////////////////////////////////////////////////////////////// - /// \copydoc adiar::internal::shared_file - ////////////////////////////////////////////////////////////////////////////// - template - using shared_file = internal::shared_file; - - ////////////////////////////////////////////////////////////////////////////// - /// \copydoc adiar::internal::make_shared_file() - ////////////////////////////////////////////////////////////////////////////// - template - inline shared_file make_shared_file() { - return internal::make_shared_file(); - } - - ////////////////////////////////////////////////////////////////////////////// - /// \copydoc adiar::internal::make_shared_file(const std::string &p) - ////////////////////////////////////////////////////////////////////////////// - template - inline shared_file make_shared_file(const std::string &p) { - return internal::make_shared_file(p); - } -} - -#endif // ADIAR_FILE_H diff --git a/src/adiar/zdd/build.cpp b/src/adiar/zdd/build.cpp index adac21faa..975a44b3e 100644 --- a/src/adiar/zdd/build.cpp +++ b/src/adiar/zdd/build.cpp @@ -65,7 +65,7 @@ namespace adiar zdd zdd_ithvar(const zdd::label_type var) { - const shared_file dom = domain_get(); + const internal::shared_file dom = domain_get(); internal::file_stream ds(dom); return zdd_ithvar(var, make_generator(ds)); @@ -101,7 +101,7 @@ namespace adiar zdd zdd_nithvar(const zdd::label_type var) { - const shared_file dom = domain_get(); + const internal::shared_file dom = domain_get(); internal::file_stream ds(dom); return zdd_nithvar(var, make_generator(ds)); @@ -156,7 +156,7 @@ namespace adiar return zdd_null(); } - const shared_file dom = domain_get(); + const internal::shared_file dom = domain_get(); internal::file_stream ds(dom); return zdd_powerset(make_generator(ds)); diff --git a/src/adiar/zdd/complement.cpp b/src/adiar/zdd/complement.cpp index 5fe184f83..ba3c88cf6 100644 --- a/src/adiar/zdd/complement.cpp +++ b/src/adiar/zdd/complement.cpp @@ -54,7 +54,7 @@ namespace adiar } static zdd on_terminal_input(const bool terminal_value, const zdd& /*dd*/, - const shared_file &universe) + const internal::shared_file &universe) { // TODO: remove internal::file_stream ls(universe); @@ -118,7 +118,7 @@ namespace adiar __zdd zdd_complement(const exec_policy &ep, const zdd &A) { - const shared_file dom = domain_get(); + const internal::shared_file dom = domain_get(); internal::file_stream ds(dom); return zdd_complement(ep, A, make_generator(ds)); diff --git a/src/adiar/zdd/zdd.cpp b/src/adiar/zdd/zdd.cpp index a7680e04b..0ba6c3c71 100644 --- a/src/adiar/zdd/zdd.cpp +++ b/src/adiar/zdd/zdd.cpp @@ -225,7 +225,7 @@ namespace adiar __zdd zdd_from(const exec_policy &ep, const bdd &f) { - const shared_file dom = domain_get(); + const internal::shared_file dom = domain_get(); internal::file_stream ds(dom); return zdd_from(ep, f, make_generator(ds)); diff --git a/test/adiar/bdd/test_count.cpp b/test/adiar/bdd/test_count.cpp index f054ea30d..1d04d96e9 100644 --- a/test/adiar/bdd/test_count.cpp +++ b/test/adiar/bdd/test_count.cpp @@ -126,7 +126,7 @@ go_bandit([]() { } // Set domain to be empty - adiar::shared_file empty_dom; + shared_file empty_dom; domain_set(empty_dom); describe("bdd_nodecount", [&]() { @@ -292,7 +292,7 @@ go_bandit([]() { }); describe("bdd_satcount(f) [non-empty dom]", [&]() { - adiar::shared_file dom; + shared_file dom; { label_writer lw(dom); lw << 0 << 1 << 2 << 3 << 4 << 5 << 6; diff --git a/test/adiar/internal/data_structures/test_level_merger.cpp b/test/adiar/internal/data_structures/test_level_merger.cpp index bb305d4a3..b2f6ff6d8 100644 --- a/test/adiar/internal/data_structures/test_level_merger.cpp +++ b/test/adiar/internal/data_structures/test_level_merger.cpp @@ -292,14 +292,14 @@ go_bandit([]() { describe("level_merger, ...>", [&]() { it("can use a single label_file", [&]() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writers label_writer w(f); w << 0 << 2 << 3; } - level_merger, std::less<>, 1> merger; + level_merger, std::less<>, 1> merger; merger.hook({f}); @@ -316,8 +316,8 @@ go_bandit([]() { }); it("can merge two label_files", [&]() { - adiar::shared_file f1; - adiar::shared_file f2; + shared_file f1; + shared_file f2; { // Garbage collect the writers label_writer w1(f1); @@ -327,7 +327,7 @@ go_bandit([]() { w2 << 0 << 1 << 3; } - level_merger, std::less<>, 2> merger; + level_merger, std::less<>, 2> merger; merger.hook({f1, f2}); diff --git a/test/adiar/internal/data_structures/test_levelized_priority_queue.cpp b/test/adiar/internal/data_structures/test_levelized_priority_queue.cpp index 7f8289cc1..335a93ca7 100644 --- a/test/adiar/internal/data_structures/test_levelized_priority_queue.cpp +++ b/test/adiar/internal/data_structures/test_levelized_priority_queue.cpp @@ -72,7 +72,7 @@ go_bandit([]() { describe("adiar/internal/levelized_priority_queue.h", []() { //////////////////////////////////////////////////////////////////////////// // TODO: Most level files should be replaced with a simpler - // adiar::shared_file (and use the << operator). + // shared_file (and use the << operator). // Yet, we of course need one test or two with a meta file. // // TODO: Are we not missing some unit tests for the very simple accessors? @@ -91,14 +91,14 @@ go_bandit([]() { }); it("initialises with #levels = 1 (which is skipped)", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); fw << 2; } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -106,14 +106,14 @@ go_bandit([]() { }); it("initialises with #levels = 2 (#buckets = 1)", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); fw << 1 << 2; } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -123,7 +123,7 @@ go_bandit([]() { }); it("initialises with #buckets == #levels", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -131,7 +131,7 @@ go_bandit([]() { << 3 << 4; // buckets } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -141,7 +141,7 @@ go_bandit([]() { }); it("initialises with #buckets < #levels", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -150,7 +150,7 @@ go_bandit([]() { << 5; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -168,7 +168,7 @@ go_bandit([]() { describe(".setup_next_level()", []() { it("can forward until the first non-empty bucket [1]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -178,7 +178,7 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -200,7 +200,7 @@ go_bandit([]() { }); it("can forward until the first non-empty bucket [2]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -210,7 +210,7 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -232,7 +232,7 @@ go_bandit([]() { }); it("can forward up until the overflow queue [1]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -242,7 +242,7 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -263,7 +263,7 @@ go_bandit([]() { }); it("can forward up until the overflow queue [2]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -273,7 +273,7 @@ go_bandit([]() { << 4 << 5 << 6; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -303,7 +303,7 @@ go_bandit([]() { }); it("can forward until next bucket", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -313,7 +313,7 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -350,7 +350,7 @@ go_bandit([]() { }); it("can forward past buckets until top of overflow queue", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -360,7 +360,7 @@ go_bandit([]() { << 4 << 5; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -397,7 +397,7 @@ go_bandit([]() { }); it("can relabel buckets until top of overflow queue", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -410,7 +410,7 @@ go_bandit([]() { << 9; // overflow not yet touched } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -432,7 +432,7 @@ go_bandit([]() { }); it("can relabel buckets until top of overflow queue (on second last level)", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -444,7 +444,7 @@ go_bandit([]() { << 8; // overflow that will have relabelled bucket(s) } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -481,7 +481,7 @@ go_bandit([]() { describe(".setup_next_level(stop_label)", []() { it("does nothing when given level prior to next bucket [1]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -491,7 +491,7 @@ go_bandit([]() { << 5; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -509,7 +509,7 @@ go_bandit([]() { }); it("does nothing when given level prior to next bucket [2]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -519,7 +519,7 @@ go_bandit([]() { << 6; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {2, 1}); pq.setup_next_level(); // 2 @@ -538,7 +538,7 @@ go_bandit([]() { }); it("forwards to first bucket", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -548,7 +548,7 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -570,7 +570,7 @@ go_bandit([]() { }); it("forwards to second bucket", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -580,7 +580,7 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -602,7 +602,7 @@ go_bandit([]() { }); it("forwards to next bucket with content", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -612,7 +612,7 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -632,7 +632,7 @@ go_bandit([]() { }); it("forwards to next bucket without content", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -642,7 +642,7 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {3, 1}); @@ -659,7 +659,7 @@ go_bandit([]() { }); it("stops early at bucket with content", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -669,7 +669,7 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -686,7 +686,7 @@ go_bandit([]() { }); it("forwards to first bucket for unknown level prior to second bucket", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -696,7 +696,7 @@ go_bandit([]() { << 5; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -716,7 +716,7 @@ go_bandit([]() { }); it("relabels with current buckets included", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -726,7 +726,7 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -748,7 +748,7 @@ go_bandit([]() { }); it("relabels early at top of overflow queue", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -758,7 +758,7 @@ go_bandit([]() { << 4 << 5 << 6; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.can_pull(), Is().False()); @@ -781,7 +781,7 @@ go_bandit([]() { }); it("can relabel for unknown level", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -793,7 +793,7 @@ go_bandit([]() { << 11 ; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {2, 1}); pq.setup_next_level(); @@ -1088,7 +1088,7 @@ go_bandit([]() { }); it("can use relabelled buckets [1]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1097,7 +1097,7 @@ go_bandit([]() { << 3 << 4 << 5 << 6; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {2, 1}); // bucket @@ -1136,7 +1136,7 @@ go_bandit([]() { }); it("can use relabelled buckets [2]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1145,7 +1145,7 @@ go_bandit([]() { << 3 << 4 << 5 << 6; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {3, 1}); // overflow @@ -1175,7 +1175,7 @@ go_bandit([]() { }); it("can push after relabelling that skips levels [1]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1184,7 +1184,7 @@ go_bandit([]() { << 3 << 4 << 5 << 6 << 7; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {1, 1}); // bucket pq.push(lpq_test_data {5, 1}); // overflow @@ -1226,7 +1226,7 @@ go_bandit([]() { }); it("can push after relabelling that skips levels [2]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1235,7 +1235,7 @@ go_bandit([]() { << 3 << 4 << 5 << 6 << 7; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {5, 1}); // overflow pq.push(lpq_test_data {6, 1}); // overflow @@ -1273,7 +1273,7 @@ go_bandit([]() { }); it("can use buckets after relabelling close to the end", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1282,7 +1282,7 @@ go_bandit([]() { << 3 << 4 << 5; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {4, 1}); // overflow pq.push(lpq_test_data {1, 1}); // bucket @@ -1317,7 +1317,7 @@ go_bandit([]() { }); it("can use buckets after relabelling close to the end (the current read bucket dies)", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1326,7 +1326,7 @@ go_bandit([]() { << 4 << 5; } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {4, 1}); // overflow pq.push(lpq_test_data {2, 1}); // bucket @@ -1361,7 +1361,7 @@ go_bandit([]() { }); it("can use buckets after bucket-hitting stop-level", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1370,7 +1370,7 @@ go_bandit([]() { << 3 << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {2, 1}); // buckete @@ -1404,7 +1404,7 @@ go_bandit([]() { }); it("can use relabelled buckets (with stop-level)", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1413,7 +1413,7 @@ go_bandit([]() { << 3 << 4 << 5 << 6; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {4, 1}); // overflow @@ -1442,7 +1442,7 @@ go_bandit([]() { }); it("can use relabelled bucket of a level that was also a prior bucket due to the stop-level", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1451,7 +1451,7 @@ go_bandit([]() { << 3 << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.setup_next_level(1u); // buckets: [2,3] @@ -1479,7 +1479,7 @@ go_bandit([]() { }); it("can push after relabelling (with stop-level) that skips levels [1]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1488,7 +1488,7 @@ go_bandit([]() { << 3 << 4 << 5 << 6 << 7; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {1, 1}); // bucket pq.push(lpq_test_data {7, 2}); // overflow @@ -1524,7 +1524,7 @@ go_bandit([]() { }); it("can push after relabelling (with stop-level) that skips levels [2]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1533,7 +1533,7 @@ go_bandit([]() { << 3 << 4 << 5 << 6 << 7; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {6, 1}); // overflow pq.push(lpq_test_data {7, 2}); // overflow @@ -1567,7 +1567,7 @@ go_bandit([]() { }); it("can use buckets after relabelling (with stop-level) close to the end", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1576,7 +1576,7 @@ go_bandit([]() { << 3 << 4 << 5; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {1, 1}); // bucket @@ -1607,7 +1607,7 @@ go_bandit([]() { }); it("can use buckets after relabelling (with stop-level) close to the end (the current read bucket dies)", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1616,7 +1616,7 @@ go_bandit([]() { << 4 << 5; } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {2, 1}); // bucket @@ -1649,7 +1649,7 @@ go_bandit([]() { describe(".pop()", []{ it("can pop from bucket [1]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1658,7 +1658,7 @@ go_bandit([]() { << 3; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {2,1}); @@ -1672,7 +1672,7 @@ go_bandit([]() { }); it("can pop from bucket [2]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1681,7 +1681,7 @@ go_bandit([]() { << 3; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {2,1}); pq.push(lpq_test_data {2,2}); @@ -1699,7 +1699,7 @@ go_bandit([]() { }); it("can pop from overflow [1]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1708,7 +1708,7 @@ go_bandit([]() { << 3 << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {3,1}); // overflow @@ -1722,7 +1722,7 @@ go_bandit([]() { }); it("can pop from overflow [2]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -1731,7 +1731,7 @@ go_bandit([]() { << 3 << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {3,1}); // overflow pq.push(lpq_test_data {2,1}); // bucket @@ -1763,7 +1763,7 @@ go_bandit([]() { ////////////////////////////////////////////////////////////////////////// // .can_pull() // describe(".empty_level() / .can_pull()", []{ - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -1774,14 +1774,14 @@ go_bandit([]() { } it("cannot pull after initialisation", [&f]() { - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.can_pull(), Is().False()); }); it("shows element after forwarding to level", [&f]() { - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data { 2,1 }); pq.setup_next_level(); // 2 @@ -1790,7 +1790,7 @@ go_bandit([]() { }); it("shows a level becomes empty", [&f]() { - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data { 2,1 }); pq.setup_next_level(); // 2 @@ -1807,7 +1807,7 @@ go_bandit([]() { }); it("shows forwarding to an empty level", [&f]() { - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data { 3,1 }); pq.setup_next_level(2); // 2 @@ -1960,7 +1960,7 @@ go_bandit([]() { describe(".size()", []{ it("increments on push to bucket [1]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -1968,7 +1968,7 @@ go_bandit([]() { << 1 << 2; // buckets } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); @@ -1980,7 +1980,7 @@ go_bandit([]() { }); it("increments on push to bucket [2]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -1988,7 +1988,7 @@ go_bandit([]() { << 1 << 2; // buckets } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); @@ -2002,7 +2002,7 @@ go_bandit([]() { }); it("increments on push to overflow queue", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2012,7 +2012,7 @@ go_bandit([]() { } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); @@ -2024,7 +2024,7 @@ go_bandit([]() { }); it("decrements on pull from bucket", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2032,7 +2032,7 @@ go_bandit([]() { << 1 << 2; // buckets } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {1, 1}); pq.push(lpq_test_data {1, 2}); @@ -2046,7 +2046,7 @@ go_bandit([]() { }); it("decrements on pull from overflow queue", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2055,7 +2055,7 @@ go_bandit([]() { << 3 << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {4, 1}); pq.push(lpq_test_data {4, 2}); @@ -2069,7 +2069,7 @@ go_bandit([]() { }); it("decrements on pull from bucket", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2077,7 +2077,7 @@ go_bandit([]() { << 1 << 2; // buckets } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {1, 1}); pq.push(lpq_test_data {1, 2}); @@ -2091,7 +2091,7 @@ go_bandit([]() { }); it("decrements on pull from overflow queue", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2100,7 +2100,7 @@ go_bandit([]() { << 3 << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {4, 1}); pq.push(lpq_test_data {4, 2}); @@ -2114,7 +2114,7 @@ go_bandit([]() { }); it("is unchanged on top from bucket", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2122,7 +2122,7 @@ go_bandit([]() { << 1 << 2; // buckets } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {1, 1}); pq.push(lpq_test_data {1, 2}); @@ -2134,7 +2134,7 @@ go_bandit([]() { }); it("is unchanged on top from overflow queue", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2143,7 +2143,7 @@ go_bandit([]() { << 3 << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {4, 1}); pq.push(lpq_test_data {4, 2}); @@ -2178,7 +2178,7 @@ go_bandit([]() { describe(".setup_next_level()", []() { it("can forward until the first non-empty level [1]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2187,7 +2187,7 @@ go_bandit([]() { << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -2206,7 +2206,7 @@ go_bandit([]() { }); it("can forward until the first non-empty level [2]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2215,7 +2215,7 @@ go_bandit([]() { << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -2234,7 +2234,7 @@ go_bandit([]() { }); it("can forward until the first non-empty level [3]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2243,7 +2243,7 @@ go_bandit([]() { << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -2264,7 +2264,7 @@ go_bandit([]() { }); it("can forward until the first non-empty level [4]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2273,7 +2273,7 @@ go_bandit([]() { << 2 << 3 << 4 << 5 << 6; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -2303,7 +2303,7 @@ go_bandit([]() { }); it("can forward until next level [1]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2312,7 +2312,7 @@ go_bandit([]() { << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -2346,7 +2346,7 @@ go_bandit([]() { }); it("can forward until next level [2]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2355,7 +2355,7 @@ go_bandit([]() { << 2 << 3 << 4 << 5; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -2389,7 +2389,7 @@ go_bandit([]() { }); it("can forward until next level [3]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2398,7 +2398,7 @@ go_bandit([]() { << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -2417,7 +2417,7 @@ go_bandit([]() { }); it("can forward until next level [4]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2426,7 +2426,7 @@ go_bandit([]() { << 2 << 3 << 4 << 5 << 6 << 7 << 8; // overflow that will have relabelled bucket(s) } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -2460,7 +2460,7 @@ go_bandit([]() { describe(".setup_next_level(stop_label)", []() { it("forwards to first level", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2469,7 +2469,7 @@ go_bandit([]() { << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -2491,7 +2491,7 @@ go_bandit([]() { }); it("forwards to next level with content [1]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2500,7 +2500,7 @@ go_bandit([]() { << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -2519,7 +2519,7 @@ go_bandit([]() { }); it("stops early at level with content", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2528,7 +2528,7 @@ go_bandit([]() { << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -2545,7 +2545,7 @@ go_bandit([]() { }); it("forwards to unknown level without content [1]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2554,7 +2554,7 @@ go_bandit([]() { << 2 << 4 << 5; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -2574,7 +2574,7 @@ go_bandit([]() { }); it("forwards to stop level [2]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2583,7 +2583,7 @@ go_bandit([]() { << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -2605,7 +2605,7 @@ go_bandit([]() { }); it("forwards to next level with content [2]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2614,7 +2614,7 @@ go_bandit([]() { << 2 << 3 << 4 << 5 << 6; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.can_pull(), Is().False()); @@ -2634,7 +2634,7 @@ go_bandit([]() { }); it("forwards to unknown level without content [2]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -2643,7 +2643,7 @@ go_bandit([]() { << 2 << 3 << 4 << 5 << 6 << 7 << 9 << 10 << 11; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {2, 1}); pq.setup_next_level(); @@ -2938,7 +2938,7 @@ go_bandit([]() { }); it("can push [5]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -2946,7 +2946,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4 << 5 << 6; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {2, 1}); @@ -2985,7 +2985,7 @@ go_bandit([]() { }); it("can push [6]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -2993,7 +2993,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4 << 5 << 6; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {3, 1}); @@ -3023,7 +3023,7 @@ go_bandit([]() { }); it("can push [7]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3031,7 +3031,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4 << 5 << 6 << 7; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {1, 1}); pq.push(lpq_test_data {5, 1}); @@ -3073,7 +3073,7 @@ go_bandit([]() { }); it("can push [8]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3081,7 +3081,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4 << 5 << 6 << 7; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {5, 1}); pq.push(lpq_test_data {6, 1}); @@ -3119,7 +3119,7 @@ go_bandit([]() { }); it("can push [9]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3127,7 +3127,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4 << 5; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {4, 1}); pq.push(lpq_test_data {1, 1}); @@ -3162,7 +3162,7 @@ go_bandit([]() { }); it("can push [10]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3170,7 +3170,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4 << 5; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {4, 1}); pq.push(lpq_test_data {2, 1}); @@ -3205,7 +3205,7 @@ go_bandit([]() { }); it("can set up next level with a stop_label [3]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3213,7 +3213,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {2, 1}); @@ -3247,7 +3247,7 @@ go_bandit([]() { }); it("can set up next level with a stop_label [4]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3255,7 +3255,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4 << 5 << 6; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {4, 1}); @@ -3284,7 +3284,7 @@ go_bandit([]() { }); it("can set up next level with a stop_label [5]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3292,7 +3292,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {2, 1}); pq.push(lpq_test_data {3, 2}); @@ -3318,7 +3318,7 @@ go_bandit([]() { }); it("can set up next level with a stop_label [6]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3326,7 +3326,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4 << 5 << 6 << 7; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {1, 1}); pq.push(lpq_test_data {7, 2}); @@ -3362,7 +3362,7 @@ go_bandit([]() { }); it("can set up next level with a stop_label [7]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3370,7 +3370,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4 << 5 << 6 << 7; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {6, 1}); pq.push(lpq_test_data {7, 2}); @@ -3404,7 +3404,7 @@ go_bandit([]() { }); it("can set up next level with a stop_label [8]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3412,7 +3412,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4 << 5; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {1, 1}); @@ -3443,7 +3443,7 @@ go_bandit([]() { }); it("can set up next level with a stop_label [9]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3451,7 +3451,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4 << 5; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {2, 1}); @@ -3484,7 +3484,7 @@ go_bandit([]() { describe(".pop()", []{ it("can pop [1]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3492,7 +3492,7 @@ go_bandit([]() { << 1 << 2 << 3; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {2,1}); @@ -3506,7 +3506,7 @@ go_bandit([]() { }); it("can pop [2]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3514,7 +3514,7 @@ go_bandit([]() { << 1 << 2 << 3; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {2,1}); pq.push(lpq_test_data {2,2}); @@ -3532,7 +3532,7 @@ go_bandit([]() { }); it("can pop [3]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3540,7 +3540,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {3,1}); @@ -3554,7 +3554,7 @@ go_bandit([]() { }); it("can pop [4]", []() { - adiar::shared_file f; + shared_file f; { label_writer w(f); @@ -3562,7 +3562,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {3,1}); // overflow pq.push(lpq_test_data {2,1}); // bucket @@ -3594,7 +3594,7 @@ go_bandit([]() { ////////////////////////////////////////////////////////////////////////// // .can_pull() // describe(".empty_level() / .can_pull()", []{ - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -3605,14 +3605,14 @@ go_bandit([]() { } it("cannot pull after initialisation", [&f]() { - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.can_pull(), Is().False()); }); it("shows element after forwarding to level", [&f]() { - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data { 2,1 }); pq.setup_next_level(); // 2 @@ -3621,7 +3621,7 @@ go_bandit([]() { }); it("shows a level becomes empty", [&f]() { - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data { 2,1 }); pq.setup_next_level(); // 2 @@ -3638,7 +3638,7 @@ go_bandit([]() { }); it("shows forwarding to an empty level", [&f]() { - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data { 3,1 }); pq.setup_next_level(2); // 2 @@ -3790,7 +3790,7 @@ go_bandit([]() { describe(".size()", []{ it("increments on push to priority queue [1]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -3798,7 +3798,7 @@ go_bandit([]() { << 1 << 2; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); @@ -3810,7 +3810,7 @@ go_bandit([]() { }); it("increments on push to priority queue [2]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -3818,7 +3818,7 @@ go_bandit([]() { << 1 << 2; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); @@ -3832,7 +3832,7 @@ go_bandit([]() { }); it("increments on push to priority queue [3]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -3840,7 +3840,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); @@ -3852,7 +3852,7 @@ go_bandit([]() { }); it("decrements on pull from priority queue [1]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -3860,7 +3860,7 @@ go_bandit([]() { << 1 << 2; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {1, 1}); pq.push(lpq_test_data {1, 2}); @@ -3874,7 +3874,7 @@ go_bandit([]() { }); it("decrements on pull from priority queue [2]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -3882,7 +3882,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {4, 1}); pq.push(lpq_test_data {4, 2}); @@ -3896,7 +3896,7 @@ go_bandit([]() { }); it("decrements on pull from priority queue [3]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -3904,7 +3904,7 @@ go_bandit([]() { << 1 << 2; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {1, 1}); pq.push(lpq_test_data {1, 2}); @@ -3918,7 +3918,7 @@ go_bandit([]() { }); it("decrements on pull from priority queue [4]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -3926,7 +3926,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {4, 1}); pq.push(lpq_test_data {4, 2}); @@ -3940,7 +3940,7 @@ go_bandit([]() { }); it("is unchanged on top from priority queue [1]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -3948,7 +3948,7 @@ go_bandit([]() { << 1 << 2; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {1, 1}); pq.push(lpq_test_data {1, 2}); @@ -3960,7 +3960,7 @@ go_bandit([]() { }); it("is unchanged on top from priority queue [2]", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -3968,7 +3968,7 @@ go_bandit([]() { << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {4, 1}); pq.push(lpq_test_data {4, 2}); @@ -3982,7 +3982,7 @@ go_bandit([]() { }); describe("levelized_priority_queue<..., lpq_test_gt, ..., std::greater<>, ...>", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -3995,7 +3995,7 @@ go_bandit([]() { it("can sort elements from buckets", [&f]() { levelized_priority_queue, 1u, std::greater<>, false, + shared_file, 1u, std::greater<>, false, 1u> pq({f}, memory_available(), 32, stats_lpq_tests); @@ -4031,7 +4031,7 @@ go_bandit([]() { it("can sort elements in overflow priority queue", [&f]() { levelized_priority_queue, 1u, std::greater<>, false, + shared_file, 1u, std::greater<>, false, 1u> pq({f}, memory_available(), 32, stats_lpq_tests); @@ -4054,7 +4054,7 @@ go_bandit([]() { it("can merge elements from buckets and overflow", [&f]() { levelized_priority_queue, 1u, std::greater<>, false, + shared_file, 1u, std::greater<>, false, 1u> pq({f}, memory_available(), 32, stats_lpq_tests); @@ -4097,7 +4097,7 @@ go_bandit([]() { //Fixed (ub) describe("levelized_priority_queue<..., look_ahead=0, lpq_test_gt, ..., std::greater<>, ...>", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -4110,7 +4110,7 @@ go_bandit([]() { it("can sort elements from the priority queue [1]", [&f]() { levelized_priority_queue, 1u, std::greater<>, false, + shared_file, 1u, std::greater<>, false, 1u> pq({f}, memory_available(), 32, stats_lpq_tests); @@ -4146,7 +4146,7 @@ go_bandit([]() { it("can sort elements from the priority queue [2]", [&f]() { levelized_priority_queue, 1u, std::greater<>, false, + shared_file, 1u, std::greater<>, false, 1u> pq({f}, memory_available(), 32, stats_lpq_tests); @@ -4169,7 +4169,7 @@ go_bandit([]() { it("can sort elements from the priority queue [3]", [&f]() { levelized_priority_queue, 1u, std::greater<>, false, + shared_file, 1u, std::greater<>, false, 1u> pq({f}, memory_available(), 32, stats_lpq_tests); @@ -4212,11 +4212,11 @@ go_bandit([]() { describe("levelized_priority_queue<..., look_ahead=1, ..., init_level=0>", []() { it("initialises #levels = 0", []() { - adiar::shared_file f; + shared_file f; levelized_priority_queue, 1u, std::less<>, false, + shared_file, 1u, std::less<>, false, 0u> pq({f}, memory_available(), 32, stats_lpq_tests); @@ -4228,7 +4228,7 @@ go_bandit([]() { }); it("initialises with #levels = 1 < #buckets", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -4237,7 +4237,7 @@ go_bandit([]() { levelized_priority_queue, 1u, std::less<>, false, + shared_file, 1u, std::less<>, false, 0u> pq({f}, memory_available(), 32, stats_lpq_tests); @@ -4249,7 +4249,7 @@ go_bandit([]() { }); it("initialises #buckets <= #levels", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer fw(f); @@ -4258,7 +4258,7 @@ go_bandit([]() { levelized_priority_queue, 1u, std::less<>, false, + shared_file, 1u, std::less<>, false, 0u> pq({f}, memory_available(), 32, stats_lpq_tests); @@ -4552,11 +4552,11 @@ go_bandit([]() { describe("levelized_priority_queue<..., look_ahead=0, ..., init_level=0>", []() { it("initialises correctly", []() { - adiar::shared_file f; + shared_file f; levelized_priority_queue, 1u, std::less<>, false, + shared_file, 1u, std::less<>, false, 0u> pq({f}, memory_available(), 32, stats_lpq_tests); @@ -5473,7 +5473,7 @@ go_bandit([]() { }); it("can push into relabelled buckets", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer w(f); @@ -5483,7 +5483,7 @@ go_bandit([]() { << 5 << 6 << 7 << 8 << 9 << 10; // overflow } - test_priority_queue, 3> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 3> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {5, 2}); // overflow AssertThat(pq.size(), Is().EqualTo(1u)); @@ -5518,7 +5518,7 @@ go_bandit([]() { }); it("can push into relabelled buckets (with stop-level)", []() { - adiar::shared_file f; + shared_file f; { // Garbage collect the writer early label_writer w(f); @@ -5528,7 +5528,7 @@ go_bandit([]() { << 5 << 6 << 7 << 8 << 9 << 10; // overflow } - test_priority_queue, 3> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 3> pq({f}, memory_available(), 32, stats_lpq_tests); pq.push(lpq_test_data {9, 2}); // overflow AssertThat(pq.size(), Is().EqualTo(1u)); diff --git a/test/adiar/internal/io/test_file.cpp b/test/adiar/internal/io/test_file.cpp index ed02ad008..c0d32ed27 100644 --- a/test/adiar/internal/io/test_file.cpp +++ b/test/adiar/internal/io/test_file.cpp @@ -227,18 +227,18 @@ go_bandit([]() { describe("file() + file_stream", []() { it("can attach to and detach from an empty file [con-/destructor]", []() { file f; - adiar::internal::file_stream fs(f); + file_stream fs(f); }); it("can attach to and detach from an empty file [member functions]", []() { file f; - adiar::internal::file_stream fs; + file_stream fs; fs.attach(f); }); it("remembers it was attached", []() { file f; - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.attached(), Is().True()); fs.detach(); AssertThat(fs.attached(), Is().False()); @@ -246,14 +246,14 @@ go_bandit([]() { it("cannot be pulled from", []() { file f; - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().False()); }); it("can be reset", []() { file f; - adiar::internal::file_stream fs(f); + file_stream fs(f); fs.reset(); AssertThat(fs.attached(), Is().True()); @@ -264,18 +264,18 @@ go_bandit([]() { describe("file() + file_writer", [&tmp_path, &curr_path]() { it("can attach to and detach from an empty file [con-/destructor]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); }); it("can attach to and detach from an empty file [member functions]", []() { file f; - adiar::file_writer fw; + file_writer fw; fw.detach(); }); it("remembers it was attached", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); AssertThat(fw.attached(), Is().True()); fw.detach(); AssertThat(fw.attached(), Is().False()); @@ -285,7 +285,7 @@ go_bandit([]() { file f; AssertThat(f.exists(), Is().False()); - adiar::file_writer fw(f); + file_writer fw(f); fw.detach(); AssertThat(f.exists(), Is().True()); @@ -293,7 +293,7 @@ go_bandit([]() { it("reports whether elements were pushed", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); AssertThat(fw.has_pushed(), Is().False()); AssertThat(fw.empty(), Is().True()); @@ -311,7 +311,7 @@ go_bandit([]() { it("changes size when writing content to file [1]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); AssertThat(fw.size(), Is().EqualTo(0u)); fw << 1 << 2; @@ -326,7 +326,7 @@ go_bandit([]() { it("changes size when writing content to file [2]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); AssertThat(fw.size(), Is().EqualTo(0u)); fw << 42; AssertThat(fw.size(), Is().EqualTo(1u)); @@ -346,7 +346,7 @@ go_bandit([]() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 42 << 21; fw.detach(); @@ -371,7 +371,7 @@ go_bandit([]() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 42 << 21; fw.detach(); @@ -392,12 +392,12 @@ go_bandit([]() { it("can read written content [1]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 1 << 2 << 3; fw.detach(); AssertThat(fw.attached(), Is().False()); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(1)); AssertThat(fs.can_pull(), Is().True()); @@ -411,12 +411,12 @@ go_bandit([]() { it("can read written content [2]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 42 << 21; fw.detach(); AssertThat(fw.attached(), Is().False()); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(42)); AssertThat(fs.can_pull(), Is().True()); @@ -428,12 +428,12 @@ go_bandit([]() { it("can read written content in reverse [1]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 1 << 2 << 3; fw.detach(); AssertThat(fw.attached(), Is().False()); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(3)); AssertThat(fs.can_pull(), Is().True()); @@ -447,12 +447,12 @@ go_bandit([]() { it("can read written content in reverse [2]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 42 << 21; fw.detach(); AssertThat(fw.attached(), Is().False()); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(21)); AssertThat(fs.can_pull(), Is().True()); @@ -464,12 +464,12 @@ go_bandit([]() { it("can seek existing elements [forward]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 1 << 2 << 3 << 4 << 5 << 6; fw.detach(); AssertThat(fw.attached(), Is().False()); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.seek(2), Is().EqualTo(2)); AssertThat(fs.can_pull(), Is().True()); @@ -484,12 +484,12 @@ go_bandit([]() { it("can seek existing elements [reverse]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 6 << 5 << 4 << 3 << 2 << 1; fw.detach(); AssertThat(fw.attached(), Is().False()); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.seek(2), Is().EqualTo(2)); AssertThat(fs.can_pull(), Is().True()); @@ -504,12 +504,12 @@ go_bandit([]() { it("can seek non-existing element [forward]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 1 << 2 << 3 << 5 << 6; fw.detach(); AssertThat(fw.attached(), Is().False()); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.seek(2), Is().EqualTo(2)); AssertThat(fs.can_pull(), Is().True()); @@ -520,12 +520,12 @@ go_bandit([]() { it("can seek non-existing element [reverse]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 6 << 5 << 3 << 2 << 1; fw.detach(); AssertThat(fw.attached(), Is().False()); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.seek(2), Is().EqualTo(2)); AssertThat(fs.can_pull(), Is().True()); @@ -536,12 +536,12 @@ go_bandit([]() { it("can seek past end [forward]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 1 << 2 << 3 << 5 << 6; fw.detach(); AssertThat(fw.attached(), Is().False()); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.seek(3), Is().EqualTo(3)); AssertThat(fs.can_pull(), Is().True()); @@ -554,12 +554,12 @@ go_bandit([]() { it("can seek past end [reverse]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 6 << 5 << 3 << 2 << 1; fw.detach(); AssertThat(fw.attached(), Is().False()); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.seek(3), Is().EqualTo(3)); AssertThat(fs.can_pull(), Is().True()); @@ -572,13 +572,13 @@ go_bandit([]() { it("can sort written content", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 42 << 2 << 32 << 21; fw.sort>(); fw.detach(); AssertThat(fw.attached(), Is().False()); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(2)); AssertThat(fs.can_pull(), Is().True()); @@ -600,14 +600,14 @@ go_bandit([]() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 12 << 9 << 1; fw.detach(); AssertThat(f.can_move(), Is().True()); f.move(new_path); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(12)); AssertThat(fs.can_pull(), Is().True()); @@ -627,14 +627,14 @@ go_bandit([]() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 12 << 9 << 1; fw.detach(); AssertThat(f.can_move(), Is().True()); f.move(new_path); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(12)); AssertThat(fs.can_pull(), Is().True()); @@ -654,14 +654,14 @@ go_bandit([]() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 8 << 9 << 4 << 2; fw.detach(); AssertThat(f.can_move(), Is().True()); f.move(new_path); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(2)); AssertThat(fs.can_pull(), Is().True()); @@ -683,14 +683,14 @@ go_bandit([]() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 8 << 9 << 4 << 2; fw.detach(); AssertThat(f.can_move(), Is().True()); f.move(new_path); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(2)); AssertThat(fs.can_pull(), Is().True()); @@ -766,7 +766,7 @@ go_bandit([]() { { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9; fw.detach(); @@ -787,7 +787,7 @@ go_bandit([]() { it("can read content with a stream", [&path]() { file f(path); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(0)); @@ -814,7 +814,7 @@ go_bandit([]() { it("can read content in reverse with a stream", [&path]() { file f(path); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(9)); @@ -841,7 +841,7 @@ go_bandit([]() { it("cannot reattach a writer to a persisted file", [&path]() { file f(path); - adiar::file_writer fw; + file_writer fw; AssertThrows(runtime_error, fw.attach(f)); }); @@ -859,7 +859,7 @@ go_bandit([]() { f.sort>(); AssertThat(f.exists(), Is().False()); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().False()); fs.detach(); }); @@ -872,7 +872,7 @@ go_bandit([]() { f.sort>(); AssertThat(f.exists(), Is().True()); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().False()); fs.detach(); }); @@ -880,13 +880,13 @@ go_bandit([]() { it("can sort non-empty file [1]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 8 << 9 << 4 << 2; fw.detach(); f.sort>(); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(2)); AssertThat(fs.can_pull(), Is().True()); @@ -902,13 +902,13 @@ go_bandit([]() { it("can sort non-empty file [2]", []() { file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 42 << -1 << 8 << 21 << 8 << 3; fw.detach(); f.sort>(); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(-1)); AssertThat(fs.can_pull(), Is().True()); @@ -949,7 +949,7 @@ go_bandit([]() { file f; f.touch(); - adiar::file_writer fw(f); + file_writer fw(f); fw << -1 << 8 << 3; fw.detach(); @@ -963,7 +963,7 @@ go_bandit([]() { { // Check is not sorted file f(path); - adiar::internal::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(-1)); AssertThat(fs.can_pull(), Is().True()); @@ -1010,7 +1010,7 @@ go_bandit([]() { it("can copy over an existing file [non-empty, 1]", []() { file f1; - adiar::file_writer fw(f1); + file_writer fw(f1); fw << 21 << 42 << 21; fw.detach(); @@ -1023,7 +1023,7 @@ go_bandit([]() { AssertThat(f2.size(), Is().EqualTo(3u)); AssertThat(f2.path(), Is().Not().EqualTo(f1.path())); - adiar::internal::file_stream fs(f2); + file_stream fs(f2); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(21)); AssertThat(fs.can_pull(), Is().True()); @@ -1036,7 +1036,7 @@ go_bandit([]() { it("can copy over an existing file [non-empty, 2]", []() { file f1; - adiar::file_writer fw(f1); + file_writer fw(f1); fw << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9; fw.detach(); @@ -1049,7 +1049,7 @@ go_bandit([]() { AssertThat(f2.size(), Is().EqualTo(10u)); AssertThat(f2.path(), Is().Not().EqualTo(f1.path())); - adiar::internal::file_stream fs(f2); + file_stream fs(f2); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(0)); AssertThat(fs.can_pull(), Is().True()); @@ -1086,7 +1086,7 @@ go_bandit([]() { it("is temporary if original file is temporary [non-empty]", []() { file f1; - adiar::file_writer fw(f1); + file_writer fw(f1); fw << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9; fw.detach(); AssertThat(f1.exists(), Is().True()); @@ -1120,7 +1120,7 @@ go_bandit([]() { std::string path; { file f1; - adiar::file_writer fw(f1); + file_writer fw(f1); fw << 0 << 1 << 2 << 3 << 4; fw.detach(); f1.make_persistent(); diff --git a/test/adiar/internal/io/test_shared_file_ptr.cpp b/test/adiar/internal/io/test_shared_file_ptr.cpp index e8c803401..1e269f83c 100644 --- a/test/adiar/internal/io/test_shared_file_ptr.cpp +++ b/test/adiar/internal/io/test_shared_file_ptr.cpp @@ -21,13 +21,13 @@ go_bandit([]() { // TODO: make_shared_file it("is default-constructed as non-nullptr", []() { - adiar::shared_file f; + shared_file f; AssertThat(f.get(), Is().Not().Null()); }); it("is default-constructed as a separate temporary and empty file object", []() { - adiar::shared_file f1; - adiar::shared_file f2; + shared_file f1; + shared_file f2; AssertThat(f1.get(), Is().Not().EqualTo(f2.get())); AssertThat(f1->path(), Is().Not().EqualTo(f2->path())); @@ -41,14 +41,14 @@ go_bandit([]() { }); it("is copy-constructed to share the file object", []() { - adiar::shared_file f1; - adiar::shared_file f2(f1); + shared_file f1; + shared_file f2(f1); AssertThat(f1.get(), Is().EqualTo(f2.get())); }); it("shares the file object after assignment", []() { - adiar::shared_file f1; - adiar::shared_file f2 = f1; + shared_file f1; + shared_file f2 = f1; AssertThat(f1.get(), Is().EqualTo(f2.get())); }); @@ -56,7 +56,7 @@ go_bandit([]() { std::string path; { - adiar::shared_file f; + shared_file f; path = f->path(); AssertThat(std::filesystem::exists(path), Is().False()); f->touch(); @@ -68,7 +68,7 @@ go_bandit([]() { }); it("can 'reset' into a nullptr and trigger deletion of file on disk", []() { - adiar::shared_file f; + shared_file f; f->touch(); const std::string path = f->path(); @@ -80,13 +80,13 @@ go_bandit([]() { }); it("first deletes file on disk when reference count reaches 0 [.reset()]", []() { - adiar::shared_file f1; + shared_file f1; f1->touch(); const std::string path = f1->path(); AssertThat(std::filesystem::exists(path), Is().True()); - adiar::shared_file f2(f1); + shared_file f2(f1); AssertThat(std::filesystem::exists(path), Is().True()); @@ -102,13 +102,13 @@ go_bandit([]() { it("first deletes file on disk when reference count reaches 0 [scope]", []() { std::string path; { - adiar::shared_file f1; + shared_file f1; f1->touch(); path = f1->path(); AssertThat(std::filesystem::exists(path), Is().True()); { - adiar::shared_file f2 = f1; + shared_file f2 = f1; AssertThat(std::filesystem::exists(path), Is().True()); } AssertThat(std::filesystem::exists(path), Is().True()); @@ -120,9 +120,9 @@ go_bandit([]() { it("file_writer is part of reference counting", []() { std::string path; - adiar::file_writer fw; + file_writer fw; { - adiar::shared_file f; + shared_file f; path = f->path(); fw.attach(f); AssertThat(std::filesystem::exists(path), Is().True()); @@ -135,9 +135,9 @@ go_bandit([]() { it("file_stream is part of reference counting", []() { std::string path; - adiar::file_stream fs; + file_stream fs; { - adiar::shared_file f; + shared_file f; path = f->path(); fs.attach(f); AssertThat(std::filesystem::exists(path), Is().True()); @@ -148,13 +148,13 @@ go_bandit([]() { }); it("can read written content", []() { - adiar::shared_file f; + shared_file f; { - adiar::file_writer fw(f); + file_writer fw(f); fw << 1 << 2 << 3 << 4; } { - adiar::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(1)); AssertThat(fs.can_pull(), Is().True()); @@ -168,13 +168,13 @@ go_bandit([]() { }); it("can read written content in reverse", []() { - adiar::shared_file f; + shared_file f; { - adiar::file_writer fw(f); + file_writer fw(f); fw << 21 << 42 << 21 << 84; } { - adiar::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(84)); AssertThat(fs.can_pull(), Is().True()); @@ -192,34 +192,34 @@ go_bandit([]() { describe("::copy(...)", []() { it("can copy over empty file", []() { - adiar::shared_file f1; + shared_file f1; AssertThat(f1->exists(), Is().False()); f1->touch(); AssertThat(f1->exists(), Is().True()); AssertThat(f1->empty(), Is().True()); - adiar::shared_file f2 = adiar::shared_file::copy(f1); + shared_file f2 = shared_file::copy(f1); AssertThat(f2->exists(), Is().True()); AssertThat(f1->path(), Is().Not().EqualTo(f2->path())); }); it("can copy over non-empty file", []() { - adiar::shared_file f1; + shared_file f1; { - adiar::file_writer fw(f1); + file_writer fw(f1); fw << 1 << 2 << 4 << 8 << 16; } - adiar::shared_file f2 = adiar::shared_file::copy(f1); + shared_file f2 = shared_file::copy(f1); // Check path AssertThat(f2->path(), Is().Not().EqualTo(f1->path())); // Check content { - adiar::file_stream fs(f2); + file_stream fs(f2); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(1)); AssertThat(fs.can_pull(), Is().True()); @@ -244,9 +244,9 @@ go_bandit([]() { } { // Create a persisted file - adiar::shared_file f; + shared_file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 0 << 2 << 4 << 6 << 8; // TODO: header file content @@ -257,9 +257,9 @@ go_bandit([]() { } { - adiar::shared_file f(file_path); + shared_file f(file_path); - adiar::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(0)); AssertThat(fs.can_pull(), Is().True()); @@ -290,9 +290,9 @@ go_bandit([]() { } { // Create a persisted file - adiar::shared_file f; + shared_file f; - adiar::file_writer fw(f); + file_writer fw(f); fw << 1 << 3 << 5 << 7; // TODO: header file content @@ -303,9 +303,9 @@ go_bandit([]() { } { - adiar::shared_file f(file_path); + shared_file f(file_path); - adiar::file_stream fs(f); + file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); AssertThat(fs.pull(), Is().EqualTo(1)); AssertThat(fs.can_pull(), Is().True()); diff --git a/test/adiar/test_domain.cpp b/test/adiar/test_domain.cpp index ba4198bbe..e942ec428 100644 --- a/test/adiar/test_domain.cpp +++ b/test/adiar/test_domain.cpp @@ -13,7 +13,7 @@ go_bandit([]() { describe("domain_isset(), domain_set(...), domain_unset()", []() { it("has domain after 'domain_set(file)'", []() { - adiar::shared_file dom; + shared_file dom; { // Garbage collect writer to free write-lock label_writer lw(dom); @@ -51,7 +51,7 @@ go_bandit([]() { AssertThat(domain_isset(), Is().True()); - adiar::file_stream ls(domain_get()); + file_stream ls(domain_get()); AssertThat(ls.can_pull(), Is().False()); }); @@ -62,7 +62,7 @@ go_bandit([]() { AssertThat(domain_isset(), Is().True()); - adiar::file_stream ls(domain_get()); + file_stream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(0u)); @@ -76,7 +76,7 @@ go_bandit([]() { AssertThat(domain_isset(), Is().True()); - adiar::file_stream ls(domain_get()); + file_stream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(0u)); @@ -109,7 +109,7 @@ go_bandit([]() { { AssertThat(domain_isset(), Is().True()); - adiar::file_stream ls(domain_get()); + file_stream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(0u)); @@ -127,7 +127,7 @@ go_bandit([]() { { AssertThat(domain_isset(), Is().True()); - adiar::file_stream ls(domain_get()); + file_stream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(0u)); @@ -156,7 +156,7 @@ go_bandit([]() { domain_set(gen); AssertThat(domain_isset(), Is().True()); - adiar::file_stream ls(domain_get()); + file_stream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(1u)); @@ -188,7 +188,7 @@ go_bandit([]() { AssertThat(domain_isset(), Is().True()); - adiar::file_stream ls(domain_get()); + file_stream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(0u)); @@ -217,7 +217,7 @@ go_bandit([]() { { // Check for xs AssertThat(domain_isset(), Is().True()); - adiar::file_stream ls(domain_get()); + file_stream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(2u)); @@ -237,7 +237,7 @@ go_bandit([]() { { // Check for ys AssertThat(domain_isset(), Is().True()); - adiar::file_stream ls(domain_get()); + file_stream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(0u)); @@ -252,7 +252,7 @@ go_bandit([]() { it("gives back the given domain file", []() { domain_unset(); - adiar::shared_file dom; + shared_file dom; { // Garbage collect writer to free write-lock label_writer lw(dom); @@ -268,7 +268,7 @@ go_bandit([]() { it("can overwrite with another domain file", []() { domain_unset(); - adiar::shared_file dom1; + shared_file dom1; { // Garbage collect writer to free write-lock label_writer lw(dom1); @@ -280,7 +280,7 @@ go_bandit([]() { AssertThat(domain_isset(), Is().True()); AssertThat(domain_get(), Is().EqualTo(dom1)); - adiar::shared_file dom2; + shared_file dom2; { // Garbage collect writer to free write-lock label_writer lw(dom2); diff --git a/test/adiar/zdd/test_project.cpp b/test/adiar/zdd/test_project.cpp index c222a77d1..0e8d8418b 100644 --- a/test/adiar/zdd/test_project.cpp +++ b/test/adiar/zdd/test_project.cpp @@ -258,7 +258,7 @@ go_bandit([]() { const exec_policy &ep = exec_policy::quantify::Singleton; it("computes with dom = Ø to be { Ø } for non-empty input [zdd_1] [const &]", [&](){ - adiar::shared_file dom; + shared_file dom; const zdd in = zdd_1; zdd out = zdd_project(ep, in, [](zdd::label_type) { return false; }); @@ -282,7 +282,7 @@ go_bandit([]() { }); it("computes with dom = Ø to be { Ø } for non-empty input [zdd_2] [&&]", [&](){ - adiar::shared_file dom; + shared_file dom; zdd out = zdd_project(ep, zdd(zdd_2), [](zdd::label_type) { return false; }); @@ -794,7 +794,7 @@ go_bandit([]() { const exec_policy ep = exec_policy::quantify::Nested; it("computes with dom = Ø to be { Ø } for non-empty input [zdd_1]", [&](){ - adiar::shared_file dom; + shared_file dom; const zdd in = zdd_1; zdd out = zdd_project(ep, in, [](zdd::label_type) { return false; }); @@ -946,7 +946,7 @@ go_bandit([]() { const exec_policy ep = exec_policy::quantify::Auto; it("computes with dom = Ø to be { Ø } for non-empty input [zdd_2]", [&](){ - adiar::shared_file dom; + shared_file dom; zdd out = zdd_project(ep, zdd(zdd_2), [](zdd::label_type) { return false; }); @@ -1662,7 +1662,7 @@ go_bandit([]() { } it("returns { Ø } for {1} with dom = {0} [const &]", [&](){ - adiar::shared_file dom; + shared_file dom; { label_writer lw(dom); lw << 0; } @@ -1698,7 +1698,7 @@ go_bandit([]() { }); it("returns { 1 } for {1} with dom = {1,0} [const &]", [&](){ - adiar::shared_file dom; + shared_file dom; { label_writer lw(dom); lw << 0 << 1; } @@ -2150,7 +2150,7 @@ go_bandit([]() { } it("returns { Ø } for {1} with dom = {0} [const &]", [&](){ - adiar::shared_file dom; + shared_file dom; { label_writer lw(dom); lw << 0; } @@ -2186,7 +2186,7 @@ go_bandit([]() { }); it("returns { 1 } for {1} with dom = {1,0} [const &]", [&](){ - adiar::shared_file dom; + shared_file dom; { label_writer lw(dom); lw << 0 << 1; } diff --git a/test/adiar/zdd/test_zdd.cpp b/test/adiar/zdd/test_zdd.cpp index 6f1a05277..ad08c92f3 100644 --- a/test/adiar/zdd/test_zdd.cpp +++ b/test/adiar/zdd/test_zdd.cpp @@ -138,7 +138,7 @@ go_bandit([]() { }); it("should compute {{0},{1}}' == {Ø,{0,1}} with dom {0,1}", [&]() { - adiar::shared_file dom; + shared_file dom; { label_writer lw(dom); lw << 0 << 1; @@ -162,7 +162,7 @@ go_bandit([]() { }); it("should compute with __zdd&& operators [|,~,-,]", [&]() { - adiar::shared_file dom; + shared_file dom; { label_writer lw(dom); lw << 0 << 1;