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
43cc18c5
Commit
43cc18c5
authored
May 29, 2024
by
Vicențiu Ciorbaru
Committed by
Sergei Golubchik
Sep 14, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: simplify Queue<>, add const
also add const to methods in List<> and Hash_set<> while we're at it
parent
d284d93f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
29 deletions
+43
-29
sql/filesort.cc
sql/filesort.cc
+2
-2
sql/item_subselect.cc
sql/item_subselect.cc
+4
-3
sql/item_subselect.h
sql/item_subselect.h
+5
-3
sql/sql_hset.h
sql/sql_hset.h
+13
-3
sql/sql_list.h
sql/sql_list.h
+2
-2
sql/sql_queue.h
sql/sql_queue.h
+9
-8
sql/vector_mhnsw.cc
sql/vector_mhnsw.cc
+8
-8
No files found.
sql/filesort.cc
View file @
43cc18c5
...
...
@@ -52,7 +52,7 @@ class Bounded_queue
uchar
**
m_sort_keys
;
size_t
m_compare_length
;
Sort_param
*
m_sort_param
;
Queue
<
uchar
*
,
uchar
*
,
size_t
>
m_queue
;
Queue
<
uchar
*
,
size_t
>
m_queue
;
};
...
...
@@ -68,7 +68,7 @@ int Bounded_queue::init(ha_rows max_elements, size_t cmplen,
if
(
max_elements
>=
UINT_MAX
-
1
)
return
1
;
// We allocate space for one extra element, for replace when queue is full.
return
m_queue
.
init
((
uint
)
max_elements
+
1
,
0
,
true
,
return
m_queue
.
init
((
uint
)
max_elements
+
1
,
true
,
(
decltype
(
m_queue
)
::
Queue_compare
)
get_ptr_compare
(
cmplen
),
&
m_compare_length
);
}
...
...
sql/item_subselect.cc
View file @
43cc18c5
...
...
@@ -6654,7 +6654,7 @@ subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts,
if
(
merge_keys
[
i
]
->
sort_keys
())
return
TRUE
;
if
(
pq
.
init
(
merge_keys_count
,
0
,
false
,
if
(
pq
.
init
(
merge_keys_count
,
false
,
subselect_rowid_merge_engine
::
cmp_keys_by_cur_rownum
))
return
TRUE
;
...
...
@@ -6713,8 +6713,9 @@ subselect_rowid_merge_engine::cmp_keys_by_null_selectivity(Ordered_key **k1,
*/
int
subselect_rowid_merge_engine
::
cmp_keys_by_cur_rownum
(
void
*
,
Ordered_key
*
k1
,
Ordered_key
*
k2
)
subselect_rowid_merge_engine
::
cmp_keys_by_cur_rownum
(
void
*
,
const
Ordered_key
*
k1
,
const
Ordered_key
*
k2
)
{
rownum_t
r1
=
k1
->
current
();
rownum_t
r2
=
k2
->
current
();
...
...
sql/item_subselect.h
View file @
43cc18c5
...
...
@@ -1368,7 +1368,7 @@ class Ordered_key : public Sql_alloc
return
FALSE
;
};
/* Return the current index element. */
rownum_t
current
()
rownum_t
current
()
const
{
DBUG_ASSERT
(
key_buff_elements
&&
cur_key_idx
<
key_buff_elements
);
return
key_buff
[
cur_key_idx
];
...
...
@@ -1507,7 +1507,7 @@ class subselect_rowid_merge_engine: public subselect_partial_match_engine
Priority queue of Ordered_key indexes, one per NULLable column.
This queue is used by the partial match algorithm in method exec().
*/
Queue
<
Ordered_key
,
Ordered_key
>
pq
;
Queue
<
Ordered_key
>
pq
;
protected:
/*
Comparison function to compare keys in order of decreasing bitmap
...
...
@@ -1518,7 +1518,9 @@ class subselect_rowid_merge_engine: public subselect_partial_match_engine
Comparison function used by the priority queue pq, the 'smaller' key
is the one with the smaller current row number.
*/
static
int
cmp_keys_by_cur_rownum
(
void
*
arg
,
Ordered_key
*
k1
,
Ordered_key
*
k2
);
static
int
cmp_keys_by_cur_rownum
(
void
*
arg
,
const
Ordered_key
*
k1
,
const
Ordered_key
*
k2
);
bool
test_null_row
(
rownum_t
row_num
);
bool
exists_complementing_null_row
(
MY_BITMAP
*
keys_to_complement
);
...
...
sql/sql_hset.h
View file @
43cc18c5
...
...
@@ -62,18 +62,28 @@ class Hash_set
@retval FALSE OK. The value either was inserted or existed
in the hash.
*/
bool
insert
(
T
*
value
)
bool
insert
(
const
T
*
value
)
{
return
my_hash_insert
(
&
m_hash
,
reinterpret_cast
<
const
uchar
*>
(
value
));
}
bool
remove
(
T
*
value
)
bool
remove
(
const
T
*
value
)
{
return
my_hash_delete
(
&
m_hash
,
reinterpret_cast
<
uchar
*>
(
value
));
return
my_hash_delete
(
&
m_hash
,
reinterpret_cast
<
uchar
*>
(
const_cast
<
T
*>
(
value
)));
}
T
*
find
(
const
void
*
key
,
size_t
klen
)
const
{
return
(
T
*
)
my_hash_search
(
&
m_hash
,
reinterpret_cast
<
const
uchar
*>
(
key
),
klen
);
}
T
*
find
(
const
T
*
other
)
const
{
DBUG_ASSERT
(
m_hash
.
get_key
);
size_t
klen
;
uchar
*
key
=
m_hash
.
get_key
(
reinterpret_cast
<
const
uchar
*>
(
other
),
&
klen
,
false
);
return
find
(
key
,
klen
);
}
/** Is this hash set empty? */
bool
is_empty
()
const
{
return
m_hash
.
records
==
0
;
}
/** Returns the number of unique elements. */
...
...
sql/sql_list.h
View file @
43cc18c5
...
...
@@ -496,8 +496,8 @@ template <class T> class List :public base_list
inline
List
()
:
base_list
()
{}
inline
List
(
const
List
<
T
>
&
tmp
,
MEM_ROOT
*
mem_root
)
:
base_list
(
tmp
,
mem_root
)
{}
inline
bool
push_back
(
T
*
a
)
{
return
base_list
::
push_back
(
a
);
}
inline
bool
push_back
(
T
*
a
,
MEM_ROOT
*
mem_root
)
inline
bool
push_back
(
const
T
*
a
)
{
return
base_list
::
push_back
((
void
*
)
a
);
}
inline
bool
push_back
(
const
T
*
a
,
MEM_ROOT
*
mem_root
)
{
return
base_list
::
push_back
((
void
*
)
a
,
mem_root
);
}
inline
bool
push_front
(
const
T
*
a
)
{
return
base_list
::
push_front
(
a
);
}
inline
bool
push_front
(
const
T
*
a
,
MEM_ROOT
*
mem_root
)
...
...
sql/sql_queue.h
View file @
43cc18c5
...
...
@@ -16,24 +16,25 @@
#ifndef QUEUE_INCLUDED
#define QUEUE_INCLUDED
#include <my_global.h>
#include "queues.h"
/**
A typesafe wrapper of QUEUE, a priority heap
*/
template
<
typename
Element
,
typename
Key
,
typename
Param
=
void
>
template
<
typename
Element
,
typename
Param
=
void
>
class
Queue
{
public:
typedef
int
(
*
Queue_compare
)(
Param
*
,
Key
*
,
Key
*
);
typedef
int
(
*
Queue_compare
)(
Param
*
,
const
Element
*
,
const
Element
*
);
Queue
()
{
m_queue
.
root
=
0
;
}
~
Queue
()
{
delete_queue
(
&
m_queue
);
}
int
init
(
uint
max_elements
,
uint
offset_to_key
,
bool
max_at_top
,
Queue_compare
compare
,
Param
*
param
=
0
)
int
init
(
uint
max_elements
,
bool
max_at_top
,
Queue_compare
compare
,
Param
*
param
=
0
)
{
return
init_queue
(
&
m_queue
,
max_elements
,
offset_to_key
,
max_at_top
,
(
queue_compare
)
compare
,
param
,
0
,
0
);
return
init_queue
(
&
m_queue
,
max_elements
,
0
,
max_at_top
,
(
queue_compare
)
compare
,
(
void
*
)
param
,
0
,
0
);
}
size_t
elements
()
const
{
return
m_queue
.
elements
;
}
...
...
@@ -42,11 +43,11 @@ class Queue
bool
is_empty
()
const
{
return
elements
()
==
0
;
}
Element
*
top
()
const
{
return
(
Element
*
)
queue_top
(
&
m_queue
);
}
void
push
(
Element
*
element
)
{
queue_insert
(
&
m_queue
,
(
uchar
*
)
element
);
}
void
push
(
const
Element
*
element
)
{
queue_insert
(
&
m_queue
,
(
uchar
*
)
element
);
}
Element
*
pop
()
{
return
(
Element
*
)
queue_remove_top
(
&
m_queue
);
}
void
clear
()
{
queue_remove_all
(
&
m_queue
);
}
void
propagate_top
()
{
queue_replace_top
(
&
m_queue
);
}
void
replace_top
(
Element
*
element
)
void
replace_top
(
const
Element
*
element
)
{
queue_top
(
&
m_queue
)
=
(
uchar
*
)
element
;
propagate_top
();
...
...
sql/vector_mhnsw.cc
View file @
43cc18c5
...
...
@@ -78,21 +78,21 @@ int mhnsw_insert(TABLE *table, KEY *keyinfo)
return
err
==
HA_ERR_END_OF_FILE
?
0
:
err
;
}
static
int
cmp_float
(
void
*
,
float
*
a
,
float
*
b
)
{
return
*
a
<
*
b
?
-
1
:
*
a
==
*
b
?
0
:
1
;
}
struct
Node
{
float
distance
;
uchar
ref
[
1000
];
};
static
int
cmp_float
(
void
*
,
const
Node
*
a
,
const
Node
*
b
)
{
return
a
->
distance
<
b
->
distance
?
-
1
:
a
->
distance
==
b
->
distance
?
0
:
1
;
}
int
mhnsw_first
(
TABLE
*
table
,
Item
*
dist
,
ulonglong
limit
)
{
TABLE
*
graph
=
table
->
hlindex
;
Queue
<
Node
,
float
>
todo
,
result
;
Queue
<
Node
>
todo
,
result
;
Node
*
cur
;
String
*
str
,
strbuf
;
const
size_t
ref_length
=
table
->
file
->
ref_length
;
...
...
@@ -105,10 +105,10 @@ int mhnsw_first(TABLE *table, Item *dist, ulonglong limit)
DBUG_ASSERT
(
graph
);
if
(
todo
.
init
(
1000
,
0
,
0
,
cmp_float
))
// XXX + autoextent
if
(
todo
.
init
(
1000
,
0
,
cmp_float
))
// XXX + autoextent
return
HA_ERR_OUT_OF_MEM
;
if
(
result
.
init
(
limit
,
0
,
1
,
cmp_float
))
if
(
result
.
init
(
limit
,
1
,
cmp_float
))
return
HA_ERR_OUT_OF_MEM
;
if
((
err
=
graph
->
file
->
ha_index_init
(
0
,
1
)))
...
...
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