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
2f727ef1
Commit
2f727ef1
authored
Jun 07, 2024
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mhnsw: cache start node too, don't push too much in pg_discard
parent
b2d1e9b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
sql/vector_mhnsw.cc
sql/vector_mhnsw.cc
+9
-9
No files found.
sql/vector_mhnsw.cc
View file @
2f727ef1
...
...
@@ -233,10 +233,10 @@ static int select_neighbors(MHNSW_Context *ctx, size_t layer,
if
((
discard
=
vec
->
distance_to
(
neigh
)
<
target_dist
))
break
;
}
if
(
discard
)
pq_discard
.
push
(
vec
);
else
if
(
!
discard
)
neighbors
.
push_back
(
vec
,
&
ctx
->
root
);
else
if
(
pq_discard
.
elements
()
+
neighbors
.
elements
<
max_neighbor_connections
)
pq_discard
.
push
(
vec
);
}
while
(
pq_discard
.
elements
()
&&
...
...
@@ -454,12 +454,12 @@ int mhnsw_insert(TABLE *table, KEY *keyinfo)
String
ref_str
,
*
ref_ptr
;
ref_ptr
=
graph
->
field
[
1
]
->
val_str
(
&
ref_str
);
FVectorNode
start_node
(
&
ctx
,
ref_ptr
->
ptr
());
FVectorNode
*
start_node
=
ctx
.
get_node
(
ref_ptr
->
ptr
());
if
(
start_nodes
.
push_back
(
&
start_node
,
&
ctx
.
root
))
if
(
start_nodes
.
push_back
(
start_node
,
&
ctx
.
root
))
return
HA_ERR_OUT_OF_MEM
;
if
(
int
err
=
start_node
.
instantiate_vector
())
if
(
int
err
=
start_node
->
instantiate_vector
())
return
err
;
if
(
ctx
.
vec_len
*
sizeof
(
float
)
!=
res
->
length
())
...
...
@@ -543,14 +543,14 @@ int mhnsw_first(TABLE *table, KEY *keyinfo, Item *dist, ulonglong limit)
List
<
FVectorNode
>
start_nodes
;
String
ref_str
,
*
ref_ptr
=
graph
->
field
[
1
]
->
val_str
(
&
ref_str
);
FVectorNode
start_node
(
&
ctx
,
ref_ptr
->
ptr
());
FVectorNode
*
start_node
=
ctx
.
get_node
(
ref_ptr
->
ptr
());
// one could put all max_layer nodes in start_nodes
// but it has no effect of the recall or speed
if
(
start_nodes
.
push_back
(
&
start_node
,
&
ctx
.
root
))
if
(
start_nodes
.
push_back
(
start_node
,
&
ctx
.
root
))
return
HA_ERR_OUT_OF_MEM
;
if
(
int
err
=
start_node
.
instantiate_vector
())
if
(
int
err
=
start_node
->
instantiate_vector
())
return
err
;
/*
...
...
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