@ -134,7 +134,6 @@ class PlainTableDBTest : public testing::Test,
plain_table_options . huge_page_tlb_size = 0 ;
plain_table_options . huge_page_tlb_size = 0 ;
plain_table_options . encoding_type = kPrefix ;
plain_table_options . encoding_type = kPrefix ;
plain_table_options . full_scan_mode = false ;
plain_table_options . full_scan_mode = false ;
plain_table_options . store_index_in_file = false ;
options . table_factory . reset ( NewPlainTableFactory ( plain_table_options ) ) ;
options . table_factory . reset ( NewPlainTableFactory ( plain_table_options ) ) ;
options . memtable_factory . reset ( NewHashLinkListRepFactory ( 4 , 0 , 3 , true ) ) ;
options . memtable_factory . reset ( NewHashLinkListRepFactory ( 4 , 0 , 3 , true ) ) ;
@ -272,8 +271,7 @@ class TestPlainTableReader : public PlainTableReader {
std : : unique_ptr < RandomAccessFileReader > & & file ,
std : : unique_ptr < RandomAccessFileReader > & & file ,
const ImmutableCFOptions & ioptions ,
const ImmutableCFOptions & ioptions ,
const SliceTransform * prefix_extractor ,
const SliceTransform * prefix_extractor ,
bool * expect_bloom_not_match , bool store_index_in_file ,
bool * expect_bloom_not_match , uint32_t column_family_id ,
uint32_t column_family_id ,
const std : : string & column_family_name )
const std : : string & column_family_name )
: PlainTableReader ( ioptions , std : : move ( file ) , env_options , icomparator ,
: PlainTableReader ( ioptions , std : : move ( file ) , env_options , icomparator ,
encoding_type , file_size , table_properties ,
encoding_type , file_size , table_properties ,
@ -290,17 +288,6 @@ class TestPlainTableReader : public PlainTableReader {
TableProperties * props = const_cast < TableProperties * > ( table_properties ) ;
TableProperties * props = const_cast < TableProperties * > ( table_properties ) ;
EXPECT_EQ ( column_family_id , static_cast < uint32_t > ( props - > column_family_id ) ) ;
EXPECT_EQ ( column_family_id , static_cast < uint32_t > ( props - > column_family_id ) ) ;
EXPECT_EQ ( column_family_name , props - > column_family_name ) ;
EXPECT_EQ ( column_family_name , props - > column_family_name ) ;
if ( store_index_in_file ) {
auto bloom_version_ptr = props - > user_collected_properties . find (
PlainTablePropertyNames : : kBloomVersion ) ;
EXPECT_TRUE ( bloom_version_ptr ! = props - > user_collected_properties . end ( ) ) ;
EXPECT_EQ ( bloom_version_ptr - > second , std : : string ( " 1 " ) ) ;
if ( ioptions . bloom_locality > 0 ) {
auto num_blocks_ptr = props - > user_collected_properties . find (
PlainTablePropertyNames : : kNumBloomBlocks ) ;
EXPECT_TRUE ( num_blocks_ptr ! = props - > user_collected_properties . end ( ) ) ;
}
}
}
}
virtual ~ TestPlainTableReader ( ) { }
virtual ~ TestPlainTableReader ( ) { }
@ -329,7 +316,6 @@ class TestPlainTableFactory : public PlainTableFactory {
bloom_bits_per_key_ ( options . bloom_bits_per_key ) ,
bloom_bits_per_key_ ( options . bloom_bits_per_key ) ,
hash_table_ratio_ ( options . hash_table_ratio ) ,
hash_table_ratio_ ( options . hash_table_ratio ) ,
index_sparseness_ ( options . index_sparseness ) ,
index_sparseness_ ( options . index_sparseness ) ,
store_index_in_file_ ( options . store_index_in_file ) ,
expect_bloom_not_match_ ( expect_bloom_not_match ) ,
expect_bloom_not_match_ ( expect_bloom_not_match ) ,
column_family_id_ ( column_family_id ) ,
column_family_id_ ( column_family_id ) ,
column_family_name_ ( std : : move ( column_family_name ) ) { }
column_family_name_ ( std : : move ( column_family_name ) ) { }
@ -346,22 +332,6 @@ class TestPlainTableFactory : public PlainTableFactory {
true /* compression_type_missing */ ) ;
true /* compression_type_missing */ ) ;
EXPECT_TRUE ( s . ok ( ) ) ;
EXPECT_TRUE ( s . ok ( ) ) ;
if ( store_index_in_file_ ) {
BlockHandle bloom_block_handle ;
s = FindMetaBlock ( file . get ( ) , file_size , kPlainTableMagicNumber ,
table_reader_options . ioptions ,
BloomBlockBuilder : : kBloomBlock , & bloom_block_handle ,
/* compression_type_missing */ true ) ;
EXPECT_TRUE ( s . ok ( ) ) ;
BlockHandle index_block_handle ;
s = FindMetaBlock ( file . get ( ) , file_size , kPlainTableMagicNumber ,
table_reader_options . ioptions ,
PlainTableIndexBuilder : : kPlainTableIndexBlock ,
& index_block_handle , /* compression_type_missing */ true ) ;
EXPECT_TRUE ( s . ok ( ) ) ;
}
auto & user_props = props - > user_collected_properties ;
auto & user_props = props - > user_collected_properties ;
auto encoding_type_prop =
auto encoding_type_prop =
user_props . find ( PlainTablePropertyNames : : kEncodingType ) ;
user_props . find ( PlainTablePropertyNames : : kEncodingType ) ;
@ -375,7 +345,7 @@ class TestPlainTableFactory : public PlainTableFactory {
bloom_bits_per_key_ , hash_table_ratio_ , index_sparseness_ , props ,
bloom_bits_per_key_ , hash_table_ratio_ , index_sparseness_ , props ,
std : : move ( file ) , table_reader_options . ioptions ,
std : : move ( file ) , table_reader_options . ioptions ,
table_reader_options . prefix_extractor , expect_bloom_not_match_ ,
table_reader_options . prefix_extractor , expect_bloom_not_match_ ,
store_index_in_file_ , column_family_id_ , column_family_name_ ) ) ;
column_family_id_ , column_family_name_ ) ) ;
* table = std : : move ( new_reader ) ;
* table = std : : move ( new_reader ) ;
return s ;
return s ;
@ -385,7 +355,6 @@ class TestPlainTableFactory : public PlainTableFactory {
int bloom_bits_per_key_ ;
int bloom_bits_per_key_ ;
double hash_table_ratio_ ;
double hash_table_ratio_ ;
size_t index_sparseness_ ;
size_t index_sparseness_ ;
bool store_index_in_file_ ;
bool * expect_bloom_not_match_ ;
bool * expect_bloom_not_match_ ;
const uint32_t column_family_id_ ;
const uint32_t column_family_id_ ;
const std : : string column_family_name_ ;
const std : : string column_family_name_ ;
@ -397,8 +366,6 @@ TEST_P(PlainTableDBTest, Flush) {
for ( EncodingType encoding_type : { kPlain , kPrefix } ) {
for ( EncodingType encoding_type : { kPlain , kPrefix } ) {
for ( int bloom_bits = 0 ; bloom_bits < = 117 ; bloom_bits + = 117 ) {
for ( int bloom_bits = 0 ; bloom_bits < = 117 ; bloom_bits + = 117 ) {
for ( int total_order = 0 ; total_order < = 1 ; total_order + + ) {
for ( int total_order = 0 ; total_order < = 1 ; total_order + + ) {
for ( int store_index_in_file = 0 ; store_index_in_file < = 1 ;
+ + store_index_in_file ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
options . create_if_missing = true ;
options . create_if_missing = true ;
// Set only one bucket to force bucket conflict.
// Set only one bucket to force bucket conflict.
@ -414,7 +381,6 @@ TEST_P(PlainTableDBTest, Flush) {
plain_table_options . huge_page_tlb_size = huge_page_tlb_size ;
plain_table_options . huge_page_tlb_size = huge_page_tlb_size ;
plain_table_options . encoding_type = encoding_type ;
plain_table_options . encoding_type = encoding_type ;
plain_table_options . full_scan_mode = false ;
plain_table_options . full_scan_mode = false ;
plain_table_options . store_index_in_file = store_index_in_file ;
options . table_factory . reset (
options . table_factory . reset (
NewPlainTableFactory ( plain_table_options ) ) ;
NewPlainTableFactory ( plain_table_options ) ) ;
@ -427,7 +393,6 @@ TEST_P(PlainTableDBTest, Flush) {
plain_table_options . huge_page_tlb_size = huge_page_tlb_size ;
plain_table_options . huge_page_tlb_size = huge_page_tlb_size ;
plain_table_options . encoding_type = encoding_type ;
plain_table_options . encoding_type = encoding_type ;
plain_table_options . full_scan_mode = false ;
plain_table_options . full_scan_mode = false ;
plain_table_options . store_index_in_file = store_index_in_file ;
options . table_factory . reset (
options . table_factory . reset (
NewPlainTableFactory ( plain_table_options ) ) ;
NewPlainTableFactory ( plain_table_options ) ) ;
@ -453,25 +418,18 @@ TEST_P(PlainTableDBTest, Flush) {
auto row = ptc . begin ( ) ;
auto row = ptc . begin ( ) ;
auto tp = row - > second ;
auto tp = row - > second ;
if ( ! store_index_in_file ) {
ASSERT_EQ ( total_order ? " 4 " : " 12 " ,
ASSERT_EQ ( total_order ? " 4 " : " 12 " ,
( tp - > user_collected_properties )
( tp - > user_collected_properties )
. at ( " plain_table_hash_table_size " ) ) ;
. at ( " plain_table_hash_table_size " ) ) ;
ASSERT_EQ ( " 0 " , ( tp - > user_collected_properties )
ASSERT_EQ (
. at ( " plain_table_sub_index_size " ) ) ;
" 0 " ,
} else {
( tp - > user_collected_properties ) . at ( " plain_table_sub_index_size " ) ) ;
ASSERT_EQ ( " 0 " , ( tp - > user_collected_properties )
. at ( " plain_table_hash_table_size " ) ) ;
ASSERT_EQ ( " 0 " , ( tp - > user_collected_properties )
. at ( " plain_table_sub_index_size " ) ) ;
}
ASSERT_EQ ( " v3 " , Get ( " 1000000000000foo " ) ) ;
ASSERT_EQ ( " v3 " , Get ( " 1000000000000foo " ) ) ;
ASSERT_EQ ( " v2 " , Get ( " 0000000000000bar " ) ) ;
ASSERT_EQ ( " v2 " , Get ( " 0000000000000bar " ) ) ;
}
}
}
}
}
}
}
}
}
}
}
TEST_P ( PlainTableDBTest , Flush2 ) {
TEST_P ( PlainTableDBTest , Flush2 ) {
@ -480,17 +438,9 @@ TEST_P(PlainTableDBTest, Flush2) {
for ( EncodingType encoding_type : { kPlain , kPrefix } ) {
for ( EncodingType encoding_type : { kPlain , kPrefix } ) {
for ( int bloom_bits = 0 ; bloom_bits < = 117 ; bloom_bits + = 117 ) {
for ( int bloom_bits = 0 ; bloom_bits < = 117 ; bloom_bits + = 117 ) {
for ( int total_order = 0 ; total_order < = 1 ; total_order + + ) {
for ( int total_order = 0 ; total_order < = 1 ; total_order + + ) {
for ( int store_index_in_file = 0 ; store_index_in_file < = 1 ;
+ + store_index_in_file ) {
if ( encoding_type = = kPrefix & & total_order ) {
if ( encoding_type = = kPrefix & & total_order ) {
continue ;
continue ;
}
}
if ( ! bloom_bits & & store_index_in_file ) {
continue ;
}
if ( total_order & & store_index_in_file ) {
continue ;
}
bool expect_bloom_not_match = false ;
bool expect_bloom_not_match = false ;
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
options . create_if_missing = true ;
options . create_if_missing = true ;
@ -509,7 +459,6 @@ TEST_P(PlainTableDBTest, Flush2) {
plain_table_options . bloom_bits_per_key = bloom_bits ;
plain_table_options . bloom_bits_per_key = bloom_bits ;
plain_table_options . huge_page_tlb_size = huge_page_tlb_size ;
plain_table_options . huge_page_tlb_size = huge_page_tlb_size ;
plain_table_options . encoding_type = encoding_type ;
plain_table_options . encoding_type = encoding_type ;
plain_table_options . store_index_in_file = store_index_in_file ;
options . table_factory . reset ( new TestPlainTableFactory (
options . table_factory . reset ( new TestPlainTableFactory (
& expect_bloom_not_match , plain_table_options ,
& expect_bloom_not_match , plain_table_options ,
0 /* column_family_id */ , kDefaultColumnFamilyName ) ) ;
0 /* column_family_id */ , kDefaultColumnFamilyName ) ) ;
@ -552,7 +501,6 @@ TEST_P(PlainTableDBTest, Flush2) {
}
}
}
}
}
}
}
}
}
TEST_P ( PlainTableDBTest , Immortal ) {
TEST_P ( PlainTableDBTest , Immortal ) {