From bc6b2ab401252277a07bc0e3c962b5eda40a8266 Mon Sep 17 00:00:00 2001 From: Feng Zhu Date: Wed, 16 Jul 2014 17:32:30 -0700 Subject: [PATCH] enable kHashSearch for blocktable in db_bench Summary: add a flag called use_hash_search in db_bench Test Plan: make all check ./db_bench --use_hash_search=1 Reviewers: ljin, haobo, yhchiang, sdong Reviewed By: sdong Subscribers: igor, dhruba Differential Revision: https://reviews.facebook.net/D20067 --- db/db_bench.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/db/db_bench.cc b/db/db_bench.cc index b74ce28e72..af83487a16 100644 --- a/db/db_bench.cc +++ b/db/db_bench.cc @@ -538,6 +538,9 @@ DEFINE_string(memtablerep, "skip_list", ""); DEFINE_int64(hash_bucket_count, 1024 * 1024, "hash bucket count"); DEFINE_bool(use_plain_table, false, "if use plain table " "instead of block-based table format"); +DEFINE_bool(use_hash_search, false, "if use kHashSearch " + "instead of kBinarySearch. " + "This is valid if only we use BlockTable"); DEFINE_string(merge_operator, "", "The merge operator to use with the database." "If a new merge operator is specified, be sure to use fresh" @@ -1624,7 +1627,7 @@ class Benchmark { options.compaction_style = FLAGS_compaction_style_e; options.block_size = FLAGS_block_size; options.filter_policy = filter_policy_; - if (FLAGS_use_plain_table) { + if (FLAGS_prefix_size != 0) { options.prefix_extractor.reset( NewFixedPrefixTransform(FLAGS_prefix_size)); } @@ -1685,8 +1688,17 @@ class Benchmark { if (bloom_bits_per_key < 0) { bloom_bits_per_key = 0; } - options.table_factory = std::shared_ptr( + options.table_factory.reset( NewPlainTableFactory(FLAGS_key_size, bloom_bits_per_key, 0.75)); + } else { + BlockBasedTableOptions block_based_options; + if (FLAGS_use_hash_search) { + block_based_options.index_type = BlockBasedTableOptions::kHashSearch; + } else { + block_based_options.index_type = BlockBasedTableOptions::kBinarySearch; + } + options.table_factory.reset( + NewBlockBasedTableFactory(block_based_options)); } if (FLAGS_max_bytes_for_level_multiplier_additional_v.size() > 0) { if (FLAGS_max_bytes_for_level_multiplier_additional_v.size() !=