@ -24,6 +24,36 @@ class DBTestCompactionFilter : public DBTestBase {
DBTestCompactionFilter ( ) : DBTestBase ( " /db_compaction_filter_test " ) { }
DBTestCompactionFilter ( ) : DBTestBase ( " /db_compaction_filter_test " ) { }
} ;
} ;
// Param variant of DBTestBase::ChangeCompactOptions
class DBTestCompactionFilterWithCompactParam
: public DBTestCompactionFilter ,
public : : testing : : WithParamInterface < DBTestBase : : OptionConfig > {
public :
DBTestCompactionFilterWithCompactParam ( ) : DBTestCompactionFilter ( ) {
option_config_ = GetParam ( ) ;
Destroy ( last_options_ ) ;
auto options = CurrentOptions ( ) ;
if ( option_config_ = = kDefault | | option_config_ = = kUniversalCompaction | |
option_config_ = = kUniversalCompactionMultiLevel ) {
options . create_if_missing = true ;
}
if ( option_config_ = = kLevelSubcompactions | |
option_config_ = = kUniversalSubcompactions ) {
assert ( options . max_subcompactions > 1 ) ;
}
TryReopen ( options ) ;
}
} ;
INSTANTIATE_TEST_CASE_P (
DBTestCompactionFilterWithCompactOption ,
DBTestCompactionFilterWithCompactParam ,
: : testing : : Values ( DBTestBase : : OptionConfig : : kDefault ,
DBTestBase : : OptionConfig : : kUniversalCompaction ,
DBTestBase : : OptionConfig : : kUniversalCompactionMultiLevel ,
DBTestBase : : OptionConfig : : kLevelSubcompactions ,
DBTestBase : : OptionConfig : : kUniversalSubcompactions ) ) ;
class KeepFilter : public CompactionFilter {
class KeepFilter : public CompactionFilter {
public :
public :
virtual bool Filter ( int level , const Slice & key , const Slice & value ,
virtual bool Filter ( int level , const Slice & key , const Slice & value ,
@ -439,12 +469,11 @@ TEST_F(DBTestCompactionFilter, CompactionFilterDeletesAll) {
}
}
# endif // ROCKSDB_LITE
# endif // ROCKSDB_LITE
TEST_F ( DBTestCompactionFilter , CompactionFilterWithValueChange ) {
TEST_P ( DBTestCompactionFilterWithCompactParam ,
do {
CompactionFilterWithValueChange ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
options . num_levels = 3 ;
options . num_levels = 3 ;
options . compaction_filter_factory =
options . compaction_filter_factory = std : : make_shared < ChangeFilterFactory > ( ) ;
std : : make_shared < ChangeFilterFactory > ( ) ;
CreateAndReopenWithCF ( { " pikachu " } , options ) ;
CreateAndReopenWithCF ( { " pikachu " } , options ) ;
// Write 100K+1 keys, these are written to a few files
// Write 100K+1 keys, these are written to a few files
@ -497,7 +526,6 @@ TEST_F(DBTestCompactionFilter, CompactionFilterWithValueChange) {
std : : string newvalue = Get ( 1 , key ) ;
std : : string newvalue = Get ( 1 , key ) ;
ASSERT_EQ ( newvalue . compare ( NEW_VALUE ) , 0 ) ;
ASSERT_EQ ( newvalue . compare ( NEW_VALUE ) , 0 ) ;
}
}
} while ( ChangeCompactOptions ( ) ) ;
}
}
TEST_F ( DBTestCompactionFilter , CompactionFilterWithMergeOperator ) {
TEST_F ( DBTestCompactionFilter , CompactionFilterWithMergeOperator ) {