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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
c78685e0
Commit
c78685e0
authored
May 28, 2002
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed unnecessary key search in the hp_rb_write_key() function
parent
c1f3be5b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
16 deletions
+25
-16
heap/hp_open.c
heap/hp_open.c
+2
-2
heap/hp_write.c
heap/hp_write.c
+14
-13
include/my_tree.h
include/my_tree.h
+4
-1
mysys/tree.c
mysys/tree.c
+5
-0
No files found.
heap/hp_open.c
View file @
c78685e0
...
@@ -99,8 +99,8 @@ HP_INFO *heap_open(const char *name, int mode, uint keys, HP_KEYDEF *keydef,
...
@@ -99,8 +99,8 @@ HP_INFO *heap_open(const char *name, int mode, uint keys, HP_KEYDEF *keydef,
if
(
keydef
[
i
].
algorithm
==
HA_KEY_ALG_BTREE
)
if
(
keydef
[
i
].
algorithm
==
HA_KEY_ALG_BTREE
)
{
{
init_tree
(
&
keyinfo
->
rb_tree
,
0
,
0
,
0
,
(
qsort_cmp2
)
keys_compare
,
1
,
init_tree
(
&
keyinfo
->
rb_tree
,
0
,
0
,
sizeof
(
byte
*
)
,
NULL
,
NULL
);
(
qsort_cmp2
)
keys_compare
,
1
,
NULL
,
NULL
);
keyinfo
->
delete_key
=
hp_rb_delete_key
;
keyinfo
->
delete_key
=
hp_rb_delete_key
;
keyinfo
->
write_key
=
hp_rb_write_key
;
keyinfo
->
write_key
=
hp_rb_write_key
;
nsegs
++
;
nsegs
++
;
...
...
heap/hp_write.c
View file @
c78685e0
...
@@ -96,22 +96,23 @@ int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, const byte *record,
...
@@ -96,22 +96,23 @@ int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, const byte *record,
info
->
last_pos
=
NULL
;
/* For heap_rnext/heap_rprev */
info
->
last_pos
=
NULL
;
/* For heap_rnext/heap_rprev */
custom_arg
.
keyseg
=
keyinfo
->
seg
;
custom_arg
.
keyseg
=
keyinfo
->
seg
;
custom_arg
.
key_length
=
hp_rb_make_key
(
keyinfo
,
info
->
recbuf
,
record
,
recpos
);
custom_arg
.
key_length
=
hp_rb_make_key
(
keyinfo
,
info
->
recbuf
,
record
,
recpos
);
if
((
keyinfo
->
flag
&
HA_NOSAME
)
&&
if
(
keyinfo
->
flag
&
HA_NOSAME
)
(
!
(
keyinfo
->
flag
&
HA_NULL_PART_KEY
)
||
!
hp_if_null_in_key
(
keyinfo
,
record
)))
{
{
custom_arg
.
search_flag
=
SEARCH_FIND
|
SEARCH_SAME
;
custom_arg
.
search_flag
=
SEARCH_FIND
|
SEARCH_SAME
;
if
(
tree_search_key
(
&
keyinfo
->
rb_tree
,
info
->
recbuf
,
info
->
parents
,
keyinfo
->
rb_tree
.
flag
=
TREE_NO_DUPS
;
&
info
->
last_pos
,
0
,
&
custom_arg
))
}
{
else
my_errno
=
HA_ERR_FOUND_DUPP_KEY
;
{
return
1
;
custom_arg
.
search_flag
=
SEARCH_SAME
;
}
keyinfo
->
rb_tree
.
flag
=
0
;
}
if
(
!
tree_insert
(
&
keyinfo
->
rb_tree
,
(
void
*
)
info
->
recbuf
,
custom_arg
.
key_length
,
&
custom_arg
))
{
my_errno
=
HA_ERR_FOUND_DUPP_KEY
;
return
1
;
}
}
custom_arg
.
search_flag
=
SEARCH_SAME
;
return
0
;
return
tree_insert
(
&
keyinfo
->
rb_tree
,
(
void
*
)
info
->
recbuf
,
custom_arg
.
key_length
+
sizeof
(
byte
*
),
&
custom_arg
)
?
0
:
1
;
}
}
/* Find where to place new record */
/* Find where to place new record */
...
...
include/my_tree.h
View file @
c78685e0
...
@@ -27,6 +27,8 @@ extern "C" {
...
@@ -27,6 +27,8 @@ extern "C" {
#define tree_set_pointer(element,ptr) *((byte **) (element+1))=((byte*) (ptr))
#define tree_set_pointer(element,ptr) *((byte **) (element+1))=((byte*) (ptr))
#define TREE_NO_DUPS 1
typedef
enum
{
left_root_right
,
right_root_left
}
TREE_WALK
;
typedef
enum
{
left_root_right
,
right_root_left
}
TREE_WALK
;
typedef
uint32
element_count
;
typedef
uint32
element_count
;
typedef
int
(
*
tree_walk_action
)(
void
*
,
element_count
,
void
*
);
typedef
int
(
*
tree_walk_action
)(
void
*
,
element_count
,
void
*
);
...
@@ -55,10 +57,11 @@ typedef struct st_tree {
...
@@ -55,10 +57,11 @@ typedef struct st_tree {
TREE_ELEMENT
**
parents
[
MAX_TREE_HEIGHT
];
TREE_ELEMENT
**
parents
[
MAX_TREE_HEIGHT
];
uint
offset_to_key
,
elements_in_tree
,
size_of_element
,
memory_limit
,
allocated
;
uint
offset_to_key
,
elements_in_tree
,
size_of_element
,
memory_limit
,
allocated
;
qsort_cmp2
compare
;
qsort_cmp2
compare
;
void
*
custom_arg
;
void
*
custom_arg
;
MEM_ROOT
mem_root
;
MEM_ROOT
mem_root
;
my_bool
with_delete
;
my_bool
with_delete
;
tree_element_free
free
;
tree_element_free
free
;
uint
flag
;
}
TREE
;
}
TREE
;
/* Functions on whole tree */
/* Functions on whole tree */
...
...
mysys/tree.c
View file @
c78685e0
...
@@ -86,6 +86,7 @@ void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit,
...
@@ -86,6 +86,7 @@ void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit,
tree
->
custom_arg
=
custom_arg
;
tree
->
custom_arg
=
custom_arg
;
tree
->
null_element
.
colour
=
BLACK
;
tree
->
null_element
.
colour
=
BLACK
;
tree
->
null_element
.
left
=
tree
->
null_element
.
right
=
0
;
tree
->
null_element
.
left
=
tree
->
null_element
.
right
=
0
;
tree
->
flag
=
0
;
if
(
!
free_element
&&
size
>=
0
&&
if
(
!
free_element
&&
size
>=
0
&&
((
uint
)
size
<=
sizeof
(
void
*
)
||
((
uint
)
size
&
(
sizeof
(
void
*
)
-
1
))))
((
uint
)
size
<=
sizeof
(
void
*
)
||
((
uint
)
size
&
(
sizeof
(
void
*
)
-
1
))))
{
{
...
@@ -231,7 +232,11 @@ TREE_ELEMENT *tree_insert(TREE *tree, void *key, uint key_size,
...
@@ -231,7 +232,11 @@ TREE_ELEMENT *tree_insert(TREE *tree, void *key, uint key_size,
rb_insert
(
tree
,
parent
,
element
);
/* rebalance tree */
rb_insert
(
tree
,
parent
,
element
);
/* rebalance tree */
}
}
else
else
{
if
(
tree
->
flag
&
TREE_NO_DUPS
)
return
(
NULL
);
element
->
count
++
;
element
->
count
++
;
}
DBUG_EXECUTE
(
"check_tree"
,
test_rb_tree
(
tree
->
root
););
DBUG_EXECUTE
(
"check_tree"
,
test_rb_tree
(
tree
->
root
););
return
element
;
return
element
;
}
}
...
...
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