Skip to content
Merged
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
5 changes: 4 additions & 1 deletion src/dbzero/core/collections/b_index/v_bindex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,9 +860,12 @@ namespace db0
// this is safe as order not violated
m_it_node.modify().m_data.lo_bound = m_data_buf->front();
}

// move on to the next node
++m_it_node;
if (m_it_node != m_ref.m_index.end()) {
m_data_buf = data_vector(m_ref.getMemspace().myPtr(m_it_node->m_data.ptr_b_data), m_ref.m_item_destroy_func);
}
return erase_count;
}

Expand Down
12 changes: 6 additions & 6 deletions src/dbzero/core/collections/vector/v_sorted_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
namespace db0

{
DB0_PACKED_BEGIN

/**
* inverting comparator
*/
*/
template <class T,class comp_t> struct inverted_comp_t
{
comp_t _comp;
Expand All @@ -37,7 +36,7 @@ DB0_PACKED_BEGIN
bool operator()(const T &val0,const T &val1) const {
return _comp(val1,val0);
}
};
};

/**
* Sorted vector state types
Expand All @@ -53,6 +52,7 @@ DB0_PACKED_BEGIN
* data_t - contained element type (comparable)
* comp_t - data comparer
*/
DB0_PACKED_BEGIN
template <class data_t, class comp_t = std::less<data_t> > class DB0_PACKED_ATTR o_sv_container
: public o_base<o_sv_container<data_t,comp_t>, 0, false >
{
Expand Down Expand Up @@ -666,7 +666,8 @@ DB0_PACKED_BEGIN
return reinterpret_cast<const data_t*>(reinterpret_cast<const std::byte*>(this) + sizeof(self));
}
};

DB0_PACKED_END

/**
* NOTICE : destroy does not call any overlaid item destructors
* in order to destroy items, call erase / clear first
Expand Down Expand Up @@ -1070,7 +1071,7 @@ DB0_PACKED_BEGIN
/**
* @return true on object relocated
*/
bool compactShrinking()
bool compactShrinking()
{
if ((*this)->isShrinking()) {
return compact();
Expand Down Expand Up @@ -1155,5 +1156,4 @@ DB0_PACKED_BEGIN
DestroyF m_item_destroy_func;
};

DB0_PACKED_END
}
24 changes: 24 additions & 0 deletions tests/unit_tests/VBIndexTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,29 @@ namespace tests
timer.printLog(std::cout) << std::endl;
}

TEST_F( VBIndexTests , testVBIndexBulkErase )
{
using ItemT = db0::key_value<std::uint32_t, std::uint32_t>;
auto memspace = getMemspace();
std::vector<ItemT> values(1500);
for (std::uint32_t i = 0; i < 1500; ++i) {
values[i] = { i, 0 };
}
db0::v_bindex<ItemT> cut(memspace, memspace.getPageSize());
cut.bulkInsert(values.begin(), values.end());
ASSERT_EQ(cut.size(), 1500u);
std::function<bool(ItemT)> selector = [&](ItemT item) {
return item.key < 1000;
};
cut.bulkErase(selector);
ASSERT_EQ(cut.size(), 500u);
// verify remaining items
auto it = cut.begin(), end = cut.end();
while (it != end) {
ASSERT_EQ((*it).key >= 1000, true);
++it;
}
}

}

Loading