From 590ed15845e63bb9d376a8640cf0aadfe657498f Mon Sep 17 00:00:00 2001 From: Sanya239 Date: Thu, 2 Apr 2026 14:15:27 +0300 Subject: [PATCH 1/8] add bp_tree.h --- include/pixie/bp_tree.h | 131 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 include/pixie/bp_tree.h diff --git a/include/pixie/bp_tree.h b/include/pixie/bp_tree.h new file mode 100644 index 0000000..c267dfe --- /dev/null +++ b/include/pixie/bp_tree.h @@ -0,0 +1,131 @@ +#pragma once + +#include + +#include +#include + +namespace pixie { +/** + * @brief A node class of BP tree + */ +struct BpNode { + size_t number; + size_t pos; + + BpNode(size_t node_number, size_t bp_pos) + : number(node_number), pos(bp_pos) {} +}; + +/** + * @brief A tree class based on the balances parentheses (BP) + * representation + */ +class BpTree { + private: + const size_t num_bits_; + RmMTree rmm; + + public: + /** + * @brief Constructor from an external array of uint64_t + */ + explicit BpTree(const std::vector& words, size_t tree_size) + : num_bits_(2 * tree_size), rmm(words, 2 * tree_size) {} + + /** + * @brief Returns the root node + */ + BpNode root() const { return BpNode(0, 0); } + + /** + * @brief Returns the size of the tree + */ + size_t size() const { return num_bits_; } + + /** + * @brief Indicates if @p node is a leaf + */ + bool is_leaf(const BpNode& node) const { + return (node.pos + 1 == num_bits_) or rmm.bit(node.pos + 1) == 0; + } + + /** + * @brief Returns the number of children of a @p node + * this method has O(d) time complexity! + * + * TODO try make this faster + */ + size_t degree(const BpNode& node) const { + if (is_leaf(node)) { + return 0; + } + BpNode child = first_child(node); + int child_count = 1; + while (true) { + if (is_last_child(child)) { + return child_count; + } + child = next_sibling(child); + child_count++; + } + } + + /** + * @brief Returns first child of a @p node + */ + BpNode first_child(const BpNode& node) const { + size_t pos = node.pos + 1; + size_t num = node.number + 1; + return BpNode(num, pos); + } + + /** + * @brief Returns the i-th child of @p node + * Indexing starts at 0 + * this method has O(i) time complexity! + * + * TODO try make this faster + */ + BpNode child(const BpNode& node, size_t i) const { + BpNode child = first_child(node); + while (i--) { + child = next_sibling(child); + } + return child; + } + + /** + * @brief Returns the parent of a @p node if @p node is not root, + * else returns root + */ + BpNode parent(const BpNode& node) const { + if (node.number == 0) { + return root(); + } + size_t pos = rmm.enclose(node.pos); + size_t num = rmm.rank1(pos); + return BpNode(num, pos); + } + + /** + * @brief Indicates if @p node is last child + */ + bool is_last_child(const BpNode& node) const { + size_t end = rmm.close(node.pos); + if (end + 1 >= num_bits_) { + return true; + } + return rmm.bit(end + 1) == 0; + } + + /** + * @brief Returns next sibling of a @p node + */ + BpNode next_sibling(const BpNode& node) const { + size_t pos = rmm.close(node.pos) + 1; + size_t num = rmm.rank1(pos); + return BpNode(num, pos); + } +}; +} // namespace pixie From 6ec3bb84b0a945bcfe87e75c7a7d18bafa009dd4 Mon Sep 17 00:00:00 2001 From: Sanya239 Date: Mon, 6 Apr 2026 17:27:33 +0300 Subject: [PATCH 2/8] make RmMTree.bit() public --- include/pixie/rmm_tree.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/pixie/rmm_tree.h b/include/pixie/rmm_tree.h index fe8bbe7..204fc4e 100644 --- a/include/pixie/rmm_tree.h +++ b/include/pixie/rmm_tree.h @@ -2215,6 +2215,7 @@ class RmMTree { build(leaf_block_bits, max_overhead); } + public: /** * @brief Read bit at position @p position (LSB-first across words). */ @@ -2222,6 +2223,7 @@ class RmMTree { return (bits[position >> 6] >> (position & 63)) & 1u; } + private: /** * @brief Set bit at position @p position to 1. */ From d9e37c1846748e471fb8bbdb6ff555d37f4f5233 Mon Sep 17 00:00:00 2001 From: Sanya239 Date: Sun, 19 Apr 2026 19:10:44 +0300 Subject: [PATCH 3/8] fix bp tree --- include/pixie/bp_tree.h | 20 ++++++++++++-------- include/pixie/rmm_tree.h | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/include/pixie/bp_tree.h b/include/pixie/bp_tree.h index c267dfe..d73bc6c 100644 --- a/include/pixie/bp_tree.h +++ b/include/pixie/bp_tree.h @@ -3,7 +3,6 @@ #include #include -#include namespace pixie { /** @@ -36,7 +35,7 @@ class BpTree { /** * @brief Returns the root node */ - BpNode root() const { return BpNode(0, 0); } + static BpNode root() { return BpNode(0, 0); } /** * @brief Returns the size of the tree @@ -50,6 +49,11 @@ class BpTree { return (node.pos + 1 == num_bits_) or rmm.bit(node.pos + 1) == 0; } + /** + * @brief Indicates if @p node is a root + */ + static bool is_root(const BpNode& node) { return node.number == 0; } + /** * @brief Returns the number of children of a @p node * this method has O(d) time complexity! @@ -74,7 +78,7 @@ class BpTree { /** * @brief Returns first child of a @p node */ - BpNode first_child(const BpNode& node) const { + static BpNode first_child(const BpNode& node) { size_t pos = node.pos + 1; size_t num = node.number + 1; return BpNode(num, pos); @@ -103,8 +107,8 @@ class BpTree { if (node.number == 0) { return root(); } - size_t pos = rmm.enclose(node.pos); - size_t num = rmm.rank1(pos); + size_t pos = rmm.enclose(node.pos + 1); + size_t num = rmm.rank1(pos) - 1; return BpNode(num, pos); } @@ -112,7 +116,7 @@ class BpTree { * @brief Indicates if @p node is last child */ bool is_last_child(const BpNode& node) const { - size_t end = rmm.close(node.pos); + size_t end = rmm.close(node.pos + 1); if (end + 1 >= num_bits_) { return true; } @@ -123,8 +127,8 @@ class BpTree { * @brief Returns next sibling of a @p node */ BpNode next_sibling(const BpNode& node) const { - size_t pos = rmm.close(node.pos) + 1; - size_t num = rmm.rank1(pos); + size_t pos = rmm.close(node.pos + 1) + 1; + size_t num = rmm.rank1(pos + 1) - 1; return BpNode(num, pos); } }; diff --git a/include/pixie/rmm_tree.h b/include/pixie/rmm_tree.h index 204fc4e..db703a3 100644 --- a/include/pixie/rmm_tree.h +++ b/include/pixie/rmm_tree.h @@ -2195,7 +2195,23 @@ class RmMTree { } build(leaf_block_bits, max_overhead); } +public: + /** + * @brief Export internal bitvector into a 0/1 string. + */ + std::string to_string() const { + std::string result; + result.resize(num_bits); + + for (size_t i = 0; i < num_bits; ++i) { + uint64_t word = bits[i >> 6]; + bool bit = (word >> (i & 63)) & 1ULL; + result[i] = bit ? '1' : '0'; + } + return result; + } +private: /** * @brief Build internal structures from 64-bit words. * @param words Words with LSB-first bits. From bd5375c3dbcef8a8848f18bdf6482816ded1fadd Mon Sep 17 00:00:00 2001 From: Sanya239 Date: Sun, 19 Apr 2026 19:11:02 +0300 Subject: [PATCH 4/8] add bp tree tests --- CMakeLists.txt | 9 +++ include/pixie/utils.h | 60 ++++++++++++++++++++ src/tests/bp_tree_tests.cpp | 110 ++++++++++++++++++++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 src/tests/bp_tree_tests.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 01444ac..e1cd006 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,6 +157,15 @@ if(PIXIE_TESTS) gtest gtest_main ${PIXIE_DIAGNOSTICS_LIBS}) + + add_executable(bp_tree_tests + src/tests/bp_tree_tests.cpp) + target_include_directories(bp_tree_tests + PUBLIC include) + target_link_libraries(bp_tree_tests + gtest + gtest_main + ${PIXIE_DIAGNOSTICS_LIBS}) endif() # --------------------------------------------------------------------------- diff --git a/include/pixie/utils.h b/include/pixie/utils.h index 24116d5..2c5f2f8 100644 --- a/include/pixie/utils.h +++ b/include/pixie/utils.h @@ -6,6 +6,9 @@ #include #include +#include "bp_tree.h" + +using pixie::BpNode; using pixie::LoudsNode; std::vector> generate_random_tree(size_t tree_size, @@ -46,6 +49,32 @@ std::vector> bfs_order( return bfs_adj; } +std::vector> dfs_order( + size_t tree_size, + const std::vector>& adj) { + std::vector> dfs_adj(tree_size); + std::vector> stack; + dfs_adj[0].push_back(0); + stack.push_back({0, 0}); + std::vector renumbering(tree_size, 0); + size_t next_number = 1; + while (!stack.empty()) { + auto& [v, i] = stack.back(); + i++; + if (i == adj[v].size()) { + stack.pop_back(); + continue; + } + size_t u = adj[v][i]; + renumbering[u] = next_number++; + dfs_adj[renumbering[v]].push_back(renumbering[u]); + dfs_adj[renumbering[u]].push_back(renumbering[v]); + + stack.push_back(std::pair{u, 0}); + } + return dfs_adj; +} + std::vector adj_to_louds( size_t tree_size, const std::vector>& adj) { @@ -59,6 +88,29 @@ std::vector adj_to_louds( return louds; } +std::vector adj_to_bp(size_t tree_size, + const std::vector>& adj) { + size_t bp_size = tree_size * 2; + std::vector bp((bp_size + 63) / 64, 0); + std::vector> stack; + stack.push_back(std::make_pair(0, 0)); + int pos = 0; + bp[pos >> 6] = bp[pos >> 6] | (1ULL << (pos & 63)); + while (!stack.empty()) { + auto& [v, p] = stack.back(); + p++; + if (p >= adj[v].size()) { + pos++; + stack.pop_back(); + continue; + } + pos++; + bp[pos >> 6] = bp[pos >> 6] | (1ULL << (pos & 63)); + stack.push_back(std::make_pair(adj[v][p], 0)); + } + return bp; +} + struct AdjListNode { size_t number; }; @@ -71,6 +123,14 @@ bool operator==(const LoudsNode& b, const AdjListNode& a) { return a.number == b.number; } +bool operator==(const AdjListNode& a, const BpNode& b) { + return a.number == b.number; +} + +bool operator==(const BpNode& b, const AdjListNode& a) { + return a.number == b.number; +} + class AdjListTree { private: std::vector> adj; diff --git a/src/tests/bp_tree_tests.cpp b/src/tests/bp_tree_tests.cpp new file mode 100644 index 0000000..f262c5c --- /dev/null +++ b/src/tests/bp_tree_tests.cpp @@ -0,0 +1,110 @@ +#include "pixie/bp_tree.h" + +#include +#include + +#include +#include + +using pixie::BpNode; +using pixie::BpTree; + +TEST(BpTreeTest, Basic) { + std::vector> adj = {{0, 1}, {0, 2}, {1, 3}, {2, 4}, {3}}; + size_t tree_size = 5; + + std::vector bp = adj_to_bp(tree_size, adj); + + BpTree bp_tree(bp, 5); + AdjListTree debug_tree(adj); + + BpNode cur = bp_tree.root(); + AdjListNode debug = debug_tree.root(); + for (size_t i = 0; i < tree_size - 1; i++) { + EXPECT_EQ(cur, debug); + cur = bp_tree.child(cur, 0); + debug = debug_tree.child(debug, 0); + } + EXPECT_EQ(cur, debug); +} + +TEST(BpTreeTest, RandomTreeDFS) { + for (size_t tree_size = 8; tree_size < (1 << 22); tree_size <<= 1) { + std::mt19937_64 rng(42); + std::vector> adj = generate_random_tree(tree_size, rng); + adj = dfs_order(tree_size, adj); + std::vector bp = adj_to_bp(tree_size, adj); + BpTree bp_tree(bp, tree_size); + AdjListTree debug_tree(adj); + + std::stack> st; + + st.push({bp_tree.root(), debug_tree.root()}); + + while (!st.empty()) { + auto cur = st.top().first; + auto debug = st.top().second; + st.pop(); + EXPECT_EQ(cur, debug); + EXPECT_EQ(bp_tree.parent(cur), debug_tree.parent(debug)); + + if (cur.number > 0) { + EXPECT_EQ(bp_tree.is_last_child(cur), debug_tree.is_last_child(debug)); + } + size_t deg = bp_tree.degree(cur); + EXPECT_EQ(deg, debug_tree.degree(debug)); + + if (deg == 0) { + continue; + } + auto child = bp_tree.first_child(cur); + auto debug_child = debug_tree.first_child(debug); + st.push({child, debug_child}); + for (size_t i = 1; i < deg; i++) { + child = bp_tree.next_sibling(child); + st.push({child, debug_tree.child(debug, i)}); + } + } + } +} + + +TEST(BpTreeTest, RandomTreeBFS) { + for (size_t tree_size = 8; tree_size < (1 << 22); tree_size <<= 1) { + std::mt19937_64 rng(42); + std::vector> adj = generate_random_tree(tree_size, rng); + adj = dfs_order(tree_size, adj); + std::vector bp = adj_to_bp(tree_size, adj); + BpTree bp_tree(bp, tree_size); + AdjListTree debug_tree(adj); + + std::queue> st; + + st.push({bp_tree.root(), debug_tree.root()}); + + while (!st.empty()) { + auto cur = st.front().first; + auto debug = st.front().second; + st.pop(); + EXPECT_EQ(bp_tree.parent(cur), debug_tree.parent(debug)); + + if (cur.number > 0) { + EXPECT_EQ(bp_tree.is_last_child(cur), debug_tree.is_last_child(debug)); + } + size_t deg = bp_tree.degree(cur); + EXPECT_EQ(deg, debug_tree.degree(debug)); + + if (deg == 0) { + continue; + } + auto child = bp_tree.first_child(cur); + auto debug_child = debug_tree.first_child(debug); + st.push({child, debug_child}); + for (size_t i = 1; i < deg; i++) { + child = bp_tree.next_sibling(child); + st.push({child, debug_tree.child(debug, i)}); + } + } + } +} + From e397ba99c27771f4b19c88a3dabc2d7bc78b2312 Mon Sep 17 00:00:00 2001 From: Sanya239 Date: Sun, 19 Apr 2026 19:28:59 +0300 Subject: [PATCH 5/8] fix kilo-code warnings --- include/pixie/bp_tree.h | 4 ++-- include/pixie/utils.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/pixie/bp_tree.h b/include/pixie/bp_tree.h index d73bc6c..854e200 100644 --- a/include/pixie/bp_tree.h +++ b/include/pixie/bp_tree.h @@ -40,7 +40,7 @@ class BpTree { /** * @brief Returns the size of the tree */ - size_t size() const { return num_bits_; } + size_t size() const { return num_bits_ / 2; } /** * @brief Indicates if @p node is a leaf @@ -65,7 +65,7 @@ class BpTree { return 0; } BpNode child = first_child(node); - int child_count = 1; + size_t child_count = 1; while (true) { if (is_last_child(child)) { return child_count; diff --git a/include/pixie/utils.h b/include/pixie/utils.h index 2c5f2f8..3dc5c4b 100644 --- a/include/pixie/utils.h +++ b/include/pixie/utils.h @@ -33,7 +33,7 @@ std::vector> bfs_order( std::queue> q; bfs_adj[0].push_back(0); q.push({0, 0}); - int cnt = 1; + size_t cnt = 1; while (!q.empty()) { size_t old_v = q.front().first; size_t cur_v = q.front().second; @@ -92,9 +92,9 @@ std::vector adj_to_bp(size_t tree_size, const std::vector>& adj) { size_t bp_size = tree_size * 2; std::vector bp((bp_size + 63) / 64, 0); - std::vector> stack; + std::vector> stack; stack.push_back(std::make_pair(0, 0)); - int pos = 0; + size_t pos = 0; bp[pos >> 6] = bp[pos >> 6] | (1ULL << (pos & 63)); while (!stack.empty()) { auto& [v, p] = stack.back(); From 12b763b336f57e432728ec9907577f56c6f36a18 Mon Sep 17 00:00:00 2001 From: Sanya239 Date: Fri, 15 May 2026 02:00:31 +0300 Subject: [PATCH 6/8] fix suggestions --- .github/workflows/build-test.yml | 16 ++++++++++ include/pixie/bp_tree.h | 50 +++++++++++++++++--------------- include/pixie/rmm_tree.h | 16 +++++----- include/pixie/utils.h | 6 ++-- src/tests/bp_tree_tests.cpp | 8 ++--- 5 files changed, 56 insertions(+), 40 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index b383db9..75f6435 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -32,6 +32,10 @@ jobs: working-directory: ./build run: ./louds_tree_tests + - name: Run BP Tree Tests + working-directory: ./build + run: ./bp_tree_tests + - name: Run Benchmark Tests working-directory: ./build run: ./benchmark_tests @@ -92,3 +96,15 @@ jobs: fi exit $rc + - name: Run BP Tree Tests + working-directory: ./build + run: | + timeout 1800 sde-external-9.58.0-2025-06-16-lin/sde64 -icl -emu-xinuse 0 -- \ + ./bp_tree_tests --gtest_output=xml:bp_results.xml + rc=$? + if [ $rc -eq 124 ] && grep -q 'failures="0"' bp_results.xml 2>/dev/null; then + echo "SDE timed out during process teardown (known SDE/ASan issue) - all tests passed, treating as success" + exit 0 + fi + exit $rc + diff --git a/include/pixie/bp_tree.h b/include/pixie/bp_tree.h index 854e200..cb53922 100644 --- a/include/pixie/bp_tree.h +++ b/include/pixie/bp_tree.h @@ -5,16 +5,6 @@ #include namespace pixie { -/** - * @brief A node class of BP tree - */ -struct BpNode { - size_t number; - size_t pos; - - BpNode(size_t node_number, size_t bp_pos) - : number(node_number), pos(bp_pos) {} -}; /** * @brief A tree class based on the balances parentheses (BP) @@ -26,6 +16,18 @@ class BpTree { RmMTree rmm; public: + + /** + * @brief A node class of BP tree + */ + struct Node { + size_t number; + size_t pos; + + Node(size_t node_number, size_t bp_pos) + : number(node_number), pos(bp_pos) {} + }; + /** * @brief Constructor from an external array of uint64_t */ @@ -35,7 +37,7 @@ class BpTree { /** * @brief Returns the root node */ - static BpNode root() { return BpNode(0, 0); } + Node root() const { return Node(0, 0); } /** * @brief Returns the size of the tree @@ -45,14 +47,14 @@ class BpTree { /** * @brief Indicates if @p node is a leaf */ - bool is_leaf(const BpNode& node) const { + bool is_leaf(const Node& node) const { return (node.pos + 1 == num_bits_) or rmm.bit(node.pos + 1) == 0; } /** * @brief Indicates if @p node is a root */ - static bool is_root(const BpNode& node) { return node.number == 0; } + bool is_root(const Node& node) { return node.number == 0; } /** * @brief Returns the number of children of a @p node @@ -60,11 +62,11 @@ class BpTree { * * TODO try make this faster */ - size_t degree(const BpNode& node) const { + size_t degree(const Node& node) const { if (is_leaf(node)) { return 0; } - BpNode child = first_child(node); + Node child = first_child(node); size_t child_count = 1; while (true) { if (is_last_child(child)) { @@ -78,10 +80,10 @@ class BpTree { /** * @brief Returns first child of a @p node */ - static BpNode first_child(const BpNode& node) { + Node first_child(const Node& node) const{ size_t pos = node.pos + 1; size_t num = node.number + 1; - return BpNode(num, pos); + return Node(num, pos); } /** @@ -91,8 +93,8 @@ class BpTree { * * TODO try make this faster */ - BpNode child(const BpNode& node, size_t i) const { - BpNode child = first_child(node); + Node child(const Node& node, size_t i) const { + Node child = first_child(node); while (i--) { child = next_sibling(child); } @@ -103,19 +105,19 @@ class BpTree { * @brief Returns the parent of a @p node if @p node is not root, * else returns root */ - BpNode parent(const BpNode& node) const { + Node parent(const Node& node) const { if (node.number == 0) { return root(); } size_t pos = rmm.enclose(node.pos + 1); size_t num = rmm.rank1(pos) - 1; - return BpNode(num, pos); + return Node(num, pos); } /** * @brief Indicates if @p node is last child */ - bool is_last_child(const BpNode& node) const { + bool is_last_child(const Node& node) const { size_t end = rmm.close(node.pos + 1); if (end + 1 >= num_bits_) { return true; @@ -126,10 +128,10 @@ class BpTree { /** * @brief Returns next sibling of a @p node */ - BpNode next_sibling(const BpNode& node) const { + Node next_sibling(const Node& node) const { size_t pos = rmm.close(node.pos + 1) + 1; size_t num = rmm.rank1(pos + 1) - 1; - return BpNode(num, pos); + return Node(num, pos); } }; } // namespace pixie diff --git a/include/pixie/rmm_tree.h b/include/pixie/rmm_tree.h index db703a3..6507c00 100644 --- a/include/pixie/rmm_tree.h +++ b/include/pixie/rmm_tree.h @@ -966,6 +966,13 @@ class RmMTree { return (result == npos ? npos : result + 1); } + /** + * @brief Read bit at position @p position (LSB-first across words). + */ + inline int bit(const size_t& position) const noexcept { + return (bits[position >> 6] >> (position & 63)) & 1u; + } + private: /** * @brief Count "10" occurrences inside a 64-bit slice of given logical @@ -2231,15 +2238,6 @@ class RmMTree { build(leaf_block_bits, max_overhead); } - public: - /** - * @brief Read bit at position @p position (LSB-first across words). - */ - inline int bit(const size_t& position) const noexcept { - return (bits[position >> 6] >> (position & 63)) & 1u; - } - - private: /** * @brief Set bit at position @p position to 1. */ diff --git a/include/pixie/utils.h b/include/pixie/utils.h index 3dc5c4b..8416dab 100644 --- a/include/pixie/utils.h +++ b/include/pixie/utils.h @@ -8,7 +8,7 @@ #include "bp_tree.h" -using pixie::BpNode; +using Node = pixie::BpTree::Node; using pixie::LoudsNode; std::vector> generate_random_tree(size_t tree_size, @@ -123,11 +123,11 @@ bool operator==(const LoudsNode& b, const AdjListNode& a) { return a.number == b.number; } -bool operator==(const AdjListNode& a, const BpNode& b) { +bool operator==(const AdjListNode& a, const Node& b) { return a.number == b.number; } -bool operator==(const BpNode& b, const AdjListNode& a) { +bool operator==(const Node& b, const AdjListNode& a) { return a.number == b.number; } diff --git a/src/tests/bp_tree_tests.cpp b/src/tests/bp_tree_tests.cpp index f262c5c..dd69baf 100644 --- a/src/tests/bp_tree_tests.cpp +++ b/src/tests/bp_tree_tests.cpp @@ -6,7 +6,7 @@ #include #include -using pixie::BpNode; +using Node = pixie::BpTree::Node; using pixie::BpTree; TEST(BpTreeTest, Basic) { @@ -18,7 +18,7 @@ TEST(BpTreeTest, Basic) { BpTree bp_tree(bp, 5); AdjListTree debug_tree(adj); - BpNode cur = bp_tree.root(); + Node cur = bp_tree.root(); AdjListNode debug = debug_tree.root(); for (size_t i = 0; i < tree_size - 1; i++) { EXPECT_EQ(cur, debug); @@ -37,7 +37,7 @@ TEST(BpTreeTest, RandomTreeDFS) { BpTree bp_tree(bp, tree_size); AdjListTree debug_tree(adj); - std::stack> st; + std::stack> st; st.push({bp_tree.root(), debug_tree.root()}); @@ -78,7 +78,7 @@ TEST(BpTreeTest, RandomTreeBFS) { BpTree bp_tree(bp, tree_size); AdjListTree debug_tree(adj); - std::queue> st; + std::queue> st; st.push({bp_tree.root(), debug_tree.root()}); From 2f49504c4eee947a864c1a253a40d456ab4d3c8f Mon Sep 17 00:00:00 2001 From: Sanya239 Date: Sat, 16 May 2026 02:06:18 +0300 Subject: [PATCH 7/8] add bp to coverage_report.sh --- scripts/coverage_report.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/coverage_report.sh b/scripts/coverage_report.sh index d1fdd1b..a6e3729 100755 --- a/scripts/coverage_report.sh +++ b/scripts/coverage_report.sh @@ -10,6 +10,7 @@ cmake --build --preset coverage "${BUILD_DIR}/unittests" "${BUILD_DIR}/excess_positions_tests" "${BUILD_DIR}/louds_tree_tests" +"${BUILD_DIR}/bp_tree_tests" "${BUILD_DIR}/test_rmm" cd "${BUILD_DIR}" From a975bad58bf01cda7e5f2e44cf7b3f2efa9121e2 Mon Sep 17 00:00:00 2001 From: Sanya239 Date: Sat, 16 May 2026 02:10:13 +0300 Subject: [PATCH 8/8] fix clang format --- include/pixie/bp_tree.h | 7 +++---- include/pixie/rmm_tree.h | 14 ++++++++------ src/tests/bp_tree_tests.cpp | 2 -- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/pixie/bp_tree.h b/include/pixie/bp_tree.h index cb53922..4b67de6 100644 --- a/include/pixie/bp_tree.h +++ b/include/pixie/bp_tree.h @@ -16,10 +16,9 @@ class BpTree { RmMTree rmm; public: - /** - * @brief A node class of BP tree - */ + * @brief A node class of BP tree + */ struct Node { size_t number; size_t pos; @@ -80,7 +79,7 @@ class BpTree { /** * @brief Returns first child of a @p node */ - Node first_child(const Node& node) const{ + Node first_child(const Node& node) const { size_t pos = node.pos + 1; size_t num = node.number + 1; return Node(num, pos); diff --git a/include/pixie/rmm_tree.h b/include/pixie/rmm_tree.h index 6507c00..cdc7ff4 100644 --- a/include/pixie/rmm_tree.h +++ b/include/pixie/rmm_tree.h @@ -967,8 +967,8 @@ class RmMTree { } /** - * @brief Read bit at position @p position (LSB-first across words). - */ + * @brief Read bit at position @p position (LSB-first across words). + */ inline int bit(const size_t& position) const noexcept { return (bits[position >> 6] >> (position & 63)) & 1u; } @@ -2202,10 +2202,11 @@ class RmMTree { } build(leaf_block_bits, max_overhead); } -public: + + public: /** - * @brief Export internal bitvector into a 0/1 string. - */ + * @brief Export internal bitvector into a 0/1 string. + */ std::string to_string() const { std::string result; result.resize(num_bits); @@ -2218,7 +2219,8 @@ class RmMTree { return result; } -private: + + private: /** * @brief Build internal structures from 64-bit words. * @param words Words with LSB-first bits. diff --git a/src/tests/bp_tree_tests.cpp b/src/tests/bp_tree_tests.cpp index dd69baf..2f80342 100644 --- a/src/tests/bp_tree_tests.cpp +++ b/src/tests/bp_tree_tests.cpp @@ -68,7 +68,6 @@ TEST(BpTreeTest, RandomTreeDFS) { } } - TEST(BpTreeTest, RandomTreeBFS) { for (size_t tree_size = 8; tree_size < (1 << 22); tree_size <<= 1) { std::mt19937_64 rng(42); @@ -107,4 +106,3 @@ TEST(BpTreeTest, RandomTreeBFS) { } } } -