Skip to content

Commit 6d2ec61

Browse files
LiuRuoyu01rock-git
authored andcommitted
[feat][store]Add binary flat index and binary ivf index
1 parent 1e4f4d9 commit 6d2ec61

24 files changed

+3924
-393
lines changed

contrib/faiss

Submodule faiss updated 213 files

src/client_v2/coordinator.cc

+20-3
Original file line numberDiff line numberDiff line change
@@ -1229,9 +1229,9 @@ void SetUpCreateRegion(CLI::App &app) {
12291229
cmd->add_flag("--use_json_parameter", opt->use_json_parameter, "Request parameter use_json_parameter swtich");
12301230
cmd->add_flag("--key_is_hex", opt->key_is_hex, "Request parameter key_is_hex");
12311231
cmd->add_option("--vector_index_type", opt->vector_index_type,
1232-
"Request parameter vector_index_type, hnsw|flat|ivf_flat|ivf_pq");
1232+
"Request parameter vector_index_type, hnsw|flat|ivf_flat|ivf_pq|binary_Flat|binary_ivf_flat");
12331233
cmd->add_option("--dimension", opt->dimension, "Request parameter dimension");
1234-
cmd->add_option("--metrics_type", opt->metrics_type, "Request parameter metrics_type, L2|IP|COSINE")->ignore_case();
1234+
cmd->add_option("--metrics_type", opt->metrics_type, "Request parameter metrics_type, L2|IP|COSINE|HAMMING")->ignore_case();
12351235
cmd->add_option("--max_elements", opt->max_elements, "Request parameter max_elements");
12361236
cmd->add_option("--efconstruction", opt->efconstruction, "Request parameter efconstruction");
12371237
cmd->add_option("--nlinks", opt->nlinks, "Request parameter nlinks");
@@ -1404,6 +1404,12 @@ void RunCreateRegion(CreateRegionOption const &opt) {
14041404
vector_index_parameter->set_vector_index_type(::dingodb::pb::common::VectorIndexType::VECTOR_INDEX_TYPE_IVF_FLAT);
14051405
} else if (opt.vector_index_type == "ivf_pq") {
14061406
vector_index_parameter->set_vector_index_type(::dingodb::pb::common::VectorIndexType::VECTOR_INDEX_TYPE_IVF_PQ);
1407+
} else if (opt.vector_index_type == "binary_flat") {
1408+
vector_index_parameter->set_vector_index_type(
1409+
::dingodb::pb::common::VectorIndexType::VECTOR_INDEX_TYPE_BINARY_FLAT);
1410+
} else if (opt.vector_index_type == "binary_ivf_flat") {
1411+
vector_index_parameter->set_vector_index_type(
1412+
::dingodb::pb::common::VectorIndexType::VECTOR_INDEX_TYPE_BINARY_IVF_FLAT);
14071413
} else {
14081414
DINGO_LOG(WARNING) << "vector_index_type is invalid, now only support hnsw and flat";
14091415
return;
@@ -1425,8 +1431,10 @@ void RunCreateRegion(CreateRegionOption const &opt) {
14251431
metric_type = ::dingodb::pb::common::MetricType::METRIC_TYPE_INNER_PRODUCT;
14261432
} else if (opt.metrics_type == "COSINE" || opt.metrics_type == "cosine") {
14271433
metric_type = ::dingodb::pb::common::MetricType::METRIC_TYPE_COSINE;
1434+
} else if (opt.metrics_type == "HAMMING" || opt.metrics_type == "hamming") {
1435+
metric_type = ::dingodb::pb::common::MetricType::METRIC_TYPE_HAMMING;
14281436
} else {
1429-
DINGO_LOG(WARNING) << "metrics_type is invalid, now only support L2, IP and COSINE";
1437+
DINGO_LOG(WARNING) << "metrics_type is invalid, now only support L2, IP, COSINE and HAMMING";
14301438
return;
14311439
}
14321440

@@ -1469,6 +1477,15 @@ void RunCreateRegion(CreateRegionOption const &opt) {
14691477
ivf_pq_index_parameter->set_ncentroids(opt.ncentroids);
14701478
ivf_pq_index_parameter->set_nsubvector(opt.nsubvector);
14711479
ivf_pq_index_parameter->set_nbits_per_idx(opt.nbits_per_idx);
1480+
} else if (opt.vector_index_type == "binary_flat") {
1481+
auto *binary_flat_parameter = vector_index_parameter->mutable_binary_flat_parameter();
1482+
binary_flat_parameter->set_metric_type(metric_type);
1483+
binary_flat_parameter->set_dimension(opt.dimension);
1484+
}else if(opt.vector_index_type=="binary_ivf_flat") {
1485+
auto *binary_ivf_flat_parameter = vector_index_parameter->mutable_binary_ivf_flat_parameter();
1486+
binary_ivf_flat_parameter->set_metric_type(metric_type);
1487+
binary_ivf_flat_parameter->set_dimension(opt.dimension);
1488+
binary_ivf_flat_parameter->set_ncentroids(opt.ncentroids);
14721489
}
14731490
}
14741491

0 commit comments

Comments
 (0)