Skip to content

Commit

Permalink
Add config test.
Browse files Browse the repository at this point in the history
  • Loading branch information
small-turtle-1 committed Jan 20, 2025
1 parent 7765f2f commit c5405c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/storage/definition/index_hnsw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,17 @@ LSGConfig LSGConfig::FromString(const String &str) {
// example: "sample_raito=0.01,ls_k=10,alpha=1.0"
LSGConfig lsg_config;
std::string_view sv(str);
while (true) {
bool end = false;
do {
auto r = sv.find(',');
if (r == std::string_view::npos) {
r = sv.size();
break;
end = true;
}
auto kv = sv.substr(0, r);
sv.remove_prefix(r + 1);
if (!end) {
sv.remove_prefix(r + 1);
}
auto pos = kv.find('=');
if (pos == std::string_view::npos) {
Status status = Status::InvalidIndexParam(String(kv));
Expand All @@ -109,7 +112,7 @@ LSGConfig LSGConfig::FromString(const String &str) {
Status status = Status::InvalidIndexParam(String(key));
RecoverableError(status);
}
}
} while (!end);
return lsg_config;
}

Expand Down
5 changes: 4 additions & 1 deletion test/sql/dql/knn/embedding/test_knn_hnsw_l2_lsg.slt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ statement ok
COPY test_knn_hnsw_l2 FROM '/var/infinity/test_data/embedding_float_dim4.csv' WITH (DELIMITER ',', FORMAT CSV);

statement ok
CREATE INDEX idx1 ON test_knn_hnsw_l2 (c2) USING Hnsw WITH (M = 16, ef_construction = 200, metric = l2, build_type = lsg);
CREATE INDEX idx1 ON test_knn_hnsw_l2 (c2) USING Hnsw WITH (M = 16, ef_construction = 200, metric = l2, build_type = lsg, lsg_config = 'sample_raito=0.01,ls_k=10,alpha=1.0');

statement ok
INSERT INTO test_knn_hnsw_l2 VALUES (2, [0.1, 0.2, 0.3, -0.2]);
Expand Down Expand Up @@ -37,3 +37,6 @@ SELECT c1 FROM test_knn_hnsw_l2 SEARCH MATCH VECTOR (c2, [0.3, 0.3, 0.2, 0.2], '
8
6
6

statement ok
DROP TABLE test_knn_hnsw_l2;

0 comments on commit c5405c6

Please sign in to comment.