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
04bea2d0
Commit
04bea2d0
authored
Aug 13, 2007
by
Bradley C. Kuszmaul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use primes right in the hash table
git-svn-id:
file:///svn/tokudb@128
c7de825b-a66e-492c-adef-691d508d4ae1
parent
47ac4c45
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
newbrt/hashtable.c
newbrt/hashtable.c
+7
-4
No files found.
newbrt/hashtable.c
View file @
04bea2d0
...
...
@@ -53,7 +53,10 @@ int toku_hash_find (HASHTABLE tab, bytevec key, ITEMLEN keylen, bytevec *data, I
}
}
int
toku_hash_rehash_everything
(
HASHTABLE
tab
,
unsigned
int
newarraysize
)
{
int
toku_hash_rehash_everything
(
HASHTABLE
tab
,
unsigned
int
primeindexdelta
)
{
int
newprimeindex
=
primeindexdelta
+
tab
->
primeidx
;
assert
(
newprimeindex
>=
0
);
unsigned
int
newarraysize
=
get_prime
(
newprimeindex
);
HASHELT
*
newarray
=
toku_calloc
(
newarraysize
,
sizeof
(
*
tab
->
array
));
unsigned
int
i
;
assert
(
newarray
!=
0
);
...
...
@@ -102,7 +105,7 @@ int toku_hash_insert (HASHTABLE tab, const void *key, ITEMLEN keylen, const void
tab
->
array
[
h
]
=
he
;
tab
->
n_keys
++
;
if
(
tab
->
n_keys
>
tab
->
arraysize
)
{
return
toku_hash_rehash_everything
(
tab
,
tab
->
arraysize
*
2
);
return
toku_hash_rehash_everything
(
tab
,
+
1
);
}
return
BRT_OK
;
}
...
...
@@ -121,8 +124,8 @@ int toku_hash_delete (HASHTABLE tab, const void *key, ITEMLEN keylen) {
toku_free_n
(
he
,
sizeof
(
*
he
)
+
he
->
keylen
+
he
->
vallen
);
tab
->
n_keys
--
;
if
((
tab
->
n_keys
*
4
<
tab
->
arraysize
)
&&
tab
->
arraysize
>
4
)
{
return
toku_hash_rehash_everything
(
tab
,
tab
->
arraysize
/
2
);
if
((
tab
->
n_keys
*
4
<
tab
->
arraysize
)
&&
tab
->
primeidx
>
0
)
{
return
toku_hash_rehash_everything
(
tab
,
-
1
);
}
return
BRT_OK
;
}
...
...
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