@ -232,7 +232,9 @@ DEFINE_bool(iterator, false, "For test iterator");
DEFINE_bool ( through_db , false , " If enable, a DB instance will be created and "
DEFINE_bool ( through_db , false , " If enable, a DB instance will be created and "
" the query will be against DB. Otherwise, will be directly against "
" the query will be against DB. Otherwise, will be directly against "
" a table reader. " ) ;
" a table reader. " ) ;
DEFINE_bool ( plain_table , false , " Use PlainTable " ) ;
DEFINE_string ( table_factory , " block_based " ,
" Table factory to use: `block_based` (default), `plain_table` or "
" `cuckoo_hash`. " ) ;
DEFINE_string ( time_unit , " microsecond " ,
DEFINE_string ( time_unit , " microsecond " ,
" The time unit used for measuring performance. User can specify "
" The time unit used for measuring performance. User can specify "
" `microsecond` (default) or `nanosecond` " ) ;
" `microsecond` (default) or `nanosecond` " ) ;
@ -242,7 +244,7 @@ int main(int argc, char** argv) {
" [OPTIONS]... " ) ;
" [OPTIONS]... " ) ;
ParseCommandLineFlags ( & argc , & argv , true ) ;
ParseCommandLineFlags ( & argc , & argv , true ) ;
rock sdb : : TableFactory * tf = new rocksdb : : BlockBasedTableFactory ( ) ;
st d : : shared_ptr < rocksdb : : TableFactory > tf ;
rocksdb : : Options options ;
rocksdb : : Options options ;
if ( FLAGS_prefix_len < 16 ) {
if ( FLAGS_prefix_len < 16 ) {
options . prefix_extractor . reset ( rocksdb : : NewFixedPrefixTransform (
options . prefix_extractor . reset ( rocksdb : : NewFixedPrefixTransform (
@ -253,7 +255,12 @@ int main(int argc, char** argv) {
options . create_if_missing = true ;
options . create_if_missing = true ;
options . compression = rocksdb : : CompressionType : : kNoCompression ;
options . compression = rocksdb : : CompressionType : : kNoCompression ;
if ( FLAGS_plain_table ) {
if ( FLAGS_table_factory = = " cuckoo_hash " ) {
options . allow_mmap_reads = true ;
env_options . use_mmap_reads = true ;
tf . reset ( rocksdb : : NewCuckooTableFactory ( 0.75 ) ) ;
} else if ( FLAGS_table_factory = = " plain_table " ) {
options . allow_mmap_reads = true ;
options . allow_mmap_reads = true ;
env_options . use_mmap_reads = true ;
env_options . use_mmap_reads = true ;
@ -262,22 +269,28 @@ int main(int argc, char** argv) {
plain_table_options . bloom_bits_per_key = ( FLAGS_prefix_len = = 16 ) ? 0 : 8 ;
plain_table_options . bloom_bits_per_key = ( FLAGS_prefix_len = = 16 ) ? 0 : 8 ;
plain_table_options . hash_table_ratio = 0.75 ;
plain_table_options . hash_table_ratio = 0.75 ;
tf = new rocksdb : : PlainTableFactory ( plain_table_options ) ;
tf . reset ( new rocksdb : : PlainTableFactory ( plain_table_options ) ) ;
options . prefix_extractor . reset ( rocksdb : : NewFixedPrefixTransform (
options . prefix_extractor . reset ( rocksdb : : NewFixedPrefixTransform (
FLAGS_prefix_len ) ) ;
FLAGS_prefix_len ) ) ;
} else if ( FLAGS_table_factory = = " block_based " ) {
tf . reset ( new rocksdb : : BlockBasedTableFactory ( ) ) ;
} else {
fprintf ( stderr , " Invalid table type %s \n " , FLAGS_table_factory . c_str ( ) ) ;
}
if ( tf ) {
// if user provides invalid options, just fall back to microsecond.
bool measured_by_nanosecond = FLAGS_time_unit = = " nanosecond " ;
options . table_factory = tf ;
rocksdb : : TableReaderBenchmark ( options , env_options , ro , FLAGS_num_keys1 ,
FLAGS_num_keys2 , FLAGS_iter , FLAGS_prefix_len ,
FLAGS_query_empty , FLAGS_iterator ,
FLAGS_through_db , measured_by_nanosecond ) ;
} else {
} else {
tf = new rocksdb : : BlockBasedTableFactory ( ) ;
return 1 ;
}
}
// if user provides invalid options, just fall back to microsecond.
bool measured_by_nanosecond = FLAGS_time_unit = = " nanosecond " ;
options . table_factory =
std : : shared_ptr < rocksdb : : TableFactory > ( tf ) ;
rocksdb : : TableReaderBenchmark ( options , env_options , ro , FLAGS_num_keys1 ,
FLAGS_num_keys2 , FLAGS_iter , FLAGS_prefix_len ,
FLAGS_query_empty , FLAGS_iterator ,
FLAGS_through_db , measured_by_nanosecond ) ;
delete tf ;
return 0 ;
return 0 ;
}
}