Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
5f612051
Commit
5f612051
authored
Jan 03, 2013
by
John Esmet
Committed by
Yoni Fogel
Apr 17, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refs #5801 fix invariant
git-svn-id:
file:///svn/toku/tokudb@51678
c7de825b-a66e-492c-adef-691d508d4ae1
parent
f245bbb1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
src/tests/threaded_stress_test_helpers.h
src/tests/threaded_stress_test_helpers.h
+8
-7
No files found.
src/tests/threaded_stress_test_helpers.h
View file @
5f612051
...
...
@@ -651,21 +651,22 @@ static int generate_row_for_put(
// int if the key size is exactly 4, and it treats
// the key as an 8 byte int if the key size is 8 or more.
static
uint64_t
breverse
(
u
int64_t
v
)
static
int64_t
breverse
(
int64_t
v
)
// Effect: return the bits in i, reversed
// Notes: implementation taken from http://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious
// Rationale: just a hack to spread out the keys during loading, doesn't need to be fast but does need to be correct.
{
uint64_t
r
=
v
;
// r will be reversed bits of v; first get LSB of v
uint64_t
k
=
v
;
// r will be reversed bits of v; first get LSB of v
int
s
=
sizeof
(
v
)
*
CHAR_BIT
-
1
;
// extra shift needed at end
for
(
v
>>=
1
;
v
;
v
>>=
1
)
{
r
<<=
1
;
r
|=
v
&
1
;
k
<<=
1
;
k
|=
v
&
1
;
s
--
;
}
r
<<=
s
;
// shift when v's highest bits are zero
return
r
;
k
<<=
s
;
// shift when v's highest bits are zero
int64_t
r
=
k
;
return
r
<
0
?
-
r
:
r
;
}
static
void
...
...
@@ -673,10 +674,10 @@ fill_key_buf(int64_t key, uint8_t *data, struct cli_args *args) {
// Effect: Fill data with a specific little-endian integer, 4 or 8 bytes long
// depending on args->key_size, possibly padded with zeroes.
// Requires: *data is at least sizeof(uint64_t)
invariant
(
key
>=
0
);
if
(
args
->
disperse_keys
)
{
key
=
breverse
(
key
);
}
invariant
(
key
>=
0
);
if
(
args
->
key_size
==
sizeof
(
int
))
{
const
int
key32
=
key
;
memcpy
(
data
,
&
key32
,
sizeof
(
key32
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment