@ -158,6 +158,8 @@ class PlainTableDBTest : public testing::Test,
db_ = nullptr ;
}
bool mmap_mode ( ) const { return mmap_mode_ ; }
void DestroyAndReopen ( Options * options = nullptr ) {
//Destroy using last options
Destroy ( & last_options_ ) ;
@ -174,6 +176,12 @@ class PlainTableDBTest : public testing::Test,
return DB : : Open ( * options , dbname_ , db ) ;
}
Status ReopenForReadOnly ( Options * options ) {
delete db_ ;
db_ = nullptr ;
return DB : : OpenForReadOnly ( * options , dbname_ , & db_ ) ;
}
Status TryReopen ( Options * options = nullptr ) {
delete db_ ;
db_ = nullptr ;
@ -547,6 +555,50 @@ TEST_P(PlainTableDBTest, Flush2) {
}
}
TEST_P ( PlainTableDBTest , Immortable ) {
for ( EncodingType encoding_type : { kPlain , kPrefix } ) {
Options options = CurrentOptions ( ) ;
options . create_if_missing = true ;
options . max_open_files = - 1 ;
// Set only one bucket to force bucket conflict.
// Test index interval for the same prefix to be 1, 2 and 4
PlainTableOptions plain_table_options ;
plain_table_options . hash_table_ratio = 0.75 ;
plain_table_options . index_sparseness = 16 ;
plain_table_options . user_key_len = kPlainTableVariableLength ;
plain_table_options . bloom_bits_per_key = 10 ;
plain_table_options . encoding_type = encoding_type ;
options . table_factory . reset ( NewPlainTableFactory ( plain_table_options ) ) ;
DestroyAndReopen ( & options ) ;
ASSERT_OK ( Put ( " 0000000000000bar " , " b " ) ) ;
ASSERT_OK ( Put ( " 1000000000000foo " , " v1 " ) ) ;
dbfull ( ) - > TEST_FlushMemTable ( ) ;
int copied = 0 ;
rocksdb : : SyncPoint : : GetInstance ( ) - > SetCallBack (
" GetContext::SaveValue::PinSelf " , [ & ] ( void * /*arg*/ ) { copied + + ; } ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > EnableProcessing ( ) ;
ASSERT_EQ ( " b " , Get ( " 0000000000000bar " ) ) ;
ASSERT_EQ ( " v1 " , Get ( " 1000000000000foo " ) ) ;
ASSERT_EQ ( 2 , copied ) ;
copied = 0 ;
Close ( ) ;
ASSERT_OK ( ReopenForReadOnly ( & options ) ) ;
ASSERT_EQ ( " b " , Get ( " 0000000000000bar " ) ) ;
ASSERT_EQ ( " v1 " , Get ( " 1000000000000foo " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( " 1000000000000bar " ) ) ;
if ( mmap_mode ( ) ) {
ASSERT_EQ ( 0 , copied ) ;
} else {
ASSERT_EQ ( 2 , copied ) ;
}
rocksdb : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
}
}
TEST_P ( PlainTableDBTest , Iterator ) {
for ( size_t huge_page_tlb_size = 0 ; huge_page_tlb_size < = 2 * 1024 * 1024 ;
huge_page_tlb_size + = 2 * 1024 * 1024 ) {