mdbx-test: fix key/value generation for long-length cases.

Change-Id: I643bca291948bf7659c77fffa31408c3794785e6
This commit is contained in:
Leonid Yuriev 2018-08-31 02:17:35 +03:00 committed by Leo Yuriev
parent 0be592530e
commit 96bdf6559e
2 changed files with 5 additions and 4 deletions

View File

@ -165,7 +165,7 @@ bool maker::increment(serial_t &serial, int delta) {
//-----------------------------------------------------------------------------
size_t length(serial_t serial) {
static size_t length(serial_t serial) {
size_t n = 0;
if (serial > UINT32_MAX) {
n = 4;
@ -199,7 +199,10 @@ void __hot maker::mk(const serial_t serial, const essentials &params,
assert(params.maxlen >= length(serial));
out.value.iov_base = out.bytes;
out.value.iov_len = params.minlen;
out.value.iov_len =
(params.maxlen > params.minlen)
? params.minlen + serial % (params.maxlen - params.minlen)
: params.minlen;
if (params.flags & (MDBX_INTEGERKEY | MDBX_INTEGERDUP)) {
assert(params.maxlen == params.minlen);

View File

@ -120,6 +120,4 @@ public:
bool increment(serial_t &serial, int delta);
};
size_t length(serial_t serial);
} /* namespace keygen */