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
This commit is contained in:
parent
bd45633b71
commit
86ba3e24e3
@ -1097,19 +1097,19 @@ class StressTest {
|
|||||||
}
|
}
|
||||||
} else if ((int)FLAGS_readpercent <= prob_op && prob_op < prefixBound) {
|
} else if ((int)FLAGS_readpercent <= prob_op && prob_op < prefixBound) {
|
||||||
// OPERATION prefix scan
|
// OPERATION prefix scan
|
||||||
// keys are longs (e.g., 8 bytes), so we let prefixes be
|
// keys are 8 bytes long, prefix size is FLAGS_prefix_size. There are
|
||||||
// everything except the last byte. So there will be 2^8=256
|
// (8 - FLAGS_prefix_size) bytes besides the prefix. So there will
|
||||||
// keys per prefix.
|
// be 2 ^ ((8 - FLAGS_prefix_size * 8) combinations.
|
||||||
if (!FLAGS_test_batches_snapshots) {
|
if (!FLAGS_test_batches_snapshots) {
|
||||||
Slice prefix = Slice(key.data(), FLAGS_prefix_size);
|
Slice prefix = Slice(key.data(), FLAGS_prefix_size);
|
||||||
read_opts.prefix = &prefix;
|
read_opts.prefix = &prefix;
|
||||||
Iterator* iter = db_->NewIterator(read_opts);
|
Iterator* iter = db_->NewIterator(read_opts);
|
||||||
int count = 0;
|
int64_t count = 0;
|
||||||
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
|
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
|
||||||
assert(iter->key().starts_with(prefix));
|
assert(iter->key().starts_with(prefix));
|
||||||
count++;
|
++count;
|
||||||
}
|
}
|
||||||
assert(count <= 256);
|
assert(count <= (1 << ((8 - FLAGS_prefix_size) * 8)));
|
||||||
if (iter->status().ok()) {
|
if (iter->status().ok()) {
|
||||||
thread->stats.AddPrefixes(1, count);
|
thread->stats.AddPrefixes(1, count);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user