From e2547103fd73e4565c8a430ab6b990f349702003 Mon Sep 17 00:00:00 2001 From: zhichao-cao Date: Mon, 28 Jan 2019 12:23:03 -0800 Subject: [PATCH] Fix the build error caused by the dynamic array (#4918) Summary: In the MixGraph benchmark of db_bench #4788 , the char array is initialized with an argument from user's input, which can cause build error on some platforms. Also, the msg char array size can be potentially smaller than the printed data, which should be extended from 100 to 256. Tested with make check. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4918 Differential Revision: D13844298 Pulled By: sagar0 fbshipit-source-id: 33c4809c5c4438f0a9f7b289d3f42e20c545bbab --- tools/db_bench_tool.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index d1911aa4c..70746d0e2 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -4667,23 +4667,25 @@ void VerifyDBFromDB(std::string& truth_db_name) { int64_t seek = 0; int64_t seek_found = 0; int64_t bytes = 0; - int64_t value_max = FLAGS_mix_max_value_size; + const int64_t default_value_max = 64*1024*1024; + int64_t value_max = default_value_max; int64_t scan_len_max = FLAGS_mix_max_scan_len; double write_rate = 1000000.0; double read_rate = 1000000.0; - std::vector ratio; - char value_buffer[2 * value_max]; + std::vector ratio {FLAGS_mix_get_ratio, + FLAGS_mix_put_ratio, FLAGS_mix_seek_ratio}; + char value_buffer[default_value_max]; QueryDecider query; RandomGenerator gen; Status s; + if(value_max > FLAGS_mix_max_value_size) { + value_max = FLAGS_mix_max_value_size; + } ReadOptions options(FLAGS_verify_checksum, true); std::unique_ptr key_guard; Slice key = AllocateKey(&key_guard); PinnableSlice pinnable_val; - ratio.push_back(FLAGS_mix_get_ratio); - ratio.push_back(FLAGS_mix_put_ratio); - ratio.push_back(FLAGS_mix_seek_ratio); query.Initiate(ratio); // the limit of qps initiation -- GitLab