Commit 8ae99c7c authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Make locality hashes work with DEL

parent b97de1cb
Pipeline #384324 passed with stages
in 46 minutes and 14 seconds
......@@ -1007,6 +1007,19 @@ rocksdb::Status StateMachine::del(StagingArea &stagingArea, const VecIterator &s
remove_all_with_prefix(locator.toSlice(), count, stagingArea);
if(count != keyInfo.getSize()) qdb_throw("mismatch between keyInfo counter and number of elements deleted by remove_all_with_prefix: " << count << " vs " << keyInfo.getSize());
}
else if(keyInfo.getKeyType() == KeyType::kLocalityHash) {
// wipe out fields
LocalityFieldLocator fieldLocator(*it);
int64_t count = 0;
remove_all_with_prefix(fieldLocator.toSlice(), count, stagingArea);
if(count != keyInfo.getSize()) qdb_throw("mismatch between keyInfo counter and number of elements deleted by remove_all_with_prefix: " << count << " vs " << keyInfo.getSize());
// wipe out indexes
LocalityIndexLocator indexLocator(*it);
count = 0;
remove_all_with_prefix(indexLocator.toSlice(), count, stagingArea);
if(count != keyInfo.getSize()) qdb_throw("mismatch between keyInfo counter and number of elements deleted by remove_all_with_prefix: " << count << " vs " << keyInfo.getSize());
}
else {
qdb_throw("should never happen");
}
......
......@@ -1000,4 +1000,10 @@ TEST_F(Raft_e2e, LocalityHash) {
ASSERT_REPLY(tunnel(leaderID)->exec("lhget", "mykey", "f1"), "v2");
ASSERT_REPLY(tunnel(leaderID)->exec("lhget", "mykey", "f1", "hint2"), "v2");
ASSERT_REPLY(tunnel(leaderID)->exec("lhget", "mykey", "f1", "hint1"), "v2");
// Delete key.
ASSERT_REPLY(tunnel(leaderID)->exec("del", "mykey"), 1);
ASSERT_REPLY(tunnel(leaderID)->exec("lhlen", "mykey"), 0);
ASSERT_REPLY(tunnel(leaderID)->exec("del", "mykey"), 0);
ASSERT_REPLY(tunnel(leaderID)->exec("lhget", "mykey", "f3", "aaaaa"), "");
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment