@@ -3969,6 +3969,56 @@ TEST(DBTest, CompactionFilterV2WithValueChange) {
3969
3969
}
3970
3970
}
3971
3971
3972
+ TEST (DBTest, CompactionFilterV2NULLPrefix) {
3973
+ Options options = CurrentOptions ();
3974
+ options.num_levels = 3 ;
3975
+ options.max_mem_compaction_level = 0 ;
3976
+ auto prefix_extractor = NewFixedPrefixTransform (8 );
3977
+ options.compaction_filter_factory_v2 =
3978
+ std::make_shared<ChangeFilterFactoryV2>(prefix_extractor);
3979
+ // In a testing environment, we can only flush the application
3980
+ // compaction filter buffer using universal compaction
3981
+ option_config_ = kUniversalCompaction ;
3982
+ options.compaction_style = (rocksdb::CompactionStyle)1 ;
3983
+ Reopen (&options);
3984
+
3985
+ // Write 100K+1 keys, these are written to a few files
3986
+ // in L0. We do this so that the current snapshot points
3987
+ // to the 100001 key.The compaction filter is not invoked
3988
+ // on keys that are visible via a snapshot because we
3989
+ // anyways cannot delete it.
3990
+ const std::string value (10 , ' x' );
3991
+ char first_key[100 ];
3992
+ snprintf (first_key, sizeof (first_key), " %s0000%010d" , " NULL" , 1 );
3993
+ Put (first_key, value);
3994
+ for (int i = 1 ; i < 100000 ; i++) {
3995
+ char key[100 ];
3996
+ snprintf (key, sizeof (key), " %08d%010d" , i, i);
3997
+ Put (key, value);
3998
+ }
3999
+
4000
+ char last_key[100 ];
4001
+ snprintf (last_key, sizeof (last_key), " %s0000%010d" , " NULL" , 2 );
4002
+ Put (last_key, value);
4003
+
4004
+ // push all files to lower levels
4005
+ dbfull ()->TEST_FlushMemTable ();
4006
+ dbfull ()->TEST_CompactRange (0 , nullptr , nullptr );
4007
+
4008
+ // verify that all keys now have the new value that
4009
+ // was set by the compaction process.
4010
+ std::string newvalue = Get (first_key);
4011
+ ASSERT_EQ (newvalue.compare (NEW_VALUE), 0 );
4012
+ newvalue = Get (last_key);
4013
+ ASSERT_EQ (newvalue.compare (NEW_VALUE), 0 );
4014
+ for (int i = 1 ; i < 100000 ; i++) {
4015
+ char key[100 ];
4016
+ snprintf (key, sizeof (key), " %08d%010d" , i, i);
4017
+ std::string newvalue = Get (key);
4018
+ ASSERT_EQ (newvalue.compare (NEW_VALUE), 0 );
4019
+ }
4020
+ }
4021
+
3972
4022
TEST (DBTest, SparseMerge) {
3973
4023
do {
3974
4024
Options options = CurrentOptions ();
0 commit comments