Skip to content

Commit

Permalink
add builder for HnswConfigDiff
Browse files Browse the repository at this point in the history
  • Loading branch information
JojiiOfficial committed May 1, 2024
1 parent dc46e8e commit fdbc50f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/qdrant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,38 +171,46 @@ pub struct OptimizerStatus {
#[prost(string, tag = "2")]
pub error: ::prost::alloc::string::String,
}
#[derive(derive_builder::Builder)]
#[builder(build_fn(private, error = "std::convert::Infallible", name = "build_inner"))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HnswConfigDiff {
///
/// Number of edges per node in the index graph. Larger the value - more accurate the search, more space required.
#[prost(uint64, optional, tag = "1")]
#[builder(default, setter(strip_option))]
pub m: ::core::option::Option<u64>,
///
/// Number of neighbours to consider during the index building. Larger the value - more accurate the search, more time required to build the index.
#[prost(uint64, optional, tag = "2")]
#[builder(default, setter(strip_option))]
pub ef_construct: ::core::option::Option<u64>,
///
/// Minimal size (in KiloBytes) of vectors for additional payload-based indexing.
/// If the payload chunk is smaller than `full_scan_threshold` additional indexing won't be used -
/// in this case full-scan search should be preferred by query planner and additional indexing is not required.
/// Note: 1 Kb = 1 vector of size 256
#[prost(uint64, optional, tag = "3")]
#[builder(default, setter(strip_option))]
pub full_scan_threshold: ::core::option::Option<u64>,
///
/// Number of parallel threads used for background index building.
/// If 0 - automatically select from 8 to 16.
/// Best to keep between 8 and 16 to prevent likelihood of building broken/inefficient HNSW graphs.
/// On small CPUs, less threads are used.
#[prost(uint64, optional, tag = "4")]
#[builder(default, setter(strip_option))]
pub max_indexing_threads: ::core::option::Option<u64>,
///
/// Store HNSW index on disk. If set to false, the index will be stored in RAM.
#[prost(bool, optional, tag = "5")]
#[builder(default, setter(strip_option))]
pub on_disk: ::core::option::Option<bool>,
///
/// Number of additional payload-aware links per node in the index graph. If not set - regular M parameter will be used.
#[prost(uint64, optional, tag = "6")]
#[builder(default, setter(strip_option))]
pub payload_m: ::core::option::Option<u64>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down Expand Up @@ -7471,4 +7479,5 @@ where

builder_type_conversions!(CreateCollection, CreateCollectionBuilder);
builder_type_conversions!(VectorParams, VectorParamsBuilder);
builder_type_conversions!(HnswConfigDiff, HnswConfigDiffBuilder);

8 changes: 8 additions & 0 deletions tests/protos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ fn configure_builder(builder: Builder) -> Builder {
"CreateCollection.sparse_vectors_config",
DEFAULT_OPTION_INTO,
),
// HnswConfig
("HnswConfigDiff.m", DEFAULT_OPTION),
("HnswConfigDiff.ef_construct", DEFAULT_OPTION),
("HnswConfigDiff.full_scan_threshold", DEFAULT_OPTION),
("HnswConfigDiff.max_indexing_threads", DEFAULT_OPTION),
("HnswConfigDiff.on_disk", DEFAULT_OPTION),
("HnswConfigDiff.payload_m", DEFAULT_OPTION),
],
builder_derive_options(),
)
Expand All @@ -158,6 +165,7 @@ fn builder_derive_options() -> &'static [BuildDeriveOptions] {
&[
("CreateCollection", DEFAULT_BUILDER_DERIVE_OPTIONS, true),
("VectorParams", DEFAULT_BUILDER_DERIVE_OPTIONS, true),
("HnswConfigDiff", DEFAULT_BUILDER_DERIVE_OPTIONS, true),
]
}

Expand Down

0 comments on commit fdbc50f

Please sign in to comment.