Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/pasta/block_tree/block_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ template <typename input_type, typename size_type> class BlockTree {
off = off % block_size;
blk_pointer = lvl_rs.rank1(blk_pointer) * tau_ + child;
}
return compressed_leaves_[blk_pointer * leaf_size + off];
return decompress_map_[compressed_leaves_[blk_pointer * leaf_size + off]];
};

int64_t select(input_type c, size_type j) {
Expand Down Expand Up @@ -401,12 +401,14 @@ template <typename input_type, typename size_type> class BlockTree {

void compress_leaves() {
compress_map_.resize(256, 0);
decompress_map_.resize(256, 0);
for (size_t i = 0; i < this->leaves_.size(); ++i) {
compress_map_[this->leaves_[i]] = 1;
}
for (size_t i = 0, cur_val = 0; i < this->compress_map_.size(); ++i) {
size_t tmp = compress_map_[i];
compress_map_[i] = cur_val;
decompress_map_[cur_val] = i;
cur_val += tmp;
}

Expand Down
14 changes: 14 additions & 0 deletions tests/block_tree/block_tree_fp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ class BlockTreeFPTest : public ::testing::Test {
protected:

std::vector<uint8_t> text;
std::vector<uint8_t> gappy_alphabet_text;

pasta::BlockTreeFP<uint8_t, int32_t>* bt;
pasta::BlockTreeFP<uint8_t, int32_t>* gappy_alphabet_bt;

void SetUp() override {

Expand All @@ -43,16 +45,22 @@ class BlockTreeFPTest : public ::testing::Test {

size_t const string_length = 100000;
text.resize(string_length);
gappy_alphabet_text.resize(string_length);
for (size_t i = 0; i < text.size(); ++i) {
text[i] = dist(gen);
gappy_alphabet_text[i] = 2*dist(gen);
}

bt = pasta::make_block_tree_fp<uint8_t, int32_t>(text, 2, 1);
bt->add_rank_support();

gappy_alphabet_bt = pasta::make_block_tree_fp<uint8_t, int32_t>(gappy_alphabet_text, 2, 1);
gappy_alphabet_bt->add_rank_support();
}

void TearDown() override {
delete bt;
delete gappy_alphabet_bt;
}

};
Expand All @@ -63,6 +71,12 @@ TEST_F(BlockTreeFPTest, access) {
}
}

TEST_F(BlockTreeFPTest, access_gappy_alphabet) {
for (size_t i = 0; i < text.size(); ++i) {
ASSERT_EQ(gappy_alphabet_bt->access(i), gappy_alphabet_text[i]);
}
}

TEST_F(BlockTreeFPTest, rank) {
std::array<size_t, 256> hist = {0};

Expand Down
13 changes: 13 additions & 0 deletions tests/block_tree/block_tree_lpf_parallel_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ class BlockTreeLPFParallelTest : public ::testing::Test {
protected:

std::vector<uint8_t> text;
std::vector<uint8_t> gappy_alphabet_text;

pasta::BlockTreeLPF<uint8_t, int32_t>* bt;
pasta::BlockTreeLPF<uint8_t, int32_t>* gappy_alphabet_bt;

void SetUp() override {

Expand All @@ -43,16 +45,21 @@ class BlockTreeLPFParallelTest : public ::testing::Test {

size_t const string_length = 100000;
text.resize(string_length);
gappy_alphabet_text.resize(string_length);
for (size_t i = 0; i < text.size(); ++i) {
text[i] = dist(gen);
gappy_alphabet_text[i] = 2*dist(gen);
}

bt = pasta::make_block_tree_lpf_parallel<uint8_t, int32_t>(text, 2, 1, true, 4);
bt->add_rank_support_omp(4);
gappy_alphabet_bt = pasta::make_block_tree_lpf_parallel<uint8_t, int32_t>(gappy_alphabet_text, 2, 1, true, 4);
gappy_alphabet_bt->add_rank_support_omp(4);
}

void TearDown() override {
delete bt;
delete gappy_alphabet_bt;
}

};
Expand All @@ -63,6 +70,12 @@ TEST_F(BlockTreeLPFParallelTest, access) {
}
}

TEST_F(BlockTreeLPFParallelTest, access_gappy_alphabet) {
for (size_t i = 0; i < text.size(); ++i) {
ASSERT_EQ(gappy_alphabet_bt->access(i), gappy_alphabet_text[i]);
}
}

TEST_F(BlockTreeLPFParallelTest, rank) {
std::array<size_t, 256> hist = {0};

Expand Down
13 changes: 13 additions & 0 deletions tests/block_tree/block_tree_lpf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ class BlockTreeLPFTest : public ::testing::Test {
protected:

std::vector<uint8_t> text;
std::vector<uint8_t> gappy_alphabet_text;

pasta::BlockTreeLPF<uint8_t, int32_t>* bt;
pasta::BlockTreeLPF<uint8_t, int32_t>* gappy_alphabet_bt;

void SetUp() override {

Expand All @@ -43,16 +45,21 @@ class BlockTreeLPFTest : public ::testing::Test {

size_t const string_length = 100000;
text.resize(string_length);
gappy_alphabet_text.resize(string_length);
for (size_t i = 0; i < text.size(); ++i) {
text[i] = dist(gen);
gappy_alphabet_text[i] = 2*dist(gen);
}

bt = pasta::make_block_tree_lpf<uint8_t, int32_t>(text, 2, 1, true);
bt->add_rank_support();
gappy_alphabet_bt = pasta::make_block_tree_lpf<uint8_t, int32_t>(gappy_alphabet_text, 2, 1, true);
gappy_alphabet_bt->add_rank_support();
}

void TearDown() override {
delete bt;
delete gappy_alphabet_bt;
}

};
Expand All @@ -63,6 +70,12 @@ TEST_F(BlockTreeLPFTest, access) {
}
}

TEST_F(BlockTreeLPFTest, access_gappy_alphabet) {
for (size_t i = 0; i < text.size(); ++i) {
ASSERT_EQ(gappy_alphabet_bt->access(i), gappy_alphabet_text[i]);
}
}

TEST_F(BlockTreeLPFTest, rank) {
std::array<size_t, 256> hist = {0};

Expand Down