From 86ba3e24e3d324bd0db5b8b24dc07ff30ed8cf02 Mon Sep 17 00:00:00 2001 From: Lei Jin Date: Tue, 11 Mar 2014 16:33:42 -0700 Subject: [PATCH] make assert based on FLAGS_prefix_size Summary: as title Test Plan: running python tools/db_crashtest.py Reviewers: igor Reviewed By: igor CC: leveldb Differential Revision: https://reviews.facebook.net/D16803 --- tools/db_stress.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/db_stress.cc b/tools/db_stress.cc index 06df06701..ca75bacbd 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -1097,19 +1097,19 @@ class StressTest { } } else if ((int)FLAGS_readpercent <= prob_op && prob_op < prefixBound) { // OPERATION prefix scan - // keys are longs (e.g., 8 bytes), so we let prefixes be - // everything except the last byte. So there will be 2^8=256 - // keys per prefix. + // keys are 8 bytes long, prefix size is FLAGS_prefix_size. There are + // (8 - FLAGS_prefix_size) bytes besides the prefix. So there will + // be 2 ^ ((8 - FLAGS_prefix_size * 8) combinations. if (!FLAGS_test_batches_snapshots) { Slice prefix = Slice(key.data(), FLAGS_prefix_size); read_opts.prefix = &prefix; Iterator* iter = db_->NewIterator(read_opts); - int count = 0; + int64_t count = 0; for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { assert(iter->key().starts_with(prefix)); - count++; + ++count; } - assert(count <= 256); + assert(count <= (1 << ((8 - FLAGS_prefix_size) * 8))); if (iter->status().ok()) { thread->stats.AddPrefixes(1, count); } else {