Skip to content

Commit 8a139a0

Browse files
committed
More valgrind issues!
Summary: Fix some more CompactionFilterV2 valgrind issues. Maybe it would make sense for CompactionFilterV2 to delete its prefix_extractor? Test Plan: ran CompactionFilterV2* tests with valgrind. issues before patch -> no issues after Reviewers: haobo, sdong, ljin, dhruba Reviewed By: dhruba CC: leveldb, danguo Differential Revision: https://reviews.facebook.net/D17337
1 parent 550cca7 commit 8a139a0

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

db/db_test.cc

+11-7
Original file line numberDiff line numberDiff line change
@@ -3707,9 +3707,11 @@ TEST(DBTest, CompactionFilterV2) {
37073707
options.num_levels = 3;
37083708
options.max_mem_compaction_level = 0;
37093709
// extract prefix
3710-
auto prefix_extractor = NewFixedPrefixTransform(8);
3710+
std::unique_ptr<const SliceTransform> prefix_extractor;
3711+
prefix_extractor.reset(NewFixedPrefixTransform(8));
3712+
37113713
options.compaction_filter_factory_v2
3712-
= std::make_shared<KeepFilterFactoryV2>(prefix_extractor);
3714+
= std::make_shared<KeepFilterFactoryV2>(prefix_extractor.get());
37133715
// In a testing environment, we can only flush the application
37143716
// compaction filter buffer using universal compaction
37153717
option_config_ = kUniversalCompaction;
@@ -3757,7 +3759,7 @@ TEST(DBTest, CompactionFilterV2) {
37573759
// create a new database with the compaction
37583760
// filter in such a way that it deletes all keys
37593761
options.compaction_filter_factory_v2 =
3760-
std::make_shared<DeleteFilterFactoryV2>(prefix_extractor);
3762+
std::make_shared<DeleteFilterFactoryV2>(prefix_extractor.get());
37613763
options.create_if_missing = true;
37623764
DestroyAndReopen(&options);
37633765

@@ -3792,9 +3794,10 @@ TEST(DBTest, CompactionFilterV2WithValueChange) {
37923794
Options options = CurrentOptions();
37933795
options.num_levels = 3;
37943796
options.max_mem_compaction_level = 0;
3795-
auto prefix_extractor = NewFixedPrefixTransform(8);
3797+
std::unique_ptr<const SliceTransform> prefix_extractor;
3798+
prefix_extractor.reset(NewFixedPrefixTransform(8));
37963799
options.compaction_filter_factory_v2 =
3797-
std::make_shared<ChangeFilterFactoryV2>(prefix_extractor);
3800+
std::make_shared<ChangeFilterFactoryV2>(prefix_extractor.get());
37983801
// In a testing environment, we can only flush the application
37993802
// compaction filter buffer using universal compaction
38003803
option_config_ = kUniversalCompaction;
@@ -3832,9 +3835,10 @@ TEST(DBTest, CompactionFilterV2NULLPrefix) {
38323835
Options options = CurrentOptions();
38333836
options.num_levels = 3;
38343837
options.max_mem_compaction_level = 0;
3835-
auto prefix_extractor = NewFixedPrefixTransform(8);
3838+
std::unique_ptr<const SliceTransform> prefix_extractor;
3839+
prefix_extractor.reset(NewFixedPrefixTransform(8));
38363840
options.compaction_filter_factory_v2 =
3837-
std::make_shared<ChangeFilterFactoryV2>(prefix_extractor);
3841+
std::make_shared<ChangeFilterFactoryV2>(prefix_extractor.get());
38383842
// In a testing environment, we can only flush the application
38393843
// compaction filter buffer using universal compaction
38403844
option_config_ = kUniversalCompaction;

0 commit comments

Comments
 (0)