|
|
@ -38,7 +38,7 @@ class NoMergingMergeOp : public MergeOperator { |
|
|
|
|
|
|
|
|
|
|
|
// Compaction filter that gets stuck when it sees a particular key,
|
|
|
|
// Compaction filter that gets stuck when it sees a particular key,
|
|
|
|
// then gets unstuck when told to.
|
|
|
|
// then gets unstuck when told to.
|
|
|
|
// Always returns Decition::kRemove.
|
|
|
|
// Always returns Decision::kRemove.
|
|
|
|
class StallingFilter : public CompactionFilter { |
|
|
|
class StallingFilter : public CompactionFilter { |
|
|
|
public: |
|
|
|
public: |
|
|
|
Decision FilterV2(int /*level*/, const Slice& key, ValueType /*type*/, |
|
|
|
Decision FilterV2(int /*level*/, const Slice& key, ValueType /*type*/, |
|
|
@ -189,7 +189,7 @@ class FakeCompaction : public CompactionIterator::CompactionProxy { |
|
|
|
bool is_allow_ingest_behind = false; |
|
|
|
bool is_allow_ingest_behind = false; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// A simplifed snapshot checker which assumes each snapshot has a global
|
|
|
|
// A simplified snapshot checker which assumes each snapshot has a global
|
|
|
|
// last visible sequence.
|
|
|
|
// last visible sequence.
|
|
|
|
class TestSnapshotChecker : public SnapshotChecker { |
|
|
|
class TestSnapshotChecker : public SnapshotChecker { |
|
|
|
public: |
|
|
|
public: |
|
|
@ -711,7 +711,7 @@ TEST_P(CompactionIteratorTest, ZeroOutSequenceAtBottomLevel) { |
|
|
|
RunTest({test::KeyStr("a", 1, kTypeValue), test::KeyStr("b", 2, kTypeValue)}, |
|
|
|
RunTest({test::KeyStr("a", 1, kTypeValue), test::KeyStr("b", 2, kTypeValue)}, |
|
|
|
{"v1", "v2"}, |
|
|
|
{"v1", "v2"}, |
|
|
|
{test::KeyStr("a", 0, kTypeValue), test::KeyStr("b", 2, kTypeValue)}, |
|
|
|
{test::KeyStr("a", 0, kTypeValue), test::KeyStr("b", 2, kTypeValue)}, |
|
|
|
{"v1", "v2"}, kMaxSequenceNumber /*last_commited_seq*/, |
|
|
|
{"v1", "v2"}, kMaxSequenceNumber /*last_committed_seq*/, |
|
|
|
nullptr /*merge_operator*/, nullptr /*compaction_filter*/, |
|
|
|
nullptr /*merge_operator*/, nullptr /*compaction_filter*/, |
|
|
|
true /*bottommost_level*/); |
|
|
|
true /*bottommost_level*/); |
|
|
|
} |
|
|
|
} |
|
|
@ -720,15 +720,14 @@ TEST_P(CompactionIteratorTest, ZeroOutSequenceAtBottomLevel) { |
|
|
|
// permanently.
|
|
|
|
// permanently.
|
|
|
|
TEST_P(CompactionIteratorTest, RemoveDeletionAtBottomLevel) { |
|
|
|
TEST_P(CompactionIteratorTest, RemoveDeletionAtBottomLevel) { |
|
|
|
AddSnapshot(1); |
|
|
|
AddSnapshot(1); |
|
|
|
RunTest({test::KeyStr("a", 1, kTypeDeletion), |
|
|
|
RunTest( |
|
|
|
test::KeyStr("b", 3, kTypeDeletion), |
|
|
|
{test::KeyStr("a", 1, kTypeDeletion), test::KeyStr("b", 3, kTypeDeletion), |
|
|
|
test::KeyStr("b", 1, kTypeValue)}, |
|
|
|
test::KeyStr("b", 1, kTypeValue)}, |
|
|
|
{"", "", ""}, |
|
|
|
{"", "", ""}, |
|
|
|
{test::KeyStr("b", 3, kTypeDeletion), |
|
|
|
{test::KeyStr("b", 3, kTypeDeletion), test::KeyStr("b", 0, kTypeValue)}, |
|
|
|
test::KeyStr("b", 0, kTypeValue)}, |
|
|
|
{"", ""}, kMaxSequenceNumber /*last_committed_seq*/, |
|
|
|
{"", ""}, |
|
|
|
nullptr /*merge_operator*/, nullptr /*compaction_filter*/, |
|
|
|
kMaxSequenceNumber /*last_commited_seq*/, nullptr /*merge_operator*/, |
|
|
|
true /*bottommost_level*/); |
|
|
|
nullptr /*compaction_filter*/, true /*bottommost_level*/); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// In bottommost level, single deletions earlier than earliest snapshot can be
|
|
|
|
// In bottommost level, single deletions earlier than earliest snapshot can be
|
|
|
@ -738,7 +737,7 @@ TEST_P(CompactionIteratorTest, RemoveSingleDeletionAtBottomLevel) { |
|
|
|
RunTest({test::KeyStr("a", 1, kTypeSingleDeletion), |
|
|
|
RunTest({test::KeyStr("a", 1, kTypeSingleDeletion), |
|
|
|
test::KeyStr("b", 2, kTypeSingleDeletion)}, |
|
|
|
test::KeyStr("b", 2, kTypeSingleDeletion)}, |
|
|
|
{"", ""}, {test::KeyStr("b", 2, kTypeSingleDeletion)}, {""}, |
|
|
|
{"", ""}, {test::KeyStr("b", 2, kTypeSingleDeletion)}, {""}, |
|
|
|
kMaxSequenceNumber /*last_commited_seq*/, nullptr /*merge_operator*/, |
|
|
|
kMaxSequenceNumber /*last_committed_seq*/, nullptr /*merge_operator*/, |
|
|
|
nullptr /*compaction_filter*/, true /*bottommost_level*/); |
|
|
|
nullptr /*compaction_filter*/, true /*bottommost_level*/); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -895,7 +894,7 @@ TEST_F(CompactionIteratorWithSnapshotCheckerTest, |
|
|
|
{"v1", "v2", "v3"}, |
|
|
|
{"v1", "v2", "v3"}, |
|
|
|
{test::KeyStr("a", 0, kTypeValue), test::KeyStr("b", 2, kTypeValue), |
|
|
|
{test::KeyStr("a", 0, kTypeValue), test::KeyStr("b", 2, kTypeValue), |
|
|
|
test::KeyStr("c", 3, kTypeValue)}, |
|
|
|
test::KeyStr("c", 3, kTypeValue)}, |
|
|
|
{"v1", "v2", "v3"}, kMaxSequenceNumber /*last_commited_seq*/, |
|
|
|
{"v1", "v2", "v3"}, kMaxSequenceNumber /*last_committed_seq*/, |
|
|
|
nullptr /*merge_operator*/, nullptr /*compaction_filter*/, |
|
|
|
nullptr /*merge_operator*/, nullptr /*compaction_filter*/, |
|
|
|
true /*bottommost_level*/); |
|
|
|
true /*bottommost_level*/); |
|
|
|
} |
|
|
|
} |
|
|
@ -906,9 +905,7 @@ TEST_F(CompactionIteratorWithSnapshotCheckerTest, |
|
|
|
RunTest( |
|
|
|
RunTest( |
|
|
|
{test::KeyStr("a", 1, kTypeDeletion), test::KeyStr("b", 2, kTypeDeletion), |
|
|
|
{test::KeyStr("a", 1, kTypeDeletion), test::KeyStr("b", 2, kTypeDeletion), |
|
|
|
test::KeyStr("c", 3, kTypeDeletion)}, |
|
|
|
test::KeyStr("c", 3, kTypeDeletion)}, |
|
|
|
{"", "", ""}, |
|
|
|
{"", "", ""}, {}, {"", ""}, kMaxSequenceNumber /*last_committed_seq*/, |
|
|
|
{}, |
|
|
|
|
|
|
|
{"", ""}, kMaxSequenceNumber /*last_commited_seq*/, |
|
|
|
|
|
|
|
nullptr /*merge_operator*/, nullptr /*compaction_filter*/, |
|
|
|
nullptr /*merge_operator*/, nullptr /*compaction_filter*/, |
|
|
|
true /*bottommost_level*/); |
|
|
|
true /*bottommost_level*/); |
|
|
|
} |
|
|
|
} |
|
|
@ -916,15 +913,14 @@ TEST_F(CompactionIteratorWithSnapshotCheckerTest, |
|
|
|
TEST_F(CompactionIteratorWithSnapshotCheckerTest, |
|
|
|
TEST_F(CompactionIteratorWithSnapshotCheckerTest, |
|
|
|
NotRemoveDeletionIfValuePresentToEarlierSnapshot) { |
|
|
|
NotRemoveDeletionIfValuePresentToEarlierSnapshot) { |
|
|
|
AddSnapshot(2,1); |
|
|
|
AddSnapshot(2,1); |
|
|
|
RunTest( |
|
|
|
RunTest({test::KeyStr("a", 4, kTypeDeletion), |
|
|
|
{test::KeyStr("a", 4, kTypeDeletion), test::KeyStr("a", 1, kTypeValue), |
|
|
|
test::KeyStr("a", 1, kTypeValue), test::KeyStr("b", 3, kTypeValue)}, |
|
|
|
test::KeyStr("b", 3, kTypeValue)}, |
|
|
|
{"", "", ""}, |
|
|
|
{"", "", ""}, |
|
|
|
{test::KeyStr("a", 4, kTypeDeletion), |
|
|
|
{test::KeyStr("a", 4, kTypeDeletion), test::KeyStr("a", 0, kTypeValue), |
|
|
|
test::KeyStr("a", 0, kTypeValue), test::KeyStr("b", 3, kTypeValue)}, |
|
|
|
test::KeyStr("b", 3, kTypeValue)}, |
|
|
|
{"", "", ""}, kMaxSequenceNumber /*last_committed_seq*/, |
|
|
|
{"", "", ""}, kMaxSequenceNumber /*last_commited_seq*/, |
|
|
|
nullptr /*merge_operator*/, nullptr /*compaction_filter*/, |
|
|
|
nullptr /*merge_operator*/, nullptr /*compaction_filter*/, |
|
|
|
true /*bottommost_level*/); |
|
|
|
true /*bottommost_level*/); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST_F(CompactionIteratorWithSnapshotCheckerTest, |
|
|
|
TEST_F(CompactionIteratorWithSnapshotCheckerTest, |
|
|
@ -936,7 +932,7 @@ TEST_F(CompactionIteratorWithSnapshotCheckerTest, |
|
|
|
{"", "", ""}, |
|
|
|
{"", "", ""}, |
|
|
|
{test::KeyStr("b", 2, kTypeSingleDeletion), |
|
|
|
{test::KeyStr("b", 2, kTypeSingleDeletion), |
|
|
|
test::KeyStr("c", 3, kTypeSingleDeletion)}, |
|
|
|
test::KeyStr("c", 3, kTypeSingleDeletion)}, |
|
|
|
{"", ""}, kMaxSequenceNumber /*last_commited_seq*/, |
|
|
|
{"", ""}, kMaxSequenceNumber /*last_committed_seq*/, |
|
|
|
nullptr /*merge_operator*/, nullptr /*compaction_filter*/, |
|
|
|
nullptr /*merge_operator*/, nullptr /*compaction_filter*/, |
|
|
|
true /*bottommost_level*/); |
|
|
|
true /*bottommost_level*/); |
|
|
|
} |
|
|
|
} |
|
|
@ -986,8 +982,8 @@ TEST_F(CompactionIteratorWithSnapshotCheckerTest, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Compaction filter should keep uncommitted key as-is, and
|
|
|
|
// Compaction filter should keep uncommitted key as-is, and
|
|
|
|
// * Convert the latest velue to deletion, and/or
|
|
|
|
// * Convert the latest value to deletion, and/or
|
|
|
|
// * if latest value is a merge, apply filter to all suequent merges.
|
|
|
|
// * if latest value is a merge, apply filter to all subsequent merges.
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(CompactionIteratorWithSnapshotCheckerTest, CompactionFilter_Value) { |
|
|
|
TEST_F(CompactionIteratorWithSnapshotCheckerTest, CompactionFilter_Value) { |
|
|
|
std::unique_ptr<CompactionFilter> compaction_filter( |
|
|
|
std::unique_ptr<CompactionFilter> compaction_filter( |
|
|
|