Skip to content

Commit

Permalink
GS_DelKeyInMutableSameAsValueInImm pass
Browse files Browse the repository at this point in the history
  • Loading branch information
udi-speedb committed Feb 4, 2024
1 parent 529cbe7 commit 5f60013
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
12 changes: 8 additions & 4 deletions db/db_impl/spdb_db_gs_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,11 @@ bool ProcessCurrValuesIterVsDelList(GlobalContext& gc, LevelContext& lc) {
case RelativePos::OVERLAP:
// The key is covered by the Del-Elem => it is irrelevant (as all of the
// range covered)
lc.values_iter->Seek(lc.del_list_iter->key().user_end_key);
if (lc.del_list_iter->key().IsRange()) {
lc.values_iter->Seek(lc.del_list_iter->key().user_end_key);
} else {
lc.values_iter->Next();
}
break;

default:
Expand Down Expand Up @@ -436,7 +440,7 @@ Status ProcessLogLevel(GlobalContext& gc, LevelContext& lc) {
if (lc.range_del_iter->Valid() == false) {
auto was_new_csk_found = ProcessCurrValuesIterVsDelList(gc, lc);
if (was_new_csk_found) {
printf("Processing Level Ended, new csk was found\n");
// printf("Processing Level Ended, new csk was found\n");
return Status::OK();
} else {
continue;
Expand Down Expand Up @@ -491,8 +495,8 @@ Status ProcessLogLevel(GlobalContext& gc, LevelContext& lc) {
}
}

printf("Processing Level Ended, was new csk was found:%d\n",
lc.new_csk_found_in_level);
// printf("Processing Level Ended, was new csk was found:%d\n",
// lc.new_csk_found_in_level);

return Status::OK();
}
Expand Down
36 changes: 30 additions & 6 deletions db/db_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7624,7 +7624,7 @@ TEST_F(DBTest, StaticPinningLastLevelWithData) {
using DelElem = spdb_gs::DelElement;

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// #if 0
#if 0

// TODO: Write unit-tests for the gs-utils funtions
class GsUtilsTest : public ::testing::Test {};
Expand Down Expand Up @@ -7865,7 +7865,7 @@ TEST_F(DelListTest, Trim) {
}

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// #endif
#endif

// ======================================================================================
// Get-Smallest
Expand Down Expand Up @@ -7912,7 +7912,7 @@ class DBGsTest : public DBTest {
};

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// #if 0
#if 0

TEST_F(DBGsTest, GS_EmptyDB) {
ReopenNewDb();
Expand Down Expand Up @@ -8079,9 +8079,6 @@ TEST_F(DBGsTest, GS_RangeTsInMutableCoveringValueInImm) {
CALL_WRAPPER(GetSmallestAndValidate(""));
}

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// #endif

TEST_F(DBGsTest, GS_RangeTsInImmCoveringValueInMutable) {
ReopenNewDb();
auto dflt_cfh = dbfull()->DefaultColumnFamily();
Expand Down Expand Up @@ -8118,6 +8115,33 @@ TEST_F(DBGsTest, GS_RangeTsInImmNotCoveringValueInMutable) {
CALL_WRAPPER(GetSmallestAndValidate("a"));
}


TEST_F(DBGsTest, GS_DelKeyInImmSameAsValueInMutable) {
ReopenNewDb();
auto dflt_cfh = dbfull()->DefaultColumnFamily();

ASSERT_OK(dbfull()->Delete(WriteOptions(), dflt_cfh, "c"));
ASSERT_OK(dbfull()->TEST_SwitchMemtable());
ASSERT_OK(dbfull()->Put(WriteOptions(), "x", "b1"));
ASSERT_OK(dbfull()->Put(WriteOptions(), "c", "a1"));

CALL_WRAPPER(GetSmallestAndValidate("c"));
}
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#endif

TEST_F(DBGsTest, GS_DelKeyInMutableSameAsValueInImm) {
ReopenNewDb();
auto dflt_cfh = dbfull()->DefaultColumnFamily();

ASSERT_OK(dbfull()->Put(WriteOptions(), "x", "b1"));
ASSERT_OK(dbfull()->Put(WriteOptions(), "c", "a1"));
ASSERT_OK(dbfull()->TEST_SwitchMemtable());
ASSERT_OK(dbfull()->Delete(WriteOptions(), dflt_cfh, "c"));

CALL_WRAPPER(GetSmallestAndValidate("x"));
}

} // namespace ROCKSDB_NAMESPACE

int main(int argc, char** argv) {
Expand Down

0 comments on commit 5f60013

Please sign in to comment.