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
471ad43c
Commit
471ad43c
authored
Aug 14, 2007
by
Bradley C. Kuszmaul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speedup toku_hashtable_random_pick
git-svn-id:
file:///svn/tokudb@134
c7de825b-a66e-492c-adef-691d508d4ae1
parent
8242d2e0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
6 deletions
+9
-6
newbrt/brt.c
newbrt/brt.c
+2
-1
newbrt/hashtable.c
newbrt/hashtable.c
+3
-2
newbrt/hashtable.h
newbrt/hashtable.h
+1
-1
newbrt/hashtest.c
newbrt/hashtest.c
+2
-1
newbrt/key.c
newbrt/key.c
+1
-1
No files found.
newbrt/brt.c
View file @
471ad43c
...
...
@@ -709,9 +709,10 @@ static int push_some_kvpairs_down (BRT t, BRTNODE node, int childnum,
{
bytevec
key
,
val
;
ITEMLEN
keylen
,
vallen
;
long
int
randomnumber
=
random
();
//printf("%s:%d Try random_pick, weight=%d \n", __FILE__, __LINE__, node->u.n.n_bytes_in_hashtable[childnum]);
assert
(
toku_hashtable_n_entries
(
node
->
u
.
n
.
htables
[
childnum
])
>
0
);
while
(
0
==
toku_hashtable_random_pick
(
node
->
u
.
n
.
htables
[
childnum
],
&
key
,
&
keylen
,
&
val
,
&
vallen
))
{
while
(
0
==
toku_hashtable_random_pick
(
node
->
u
.
n
.
htables
[
childnum
],
&
key
,
&
keylen
,
&
val
,
&
vallen
,
&
randomnumber
))
{
int
child_did_split
=
0
;
BRTNODE
childa
,
childb
;
DBT
hk
,
hv
;
DBT
childsplitk
;
...
...
newbrt/hashtable.c
View file @
471ad43c
...
...
@@ -134,9 +134,9 @@ int toku_hash_delete (HASHTABLE tab, const void *key, ITEMLEN keylen) {
}
int
toku_hashtable_random_pick
(
HASHTABLE
h
,
bytevec
*
key
,
ITEMLEN
*
keylen
,
bytevec
*
data
,
ITEMLEN
*
datalen
)
{
int
toku_hashtable_random_pick
(
HASHTABLE
h
,
bytevec
*
key
,
ITEMLEN
*
keylen
,
bytevec
*
data
,
ITEMLEN
*
datalen
,
long
int
*
randomnumber
)
{
unsigned
int
i
;
unsigned
int
usei
=
random
(
)
%
h
->
arraysize
;
unsigned
int
usei
=
(
*
randomnumber
)
%
h
->
arraysize
;
for
(
i
=
0
;
i
<
h
->
arraysize
;
i
++
,
usei
++
)
{
if
(
usei
>=
h
->
arraysize
)
usei
=
0
;
HASHELT
he
=
h
->
array
[
usei
];
...
...
@@ -145,6 +145,7 @@ int toku_hashtable_random_pick(HASHTABLE h, bytevec *key, ITEMLEN *keylen, bytev
*
keylen
=
he
->
keylen
;
*
data
=
&
he
->
keyval
[
he
->
keylen
];
*
datalen
=
he
->
vallen
;
*
randomnumber
=
usei
;
return
0
;
}
}
...
...
newbrt/hashtable.h
View file @
471ad43c
...
...
@@ -24,7 +24,7 @@ int toku_hashtable_n_entries(HASHTABLE);
void
toku_hashtable_clear
(
HASHTABLE
);
int
toku_hashtable_random_pick
(
HASHTABLE
h
,
bytevec
*
key
,
ITEMLEN
*
keylen
,
bytevec
*
data
,
ITEMLEN
*
datalen
);
int
toku_hashtable_random_pick
(
HASHTABLE
h
,
bytevec
*
key
,
ITEMLEN
*
keylen
,
bytevec
*
data
,
ITEMLEN
*
datalen
,
long
int
*
randomnumber
);
//int hashtable_find_last(HASHTABLE h, bytevec *key, ITEMLEN *keylen, bytevec *data, ITEMLEN *datalen);
typedef
struct
hashelt
*
HASHELT
;
...
...
newbrt/hashtest.c
View file @
471ad43c
...
...
@@ -127,7 +127,8 @@ void test1(void) {
for
(
j
=
0
;
j
<
4
;
j
++
)
{
bytevec
key
,
val
;
ITEMLEN
keylen
,
vallen
;
r
=
toku_hashtable_random_pick
(
table
,
&
key
,
&
keylen
,
&
val
,
&
vallen
);
long
int
randnum
=
random
();
r
=
toku_hashtable_random_pick
(
table
,
&
key
,
&
keylen
,
&
val
,
&
vallen
,
&
randnum
);
assert
(
r
==
0
);
r
=
toku_hash_delete
(
table
,
key
,
keylen
);
assert
(
r
==
0
);
...
...
newbrt/key.c
View file @
471ad43c
...
...
@@ -62,7 +62,7 @@ int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) {
return
key1len
-
key2len
;
}
#else
/* unroll that one
twice
*/
/* unroll that one
four times
*/
int
keycompare
(
bytevec
key1
,
ITEMLEN
key1len
,
bytevec
key2
,
ITEMLEN
key2len
)
{
int
comparelen
=
key1len
<
key2len
?
key1len
:
key2len
;
const
unsigned
char
*
k1
;
...
...
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