C++17 support (#4482)

Summary:
Closes https://github.com/facebook/rocksdb/issues/4462

I'm not sure if you'll be happy with `std::random_device{}`, perhaps you would want to use your rand instance instead. I didn't test to see if your rand instance supports the requirements that `std::shuffle` takes.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4482

Differential Revision: D10325133

Pulled By: yiwu-arbug

fbshipit-source-id: 47b7adaf4bb2b8d64cf090ea6b1b48ef53180581
main
zpalmtree 6 years ago committed by Facebook Github Bot
parent c648d90f8e
commit 46dd8b1e13
  1. 10
      util/transaction_test_util.cc

@ -13,6 +13,7 @@
#include <inttypes.h> #include <inttypes.h>
#include <algorithm> #include <algorithm>
#include <numeric> #include <numeric>
#include <random>
#include <string> #include <string>
#include <thread> #include <thread>
@ -135,8 +136,7 @@ bool RandomTransactionInserter::DoInsert(DB* db, Transaction* txn,
std::vector<uint16_t> set_vec(num_sets_); std::vector<uint16_t> set_vec(num_sets_);
std::iota(set_vec.begin(), set_vec.end(), static_cast<uint16_t>(0)); std::iota(set_vec.begin(), set_vec.end(), static_cast<uint16_t>(0));
std::random_shuffle(set_vec.begin(), set_vec.end(), std::shuffle(set_vec.begin(), set_vec.end(), std::random_device{});
[&](uint64_t r) { return rand_->Uniform(r); });
// For each set, pick a key at random and increment it // For each set, pick a key at random and increment it
for (uint16_t set_i : set_vec) { for (uint16_t set_i : set_vec) {
@ -258,10 +258,8 @@ Status RandomTransactionInserter::Verify(DB* db, uint16_t num_sets,
std::vector<uint16_t> set_vec(num_sets); std::vector<uint16_t> set_vec(num_sets);
std::iota(set_vec.begin(), set_vec.end(), static_cast<uint16_t>(0)); std::iota(set_vec.begin(), set_vec.end(), static_cast<uint16_t>(0));
if (rand) { std::shuffle(set_vec.begin(), set_vec.end(), std::random_device{});
std::random_shuffle(set_vec.begin(), set_vec.end(),
[&](uint64_t r) { return rand->Uniform(r); });
}
// For each set of keys with the same prefix, sum all the values // For each set of keys with the same prefix, sum all the values
for (uint16_t set_i : set_vec) { for (uint16_t set_i : set_vec) {
// Five digits (since the largest uint16_t is 65535) plus the NUL // Five digits (since the largest uint16_t is 65535) plus the NUL

Loading…
Cancel
Save