From 0088e91181a22ecbee46b6a1bb56a730dae65a3a Mon Sep 17 00:00:00 2001 From: Palash Nigam Date: Tue, 26 Nov 2024 16:45:46 +0530 Subject: [PATCH] Replace macro generated builder types with unrolled ones (#199) * Replace macro generated builder types with unrolled ones Fixes: #195 * fix clippy and implement missing defaults * unexpose builder module and remove comment --------- Co-authored-by: generall --- src/builders/abort_shard_transfer_builder.rs | 141 ++ src/builders/binary_quantization_builder.rs | 97 ++ src/builders/clear_payload_points_builder.rs | 149 ++ .../collection_params_diff_builder.rs | 98 ++ src/builders/context_example_pair_builder.rs | 64 + src/builders/context_input_builder.rs | 57 + src/builders/context_input_pair_builder.rs | 107 ++ src/builders/count_points_builder.rs | 165 ++ src/builders/create_alias_builder.rs | 121 ++ src/builders/create_collection_builder.rs | 269 +++ .../create_field_index_collection_builder.rs | 171 ++ src/builders/create_shard_key_builder.rs | 89 + .../create_shard_key_request_builder.rs | 125 ++ src/builders/datetime_index_params_builder.rs | 68 + src/builders/delete_collection_builder.rs | 114 ++ .../delete_field_index_collection_builder.rs | 145 ++ src/builders/delete_payload_points_builder.rs | 172 ++ src/builders/delete_point_vectors_builder.rs | 165 ++ src/builders/delete_points_builder.rs | 154 ++ .../delete_shard_key_request_builder.rs | 118 ++ .../delete_snapshot_request_builder.rs | 121 ++ src/builders/discover_batch_points_builder.rs | 146 ++ src/builders/discover_input_builder.rs | 107 ++ src/builders/discover_points_builder.rs | 273 +++ src/builders/facet_counts_builder.rs | 193 +++ src/builders/float_index_params_builder.rs | 72 + src/builders/geo_index_params_builder.rs | 61 + src/builders/get_points_builder.rs | 191 +++ src/builders/hnsw_config_diff_builder.rs | 150 ++ src/builders/integer_index_params_builder.rs | 133 ++ src/builders/keyword_index_params_builder.rs | 68 + src/builders/lookup_location_builder.rs | 126 ++ src/builders/mod.rs | 212 +++ src/builders/move_shard_builder.rs | 153 ++ src/builders/multi_vector_config_builder.rs | 96 ++ .../optimizers_config_diff_builder.rs | 210 +++ src/builders/order_by_builder.rs | 119 ++ src/builders/prefetch_query_builder.rs | 134 ++ src/builders/product_quantization_builder.rs | 114 ++ .../quantization_search_params_builder.rs | 97 ++ src/builders/query_batch_points_builder.rs | 143 ++ src/builders/query_point_groups_builder.rs | 298 ++++ src/builders/query_points_builder.rs | 270 +++ .../recommend_batch_points_builder.rs | 145 ++ src/builders/recommend_input_builder.rs | 79 + .../recommend_point_groups_builder.rs | 318 ++++ src/builders/recommend_points_builder.rs | 282 +++ src/builders/rename_alias_builder.rs | 121 ++ src/builders/replica_builder.rs | 110 ++ src/builders/replicate_shard_builder.rs | 145 ++ src/builders/scalar_quantization_builder.rs | 124 ++ src/builders/scroll_points_builder.rs | 212 +++ src/builders/search_batch_points_builder.rs | 144 ++ src/builders/search_matrix_points_builder.rs | 185 ++ src/builders/search_params_builder.rs | 107 ++ src/builders/search_point_groups_builder.rs | 308 ++++ src/builders/search_points_builder.rs | 270 +++ src/builders/set_payload_points_builder.rs | 182 ++ src/builders/sparse_index_config_builder.rs | 87 + src/builders/sparse_vector_params_builder.rs | 68 + src/builders/strict_mode_config_builder.rs | 118 ++ src/builders/text_index_params_builder.rs | 146 ++ src/builders/update_batch_points_builder.rs | 140 ++ src/builders/update_collection_builder.rs | 194 +++ ...ollection_cluster_setup_request_builder.rs | 137 ++ src/builders/update_point_vectors_builder.rs | 156 ++ src/builders/upsert_points_builder.rs | 154 ++ src/builders/uuid_index_params_builder.rs | 68 + src/builders/vector_params_builder.rs | 168 ++ src/builders/vector_params_diff_builder.rs | 85 + src/builders/wal_config_diff_builder.rs | 68 + src/builders/with_lookup_builder.rs | 131 ++ src/lib.rs | 11 +- src/qdrant.rs | 1511 +---------------- src/qdrant_client/builders/mod.rs | 1 - src/qdrant_client/builders/payloads.rs | 15 - src/qdrant_client/collection.rs | 5 +- src/qdrant_client/query.rs | 13 +- tests/protos.rs | 1169 +------------ 79 files changed, 10624 insertions(+), 2629 deletions(-) create mode 100644 src/builders/abort_shard_transfer_builder.rs create mode 100644 src/builders/binary_quantization_builder.rs create mode 100644 src/builders/clear_payload_points_builder.rs create mode 100644 src/builders/collection_params_diff_builder.rs create mode 100644 src/builders/context_example_pair_builder.rs create mode 100644 src/builders/context_input_builder.rs create mode 100644 src/builders/context_input_pair_builder.rs create mode 100644 src/builders/count_points_builder.rs create mode 100644 src/builders/create_alias_builder.rs create mode 100644 src/builders/create_collection_builder.rs create mode 100644 src/builders/create_field_index_collection_builder.rs create mode 100644 src/builders/create_shard_key_builder.rs create mode 100644 src/builders/create_shard_key_request_builder.rs create mode 100644 src/builders/datetime_index_params_builder.rs create mode 100644 src/builders/delete_collection_builder.rs create mode 100644 src/builders/delete_field_index_collection_builder.rs create mode 100644 src/builders/delete_payload_points_builder.rs create mode 100644 src/builders/delete_point_vectors_builder.rs create mode 100644 src/builders/delete_points_builder.rs create mode 100644 src/builders/delete_shard_key_request_builder.rs create mode 100644 src/builders/delete_snapshot_request_builder.rs create mode 100644 src/builders/discover_batch_points_builder.rs create mode 100644 src/builders/discover_input_builder.rs create mode 100644 src/builders/discover_points_builder.rs create mode 100644 src/builders/facet_counts_builder.rs create mode 100644 src/builders/float_index_params_builder.rs create mode 100644 src/builders/geo_index_params_builder.rs create mode 100644 src/builders/get_points_builder.rs create mode 100644 src/builders/hnsw_config_diff_builder.rs create mode 100644 src/builders/integer_index_params_builder.rs create mode 100644 src/builders/keyword_index_params_builder.rs create mode 100644 src/builders/lookup_location_builder.rs create mode 100644 src/builders/mod.rs create mode 100644 src/builders/move_shard_builder.rs create mode 100644 src/builders/multi_vector_config_builder.rs create mode 100644 src/builders/optimizers_config_diff_builder.rs create mode 100644 src/builders/order_by_builder.rs create mode 100644 src/builders/prefetch_query_builder.rs create mode 100644 src/builders/product_quantization_builder.rs create mode 100644 src/builders/quantization_search_params_builder.rs create mode 100644 src/builders/query_batch_points_builder.rs create mode 100644 src/builders/query_point_groups_builder.rs create mode 100644 src/builders/query_points_builder.rs create mode 100644 src/builders/recommend_batch_points_builder.rs create mode 100644 src/builders/recommend_input_builder.rs create mode 100644 src/builders/recommend_point_groups_builder.rs create mode 100644 src/builders/recommend_points_builder.rs create mode 100644 src/builders/rename_alias_builder.rs create mode 100644 src/builders/replica_builder.rs create mode 100644 src/builders/replicate_shard_builder.rs create mode 100644 src/builders/scalar_quantization_builder.rs create mode 100644 src/builders/scroll_points_builder.rs create mode 100644 src/builders/search_batch_points_builder.rs create mode 100644 src/builders/search_matrix_points_builder.rs create mode 100644 src/builders/search_params_builder.rs create mode 100644 src/builders/search_point_groups_builder.rs create mode 100644 src/builders/search_points_builder.rs create mode 100644 src/builders/set_payload_points_builder.rs create mode 100644 src/builders/sparse_index_config_builder.rs create mode 100644 src/builders/sparse_vector_params_builder.rs create mode 100644 src/builders/strict_mode_config_builder.rs create mode 100644 src/builders/text_index_params_builder.rs create mode 100644 src/builders/update_batch_points_builder.rs create mode 100644 src/builders/update_collection_builder.rs create mode 100644 src/builders/update_collection_cluster_setup_request_builder.rs create mode 100644 src/builders/update_point_vectors_builder.rs create mode 100644 src/builders/upsert_points_builder.rs create mode 100644 src/builders/uuid_index_params_builder.rs create mode 100644 src/builders/vector_params_builder.rs create mode 100644 src/builders/vector_params_diff_builder.rs create mode 100644 src/builders/wal_config_diff_builder.rs create mode 100644 src/builders/with_lookup_builder.rs delete mode 100644 src/qdrant_client/builders/payloads.rs diff --git a/src/builders/abort_shard_transfer_builder.rs b/src/builders/abort_shard_transfer_builder.rs new file mode 100644 index 00000000..2ea9e2eb --- /dev/null +++ b/src/builders/abort_shard_transfer_builder.rs @@ -0,0 +1,141 @@ +use crate::qdrant::*; + +pub struct AbortShardTransferBuilder { + /// Local shard id + pub(crate) shard_id: Option, + pub(crate) to_shard_id: Option>, + pub(crate) from_peer_id: Option, + pub(crate) to_peer_id: Option, +} + +impl AbortShardTransferBuilder { + /// Local shard id + #[allow(unused_mut)] + pub fn shard_id(self, value: u32) -> Self { + let mut new = self; + new.shard_id = Option::Some(value); + new + } + #[allow(unused_mut)] + pub fn to_shard_id(self, value: u32) -> Self { + let mut new = self; + new.to_shard_id = Option::Some(Option::Some(value)); + new + } + #[allow(unused_mut)] + pub fn from_peer_id(self, value: u64) -> Self { + let mut new = self; + new.from_peer_id = Option::Some(value); + new + } + #[allow(unused_mut)] + pub fn to_peer_id(self, value: u64) -> Self { + let mut new = self; + new.to_peer_id = Option::Some(value); + new + } + fn build_inner(self) -> Result { + Ok(AbortShardTransfer { + shard_id: match self.shard_id { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("shard_id"), + )); + } + }, + to_shard_id: self.to_shard_id.unwrap_or_default(), + from_peer_id: match self.from_peer_id { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("from_peer_id"), + )); + } + }, + to_peer_id: match self.to_peer_id { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("to_peer_id"), + )); + } + }, + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + shard_id: core::default::Default::default(), + to_shard_id: core::default::Default::default(), + from_peer_id: core::default::Default::default(), + to_peer_id: core::default::Default::default(), + } + } +} + +impl From for AbortShardTransfer { + fn from(value: AbortShardTransferBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "AbortShardTransferBuilder", "AbortShardTransfer" + ) + }) + } +} + +impl AbortShardTransferBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> AbortShardTransfer { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "AbortShardTransferBuilder", "AbortShardTransfer" + ) + }) + } +} + +impl AbortShardTransferBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +// src/builders/abort_shard_transfer_builder.rs + +#[non_exhaustive] +#[derive(Debug)] +pub enum AbortShardTransferBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for AbortShardTransferBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +impl std::error::Error for AbortShardTransferBuilderError {} + +impl From for AbortShardTransferBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +impl From for AbortShardTransferBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/binary_quantization_builder.rs b/src/builders/binary_quantization_builder.rs new file mode 100644 index 00000000..90d061f2 --- /dev/null +++ b/src/builders/binary_quantization_builder.rs @@ -0,0 +1,97 @@ +use crate::qdrant::*; + +pub struct BinaryQuantizationBuilder { + /// If true - quantized vectors always will be stored in RAM, ignoring the config of main storage + pub(crate) always_ram: Option>, +} + +impl BinaryQuantizationBuilder { + /// If true - quantized vectors always will be stored in RAM, ignoring the config of main storage + #[allow(unused_mut)] + pub fn always_ram(self, value: bool) -> Self { + let mut new = self; + new.always_ram = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(BinaryQuantization { + always_ram: self.always_ram.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + always_ram: core::default::Default::default(), + } + } +} + +impl From for BinaryQuantization { + fn from(value: BinaryQuantizationBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "BinaryQuantizationBuilder", "BinaryQuantization" + ) + }) + } +} + +impl BinaryQuantizationBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> BinaryQuantization { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "BinaryQuantizationBuilder", "BinaryQuantization" + ) + }) + } +} + +impl BinaryQuantizationBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +// src/builders/binary_quantization_builder.rs + +#[non_exhaustive] +#[derive(Debug)] +pub enum BinaryQuantizationBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for BinaryQuantizationBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for BinaryQuantizationBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for BinaryQuantizationBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for BinaryQuantizationBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/clear_payload_points_builder.rs b/src/builders/clear_payload_points_builder.rs new file mode 100644 index 00000000..f2fb2222 --- /dev/null +++ b/src/builders/clear_payload_points_builder.rs @@ -0,0 +1,149 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct ClearPayloadPointsBuilder { + /// name of the collection + pub(crate) collection_name: Option, + /// Wait until the changes have been applied? + pub(crate) wait: Option>, + /// Affected points + points: Option, + /// Write ordering guarantees + pub(crate) ordering: Option>, + /// Option for custom sharding to specify used shard keys + pub(crate) shard_key_selector: Option>, +} + +impl ClearPayloadPointsBuilder { + /// name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Wait until the changes have been applied? + #[allow(unused_mut)] + pub fn wait(self, value: bool) -> Self { + let mut new = self; + new.wait = Option::Some(Option::Some(value)); + new + } + /// Affected points + #[allow(unused_mut)] + pub fn points>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.points = Option::Some(value.into()); + new + } + /// Write ordering guarantees + #[allow(unused_mut)] + pub fn ordering>(self, value: VALUE) -> Self { + let mut new = self; + new.ordering = Option::Some(Option::Some(value.into())); + new + } + /// Option for custom sharding to specify used shard keys + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(ClearPayloadPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + wait: self.wait.unwrap_or_default(), + points: { convert_option(&self.points) }, + ordering: self.ordering.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + wait: core::default::Default::default(), + points: core::default::Default::default(), + ordering: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + } + } +} + +impl From for ClearPayloadPoints { + fn from(value: ClearPayloadPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "ClearPayloadPointsBuilder", "ClearPayloadPoints" + ) + }) + } +} + +impl ClearPayloadPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> ClearPayloadPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "ClearPayloadPointsBuilder", "ClearPayloadPoints" + ) + }) + } +} + +impl ClearPayloadPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} +/// Error type for ClearPayloadPointsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum ClearPayloadPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +impl std::fmt::Display for ClearPayloadPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +impl std::error::Error for ClearPayloadPointsBuilderError {} + +impl From for ClearPayloadPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +impl From for ClearPayloadPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/collection_params_diff_builder.rs b/src/builders/collection_params_diff_builder.rs new file mode 100644 index 00000000..cae90615 --- /dev/null +++ b/src/builders/collection_params_diff_builder.rs @@ -0,0 +1,98 @@ +use crate::qdrant::*; + +pub struct CollectionParamsDiffBuilder { + /// Number of replicas of each shard that network tries to maintain + pub(crate) replication_factor: Option>, + /// How many replicas should apply the operation for us to consider it successful + pub(crate) write_consistency_factor: Option>, + /// If true - point's payload will not be stored in memory + pub(crate) on_disk_payload: Option>, + /// Fan-out every read request to these many additional remote nodes (and return first available response) + pub(crate) read_fan_out_factor: Option>, +} +#[allow(clippy::all)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[allow(dead_code)] +impl CollectionParamsDiffBuilder { + /// Number of replicas of each shard that network tries to maintain + #[allow(unused_mut)] + pub fn replication_factor(self, value: u32) -> Self { + let mut new = self; + new.replication_factor = Option::Some(Option::Some(value)); + new + } + /// How many replicas should apply the operation for us to consider it successful + #[allow(unused_mut)] + pub fn write_consistency_factor(self, value: u32) -> Self { + let mut new = self; + new.write_consistency_factor = Option::Some(Option::Some(value)); + new + } + /// If true - point's payload will not be stored in memory + #[allow(unused_mut)] + pub fn on_disk_payload(self, value: bool) -> Self { + let mut new = self; + new.on_disk_payload = Option::Some(Option::Some(value)); + new + } + /// Fan-out every read request to these many additional remote nodes (and return first available response) + #[allow(unused_mut)] + pub fn read_fan_out_factor(self, value: u32) -> Self { + let mut new = self; + new.read_fan_out_factor = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(CollectionParamsDiff { + replication_factor: match self.replication_factor { + Some(value) => value, + None => core::default::Default::default(), + }, + write_consistency_factor: match self.write_consistency_factor { + Some(value) => value, + None => core::default::Default::default(), + }, + on_disk_payload: match self.on_disk_payload { + Some(value) => value, + None => core::default::Default::default(), + }, + read_fan_out_factor: match self.read_fan_out_factor { + Some(value) => value, + None => core::default::Default::default(), + }, + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + replication_factor: core::default::Default::default(), + write_consistency_factor: core::default::Default::default(), + on_disk_payload: core::default::Default::default(), + read_fan_out_factor: core::default::Default::default(), + } + } +} + +impl From for CollectionParamsDiff { + fn from(value: CollectionParamsDiffBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "CollectionParamsDiffBuilder", "CollectionParamsDiff" + ) + }) + } +} + +impl CollectionParamsDiffBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> CollectionParamsDiff { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "CollectionParamsDiffBuilder", "CollectionParamsDiff" + ) + }) + } +} diff --git a/src/builders/context_example_pair_builder.rs b/src/builders/context_example_pair_builder.rs new file mode 100644 index 00000000..b58ad962 --- /dev/null +++ b/src/builders/context_example_pair_builder.rs @@ -0,0 +1,64 @@ +use crate::qdrant::*; + +pub struct ContextExamplePairBuilder { + pub(crate) positive: Option>, + pub(crate) negative: Option>, +} + +impl ContextExamplePairBuilder { + #[allow(unused_mut)] + pub fn positive>(self, value: VALUE) -> Self { + let mut new = self; + new.positive = Option::Some(Option::Some(value.into())); + new + } + #[allow(unused_mut)] + pub fn negative>(self, value: VALUE) -> Self { + let mut new = self; + new.negative = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(ContextExamplePair { + positive: self.positive.unwrap_or_default(), + negative: self.negative.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + positive: core::default::Default::default(), + negative: core::default::Default::default(), + } + } +} + +impl From for ContextExamplePair { + fn from(value: ContextExamplePairBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "ContextExamplePairBuilder", "ContextExamplePair" + ) + }) + } +} + +impl ContextExamplePairBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> ContextExamplePair { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "ContextExamplePairBuilder", "ContextExamplePair" + ) + }) + } +} + +impl Default for ContextExamplePairBuilder { + fn default() -> Self { + Self::create_empty() + } +} diff --git a/src/builders/context_input_builder.rs b/src/builders/context_input_builder.rs new file mode 100644 index 00000000..1952acc2 --- /dev/null +++ b/src/builders/context_input_builder.rs @@ -0,0 +1,57 @@ +use crate::qdrant::*; + +pub struct ContextInputBuilder { + /// Search space will be constrained by these pairs of vectors + pub(crate) pairs: Option>, +} + +impl ContextInputBuilder { + /// Search space will be constrained by these pairs of vectors + #[allow(unused_mut)] + pub fn pairs>>(self, value: VALUE) -> Self { + let mut new = self; + new.pairs = Option::Some(value.into()); + new + } + + fn build_inner(self) -> Result { + Ok(ContextInput { + pairs: self.pairs.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + pairs: core::default::Default::default(), + } + } +} + +impl From for ContextInput { + fn from(value: ContextInputBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "ContextInputBuilder", "ContextInput" + ) + }) + } +} + +impl ContextInputBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> ContextInput { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "ContextInputBuilder", "ContextInput" + ) + }) + } +} + +impl Default for ContextInputBuilder { + fn default() -> Self { + Self::create_empty() + } +} diff --git a/src/builders/context_input_pair_builder.rs b/src/builders/context_input_pair_builder.rs new file mode 100644 index 00000000..78b01331 --- /dev/null +++ b/src/builders/context_input_pair_builder.rs @@ -0,0 +1,107 @@ +use crate::qdrant::*; + +pub struct ContextInputPairBuilder { + /// A positive vector + pub(crate) positive: Option>, + /// Repel from this vector + pub(crate) negative: Option>, +} + +impl ContextInputPairBuilder { + /// A positive vector + #[allow(unused_mut)] + pub fn positive>(self, value: VALUE) -> Self { + let mut new = self; + new.positive = Option::Some(Option::Some(value.into())); + new + } + /// Repel from this vector + #[allow(unused_mut)] + pub fn negative>(self, value: VALUE) -> Self { + let mut new = self; + new.negative = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(ContextInputPair { + positive: self.positive.unwrap_or_default(), + negative: self.negative.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + positive: core::default::Default::default(), + negative: core::default::Default::default(), + } + } +} + +impl From for ContextInputPair { + fn from(value: ContextInputPairBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "ContextInputPairBuilder", "ContextInputPair" + ) + }) + } +} + +impl ContextInputPairBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> ContextInputPair { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "ContextInputPairBuilder", "ContextInputPair" + ) + }) + } +} + +impl ContextInputPairBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for ContextInputPairBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum ContextInputPairBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for ContextInputPairBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for ContextInputPairBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for ContextInputPairBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for ContextInputPairBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/count_points_builder.rs b/src/builders/count_points_builder.rs new file mode 100644 index 00000000..cef0296a --- /dev/null +++ b/src/builders/count_points_builder.rs @@ -0,0 +1,165 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct CountPointsBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// Filter conditions - return only those points that satisfy the specified conditions + pub(crate) filter: Option>, + /// If `true` - return exact count, if `false` - return approximate count + pub(crate) exact: Option>, + /// Options for specifying read consistency guarantees + read_consistency: Option, + /// Specify in which shards to look for the points, if not specified - look in all shards + pub(crate) shard_key_selector: Option>, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, +} + +impl CountPointsBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Filter conditions - return only those points that satisfy the specified conditions + #[allow(unused_mut)] + pub fn filter>(self, value: VALUE) -> Self { + let mut new = self; + new.filter = Option::Some(Option::Some(value.into())); + new + } + /// If `true` - return exact count, if `false` - return approximate count + #[allow(unused_mut)] + pub fn exact(self, value: bool) -> Self { + let mut new = self; + new.exact = Option::Some(Option::Some(value)); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(value.into()); + new + } + /// Specify in which shards to look for the points, if not specified - look in all shards + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(CountPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + filter: self.filter.unwrap_or_default(), + exact: self.exact.unwrap_or_default(), + read_consistency: { convert_option(&self.read_consistency) }, + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + timeout: self.timeout.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + filter: core::default::Default::default(), + exact: core::default::Default::default(), + read_consistency: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + timeout: core::default::Default::default(), + } + } +} + +impl From for CountPoints { + fn from(value: CountPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "CountPointsBuilder", "CountPoints" + ) + }) + } +} + +impl CountPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> CountPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "CountPointsBuilder", "CountPoints" + ) + }) + } +} + +impl CountPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for CountPointsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum CountPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for CountPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for CountPointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for CountPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for CountPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/create_alias_builder.rs b/src/builders/create_alias_builder.rs new file mode 100644 index 00000000..12d0b78c --- /dev/null +++ b/src/builders/create_alias_builder.rs @@ -0,0 +1,121 @@ +use crate::qdrant::*; + +pub struct CreateAliasBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// New name of the alias + pub(crate) alias_name: Option, +} + +impl CreateAliasBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// New name of the alias + #[allow(unused_mut)] + pub fn alias_name(self, value: String) -> Self { + let mut new = self; + new.alias_name = Option::Some(value); + new + } + + fn build_inner(self) -> Result { + Ok(CreateAlias { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + alias_name: match self.alias_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("alias_name"), + )); + } + }, + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + alias_name: core::default::Default::default(), + } + } +} + +impl From for CreateAlias { + fn from(value: CreateAliasBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "CreateAliasBuilder", "CreateAlias" + ) + }) + } +} + +impl CreateAliasBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> CreateAlias { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "CreateAliasBuilder", "CreateAlias" + ) + }) + } +} + +impl CreateAliasBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for CreateAliasBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum CreateAliasBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for CreateAliasBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for CreateAliasBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for CreateAliasBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for CreateAliasBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/create_collection_builder.rs b/src/builders/create_collection_builder.rs new file mode 100644 index 00000000..732ac17d --- /dev/null +++ b/src/builders/create_collection_builder.rs @@ -0,0 +1,269 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +#[derive(Debug)] +pub struct CreateCollectionBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// Configuration of vector index + pub(crate) hnsw_config: Option>, + /// Configuration of the Write-Ahead-Log + pub(crate) wal_config: Option>, + /// Configuration of the optimizers + pub(crate) optimizers_config: Option>, + /// Number of shards in the collection, default is 1 for standalone, otherwise equal to the number of nodes. Minimum is 1 + pub(crate) shard_number: Option>, + /// If true - point's payload will not be stored in memory + pub(crate) on_disk_payload: Option>, + /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied + pub(crate) timeout: Option>, + /// Configuration for vectors + pub(crate) vectors_config: Option>, + /// Number of replicas of each shard that network tries to maintain, default = 1 + pub(crate) replication_factor: Option>, + /// How many replicas should apply the operation for us to consider it successful, default = 1 + pub(crate) write_consistency_factor: Option>, + /// Specify name of the other collection to copy data from + pub(crate) init_from_collection: Option>, + /// Quantization configuration of vector + quantization_config: Option, + /// Sharding method + pub(crate) sharding_method: Option>, + /// Configuration for sparse vectors + pub(crate) sparse_vectors_config: Option>, + /// Configuration for strict mode + pub(crate) strict_mode_config: Option>, +} +#[allow(clippy::all)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[allow(dead_code)] +impl CreateCollectionBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name>(self, value: VALUE) -> Self { + let mut new = self; + new.collection_name = Option::Some(value.into()); + new + } + /// Configuration of vector index + #[allow(unused_mut)] + pub fn hnsw_config>(self, value: VALUE) -> Self { + let mut new = self; + new.hnsw_config = Option::Some(Option::Some(value.into())); + new + } + /// Configuration of the Write-Ahead-Log + #[allow(unused_mut)] + pub fn wal_config>(self, value: VALUE) -> Self { + let mut new = self; + new.wal_config = Option::Some(Option::Some(value.into())); + new + } + /// Configuration of the optimizers + #[allow(unused_mut)] + pub fn optimizers_config>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.optimizers_config = Option::Some(Option::Some(value.into())); + new + } + /// Number of shards in the collection, default is 1 for standalone, otherwise equal to the number of nodes. Minimum is 1 + #[allow(unused_mut)] + pub fn shard_number(self, value: u32) -> Self { + let mut new = self; + new.shard_number = Option::Some(Option::Some(value)); + new + } + /// If true - point's payload will not be stored in memory + #[allow(unused_mut)] + pub fn on_disk_payload(self, value: bool) -> Self { + let mut new = self; + new.on_disk_payload = Option::Some(Option::Some(value)); + new + } + /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + /// Configuration for vectors + #[allow(unused_mut)] + pub fn vectors_config>(self, value: VALUE) -> Self { + let mut new = self; + new.vectors_config = Option::Some(Option::Some(value.into())); + new + } + /// Number of replicas of each shard that network tries to maintain, default = 1 + #[allow(unused_mut)] + pub fn replication_factor(self, value: u32) -> Self { + let mut new = self; + new.replication_factor = Option::Some(Option::Some(value)); + new + } + /// How many replicas should apply the operation for us to consider it successful, default = 1 + #[allow(unused_mut)] + pub fn write_consistency_factor(self, value: u32) -> Self { + let mut new = self; + new.write_consistency_factor = Option::Some(Option::Some(value)); + new + } + /// Specify name of the other collection to copy data from + #[allow(unused_mut)] + pub fn init_from_collection>(self, value: VALUE) -> Self { + let mut new = self; + new.init_from_collection = Option::Some(Option::Some(value.into())); + new + } + /// Quantization configuration of vector + #[allow(unused_mut)] + pub fn quantization_config>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.quantization_config = Option::Some(value.into()); + new + } + /// Sharding method + #[allow(unused_mut)] + pub fn sharding_method(self, value: i32) -> Self { + let mut new = self; + new.sharding_method = Option::Some(Option::Some(value)); + new + } + /// Configuration for sparse vectors + #[allow(unused_mut)] + pub fn sparse_vectors_config>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.sparse_vectors_config = Option::Some(Option::Some(value.into())); + new + } + /// Configuration for strict mode + #[allow(unused_mut)] + pub fn strict_mode_config>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.strict_mode_config = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(CreateCollection { + collection_name: match self.collection_name { + Some(value) => value, + None => core::default::Default::default(), + }, + hnsw_config: match self.hnsw_config { + Some(value) => value, + None => core::default::Default::default(), + }, + wal_config: match self.wal_config { + Some(value) => value, + None => core::default::Default::default(), + }, + optimizers_config: match self.optimizers_config { + Some(value) => value, + None => core::default::Default::default(), + }, + shard_number: match self.shard_number { + Some(value) => value, + None => core::default::Default::default(), + }, + on_disk_payload: match self.on_disk_payload { + Some(value) => value, + None => core::default::Default::default(), + }, + timeout: match self.timeout { + Some(value) => value, + None => core::default::Default::default(), + }, + vectors_config: match self.vectors_config { + Some(value) => value, + None => core::default::Default::default(), + }, + replication_factor: match self.replication_factor { + Some(value) => value, + None => core::default::Default::default(), + }, + write_consistency_factor: match self.write_consistency_factor { + Some(value) => value, + None => core::default::Default::default(), + }, + init_from_collection: match self.init_from_collection { + Some(value) => value, + None => core::default::Default::default(), + }, + quantization_config: { convert_option(&self.quantization_config) }, + sharding_method: match self.sharding_method { + Some(value) => value, + None => core::default::Default::default(), + }, + sparse_vectors_config: match self.sparse_vectors_config { + Some(value) => value, + None => core::default::Default::default(), + }, + strict_mode_config: match self.strict_mode_config { + Some(value) => value, + None => core::default::Default::default(), + }, + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + hnsw_config: core::default::Default::default(), + wal_config: core::default::Default::default(), + optimizers_config: core::default::Default::default(), + shard_number: core::default::Default::default(), + on_disk_payload: core::default::Default::default(), + timeout: core::default::Default::default(), + vectors_config: core::default::Default::default(), + replication_factor: core::default::Default::default(), + write_consistency_factor: core::default::Default::default(), + init_from_collection: core::default::Default::default(), + quantization_config: core::default::Default::default(), + sharding_method: core::default::Default::default(), + sparse_vectors_config: core::default::Default::default(), + strict_mode_config: core::default::Default::default(), + } + } +} + +impl From for CreateCollection { + fn from(value: CreateCollectionBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "CreateCollectionBuilder", "CreateCollection" + ) + }) + } +} + +impl CreateCollectionBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> CreateCollection { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "CreateCollectionBuilder", "CreateCollection" + ) + }) + } +} + +impl Default for CreateCollectionBuilder { + fn default() -> Self { + Self::create_empty() + } +} diff --git a/src/builders/create_field_index_collection_builder.rs b/src/builders/create_field_index_collection_builder.rs new file mode 100644 index 00000000..5dc3efca --- /dev/null +++ b/src/builders/create_field_index_collection_builder.rs @@ -0,0 +1,171 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct CreateFieldIndexCollectionBuilder { + /// name of the collection + pub(crate) collection_name: Option, + /// Wait until the changes have been applied? + pub(crate) wait: Option>, + /// Field name to index + pub(crate) field_name: Option, + /// Field type. + pub(crate) field_type: Option>, + /// Payload index params. + field_index_params: Option, + /// Write ordering guarantees + pub(crate) ordering: Option>, +} + +impl CreateFieldIndexCollectionBuilder { + /// name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Wait until the changes have been applied? + #[allow(unused_mut)] + pub fn wait(self, value: bool) -> Self { + let mut new = self; + new.wait = Option::Some(Option::Some(value)); + new + } + /// Field name to index + #[allow(unused_mut)] + pub fn field_name(self, value: String) -> Self { + let mut new = self; + new.field_name = Option::Some(value); + new + } + /// Field type. + #[allow(unused_mut)] + pub fn field_type>(self, value: VALUE) -> Self { + let mut new = self; + new.field_type = Option::Some(Option::Some(value.into())); + new + } + /// Payload index params. + #[allow(unused_mut)] + pub fn field_index_params>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.field_index_params = Option::Some(value.into()); + new + } + /// Write ordering guarantees + #[allow(unused_mut)] + pub fn ordering>(self, value: VALUE) -> Self { + let mut new = self; + new.ordering = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner( + self, + ) -> Result { + Ok(CreateFieldIndexCollection { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + wait: self.wait.unwrap_or_default(), + field_name: match self.field_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("field_name"), + )); + } + }, + field_type: self.field_type.unwrap_or_default(), + field_index_params: { convert_option(&self.field_index_params) }, + ordering: self.ordering.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + wait: core::default::Default::default(), + field_name: core::default::Default::default(), + field_type: core::default::Default::default(), + field_index_params: core::default::Default::default(), + ordering: core::default::Default::default(), + } + } +} + +impl From for CreateFieldIndexCollection { + fn from(value: CreateFieldIndexCollectionBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "CreateFieldIndexCollectionBuilder", "CreateFieldIndexCollection" + ) + }) + } +} + +impl CreateFieldIndexCollectionBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> CreateFieldIndexCollection { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "CreateFieldIndexCollectionBuilder", "CreateFieldIndexCollection" + ) + }) + } +} + +impl CreateFieldIndexCollectionBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for CreateFieldIndexCollectionBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum CreateFieldIndexCollectionBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for CreateFieldIndexCollectionBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for CreateFieldIndexCollectionBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for CreateFieldIndexCollectionBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for CreateFieldIndexCollectionBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/create_shard_key_builder.rs b/src/builders/create_shard_key_builder.rs new file mode 100644 index 00000000..f448223d --- /dev/null +++ b/src/builders/create_shard_key_builder.rs @@ -0,0 +1,89 @@ +use crate::qdrant::*; + +pub struct CreateShardKeyBuilder { + /// User-defined shard key + pub(crate) shard_key: Option>, + /// Number of shards to create per shard key + pub(crate) shards_number: Option>, + /// Number of replicas of each shard to create + pub(crate) replication_factor: Option>, + /// List of peer ids, allowed to create shards. If empty - all peers are allowed + pub(crate) placement: Option>, +} + +impl CreateShardKeyBuilder { + /// User-defined shard key + #[allow(unused_mut)] + pub fn shard_key>(self, value: VALUE) -> Self { + let mut new = self; + new.shard_key = Option::Some(Option::Some(value.into())); + new + } + /// Number of shards to create per shard key + #[allow(unused_mut)] + pub fn shards_number(self, value: u32) -> Self { + let mut new = self; + new.shards_number = Option::Some(Option::Some(value)); + new + } + /// Number of replicas of each shard to create + #[allow(unused_mut)] + pub fn replication_factor(self, value: u32) -> Self { + let mut new = self; + new.replication_factor = Option::Some(Option::Some(value)); + new + } + /// List of peer ids, allowed to create shards. If empty - all peers are allowed + #[allow(unused_mut)] + pub fn placement(self, value: Vec) -> Self { + let mut new = self; + new.placement = Option::Some(value); + new + } + fn build_inner(self) -> Result { + Ok(CreateShardKey { + shard_key: self.shard_key.unwrap_or_default(), + shards_number: self.shards_number.unwrap_or_default(), + replication_factor: self.replication_factor.unwrap_or_default(), + placement: self.placement.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + shard_key: core::default::Default::default(), + shards_number: core::default::Default::default(), + replication_factor: core::default::Default::default(), + placement: core::default::Default::default(), + } + } +} + +impl From for CreateShardKey { + fn from(value: CreateShardKeyBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "CreateShardKeyBuilder", "CreateShardKey" + ) + }) + } +} + +impl CreateShardKeyBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> CreateShardKey { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "CreateShardKeyBuilder", "CreateShardKey" + ) + }) + } +} + +impl Default for CreateShardKeyBuilder { + fn default() -> Self { + Self::create_empty() + } +} diff --git a/src/builders/create_shard_key_request_builder.rs b/src/builders/create_shard_key_request_builder.rs new file mode 100644 index 00000000..84a3a378 --- /dev/null +++ b/src/builders/create_shard_key_request_builder.rs @@ -0,0 +1,125 @@ +use crate::qdrant::*; + +pub struct CreateShardKeyRequestBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// Request to create shard key + pub(crate) request: Option>, + /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied + pub(crate) timeout: Option>, +} + +impl CreateShardKeyRequestBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Request to create shard key + #[allow(unused_mut)] + pub fn request>(self, value: VALUE) -> Self { + let mut new = self; + new.request = Option::Some(Option::Some(value.into())); + new + } + /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(CreateShardKeyRequest { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + request: self.request.unwrap_or_default(), + timeout: self.timeout.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + request: core::default::Default::default(), + timeout: core::default::Default::default(), + } + } +} + +impl From for CreateShardKeyRequest { + fn from(value: CreateShardKeyRequestBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "CreateShardKeyRequestBuilder", "CreateShardKeyRequest" + ) + }) + } +} + +impl CreateShardKeyRequestBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> CreateShardKeyRequest { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "CreateShardKeyRequestBuilder", "CreateShardKeyRequest" + ) + }) + } +} + +impl CreateShardKeyRequestBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for CreateShardKeyRequestBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum CreateShardKeyRequestBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for CreateShardKeyRequestBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for CreateShardKeyRequestBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for CreateShardKeyRequestBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for CreateShardKeyRequestBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/datetime_index_params_builder.rs b/src/builders/datetime_index_params_builder.rs new file mode 100644 index 00000000..40d48992 --- /dev/null +++ b/src/builders/datetime_index_params_builder.rs @@ -0,0 +1,68 @@ +use crate::qdrant::*; + +pub struct DatetimeIndexParamsBuilder { + /// If true - store index on disk. + pub(crate) on_disk: Option>, + /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. + pub(crate) is_principal: Option>, +} + +impl DatetimeIndexParamsBuilder { + /// If true - store index on disk. + #[allow(unused_mut)] + pub fn on_disk(self, value: bool) -> Self { + let mut new = self; + new.on_disk = Option::Some(Option::Some(value)); + new + } + /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. + #[allow(unused_mut)] + pub fn is_principal(self, value: bool) -> Self { + let mut new = self; + new.is_principal = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(DatetimeIndexParams { + on_disk: self.on_disk.unwrap_or_default(), + is_principal: self.is_principal.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + on_disk: core::default::Default::default(), + is_principal: core::default::Default::default(), + } + } +} + +impl Default for DatetimeIndexParamsBuilder { + fn default() -> Self { + Self::create_empty() + } +} + +impl From for DatetimeIndexParams { + fn from(value: DatetimeIndexParamsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "DatetimeIndexParamsBuilder", "DatetimeIndexParams" + ) + }) + } +} + +impl DatetimeIndexParamsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> DatetimeIndexParams { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "DatetimeIndexParamsBuilder", "DatetimeIndexParams" + ) + }) + } +} diff --git a/src/builders/delete_collection_builder.rs b/src/builders/delete_collection_builder.rs new file mode 100644 index 00000000..053ca356 --- /dev/null +++ b/src/builders/delete_collection_builder.rs @@ -0,0 +1,114 @@ +use crate::qdrant::*; + +pub struct DeleteCollectionBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied + pub(crate) timeout: Option>, +} + +impl DeleteCollectionBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(DeleteCollection { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + timeout: self.timeout.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + timeout: core::default::Default::default(), + } + } +} + +impl From for DeleteCollection { + fn from(value: DeleteCollectionBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "DeleteCollectionBuilder", "DeleteCollection" + ) + }) + } +} + +impl DeleteCollectionBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> DeleteCollection { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "DeleteCollectionBuilder", "DeleteCollection" + ) + }) + } +} + +impl DeleteCollectionBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for DeleteCollectionBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum DeleteCollectionBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for DeleteCollectionBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for DeleteCollectionBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for DeleteCollectionBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for DeleteCollectionBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/delete_field_index_collection_builder.rs b/src/builders/delete_field_index_collection_builder.rs new file mode 100644 index 00000000..9add16ee --- /dev/null +++ b/src/builders/delete_field_index_collection_builder.rs @@ -0,0 +1,145 @@ +use crate::qdrant::*; + +pub struct DeleteFieldIndexCollectionBuilder { + /// name of the collection + pub(crate) collection_name: Option, + /// Wait until the changes have been applied? + pub(crate) wait: Option>, + /// Field name to delete + pub(crate) field_name: Option, + /// Write ordering guarantees + pub(crate) ordering: Option>, +} + +impl DeleteFieldIndexCollectionBuilder { + /// name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Wait until the changes have been applied? + #[allow(unused_mut)] + pub fn wait(self, value: bool) -> Self { + let mut new = self; + new.wait = Option::Some(Option::Some(value)); + new + } + /// Field name to delete + #[allow(unused_mut)] + pub fn field_name(self, value: String) -> Self { + let mut new = self; + new.field_name = Option::Some(value); + new + } + /// Write ordering guarantees + #[allow(unused_mut)] + pub fn ordering(self, value: WriteOrdering) -> Self { + let mut new = self; + new.ordering = Option::Some(Option::Some(value)); + new + } + + fn build_inner( + self, + ) -> Result { + Ok(DeleteFieldIndexCollection { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + wait: self.wait.unwrap_or_default(), + field_name: match self.field_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("field_name"), + )); + } + }, + ordering: self.ordering.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + wait: core::default::Default::default(), + field_name: core::default::Default::default(), + ordering: core::default::Default::default(), + } + } +} + +impl From for DeleteFieldIndexCollection { + fn from(value: DeleteFieldIndexCollectionBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "DeleteFieldIndexCollectionBuilder", "DeleteFieldIndexCollection" + ) + }) + } +} + +impl DeleteFieldIndexCollectionBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> DeleteFieldIndexCollection { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "DeleteFieldIndexCollectionBuilder", "DeleteFieldIndexCollection" + ) + }) + } +} + +impl DeleteFieldIndexCollectionBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for DeleteFieldIndexCollectionBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum DeleteFieldIndexCollectionBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for DeleteFieldIndexCollectionBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for DeleteFieldIndexCollectionBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for DeleteFieldIndexCollectionBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for DeleteFieldIndexCollectionBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/delete_payload_points_builder.rs b/src/builders/delete_payload_points_builder.rs new file mode 100644 index 00000000..52301e3c --- /dev/null +++ b/src/builders/delete_payload_points_builder.rs @@ -0,0 +1,172 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct DeletePayloadPointsBuilder { + /// name of the collection + pub(crate) collection_name: Option, + /// Wait until the changes have been applied? + pub(crate) wait: Option>, + /// List of keys to delete + pub(crate) keys: Option>, + /// Affected points + points_selector: Option, + /// Write ordering guarantees + pub(crate) ordering: Option>, + /// Option for custom sharding to specify used shard keys + pub(crate) shard_key_selector: Option>, +} + +impl DeletePayloadPointsBuilder { + /// name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Wait until the changes have been applied? + #[allow(unused_mut)] + pub fn wait(self, value: bool) -> Self { + let mut new = self; + new.wait = Option::Some(Option::Some(value)); + new + } + /// List of keys to delete + #[allow(unused_mut)] + pub fn keys(self, value: Vec) -> Self { + let mut new = self; + new.keys = Option::Some(value); + new + } + /// Affected points + #[allow(unused_mut)] + pub fn points_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.points_selector = Option::Some(value.into()); + new + } + /// Write ordering guarantees + #[allow(unused_mut)] + pub fn ordering>(self, value: VALUE) -> Self { + let mut new = self; + new.ordering = Option::Some(Option::Some(value.into())); + new + } + /// Option for custom sharding to specify used shard keys + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(DeletePayloadPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + wait: self.wait.unwrap_or_default(), + keys: match self.keys { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("keys"), + )); + } + }, + points_selector: { convert_option(&self.points_selector) }, + ordering: self.ordering.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + wait: core::default::Default::default(), + keys: core::default::Default::default(), + points_selector: core::default::Default::default(), + ordering: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + } + } +} + +impl From for DeletePayloadPoints { + fn from(value: DeletePayloadPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "DeletePayloadPointsBuilder", "DeletePayloadPoints" + ) + }) + } +} + +impl DeletePayloadPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> DeletePayloadPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "DeletePayloadPointsBuilder", "DeletePayloadPoints" + ) + }) + } +} + +impl DeletePayloadPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for DeletePayloadPointsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum DeletePayloadPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for DeletePayloadPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for DeletePayloadPointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for DeletePayloadPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for DeletePayloadPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/delete_point_vectors_builder.rs b/src/builders/delete_point_vectors_builder.rs new file mode 100644 index 00000000..43405b15 --- /dev/null +++ b/src/builders/delete_point_vectors_builder.rs @@ -0,0 +1,165 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct DeletePointVectorsBuilder { + /// name of the collection + pub(crate) collection_name: Option, + /// Wait until the changes have been applied? + pub(crate) wait: Option>, + /// Affected points + points_selector: Option, + /// List of vector names to delete + pub(crate) vectors: Option>, + /// Write ordering guarantees + pub(crate) ordering: Option>, + /// Option for custom sharding to specify used shard keys + pub(crate) shard_key_selector: Option>, +} + +impl DeletePointVectorsBuilder { + /// name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Wait until the changes have been applied? + #[allow(unused_mut)] + pub fn wait(self, value: bool) -> Self { + let mut new = self; + new.wait = Option::Some(Option::Some(value)); + new + } + /// Affected points + #[allow(unused_mut)] + pub fn points_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.points_selector = Option::Some(value.into()); + new + } + /// List of vector names to delete + #[allow(unused_mut)] + pub fn vectors>(self, value: VALUE) -> Self { + let mut new = self; + new.vectors = Option::Some(Option::Some(value.into())); + new + } + /// Write ordering guarantees + #[allow(unused_mut)] + pub fn ordering>(self, value: VALUE) -> Self { + let mut new = self; + new.ordering = Option::Some(Option::Some(value.into())); + new + } + /// Option for custom sharding to specify used shard keys + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(DeletePointVectors { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + wait: self.wait.unwrap_or_default(), + points_selector: { convert_option(&self.points_selector) }, + vectors: self.vectors.unwrap_or_default(), + ordering: self.ordering.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + wait: core::default::Default::default(), + points_selector: core::default::Default::default(), + vectors: core::default::Default::default(), + ordering: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + } + } +} + +impl From for DeletePointVectors { + fn from(value: DeletePointVectorsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "DeletePointVectorsBuilder", "DeletePointVectors" + ) + }) + } +} + +impl DeletePointVectorsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> DeletePointVectors { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "DeletePointVectorsBuilder", "DeletePointVectors" + ) + }) + } +} + +impl DeletePointVectorsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for DeletePointVectorsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum DeletePointVectorsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for DeletePointVectorsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for DeletePointVectorsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for DeletePointVectorsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for DeletePointVectorsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/delete_points_builder.rs b/src/builders/delete_points_builder.rs new file mode 100644 index 00000000..89cad477 --- /dev/null +++ b/src/builders/delete_points_builder.rs @@ -0,0 +1,154 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct DeletePointsBuilder { + /// name of the collection + pub(crate) collection_name: Option, + /// Wait until the changes have been applied? + pub(crate) wait: Option>, + /// Affected points + points: Option, + /// Write ordering guarantees + pub(crate) ordering: Option>, + /// Option for custom sharding to specify used shard keys + pub(crate) shard_key_selector: Option>, +} + +impl DeletePointsBuilder { + /// name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Wait until the changes have been applied? + #[allow(unused_mut)] + pub fn wait(self, value: bool) -> Self { + let mut new = self; + new.wait = Option::Some(Option::Some(value)); + new + } + /// Affected points + #[allow(unused_mut)] + pub fn points>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.points = Option::Some(value.into()); + new + } + /// Write ordering guarantees + #[allow(unused_mut)] + pub fn ordering>(self, value: VALUE) -> Self { + let mut new = self; + new.ordering = Option::Some(Option::Some(value.into())); + new + } + /// Option for custom sharding to specify used shard keys + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(DeletePoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + wait: self.wait.unwrap_or_default(), + points: { convert_option(&self.points) }, + ordering: self.ordering.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + wait: core::default::Default::default(), + points: core::default::Default::default(), + ordering: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + } + } +} + +impl From for DeletePoints { + fn from(value: DeletePointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "DeletePointsBuilder", "DeletePoints" + ) + }) + } +} + +impl DeletePointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> DeletePoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "DeletePointsBuilder", "DeletePoints" + ) + }) + } +} + +impl DeletePointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for DeletePointsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum DeletePointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for DeletePointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for DeletePointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for DeletePointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for DeletePointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/delete_shard_key_request_builder.rs b/src/builders/delete_shard_key_request_builder.rs new file mode 100644 index 00000000..b6677099 --- /dev/null +++ b/src/builders/delete_shard_key_request_builder.rs @@ -0,0 +1,118 @@ +use crate::qdrant::*; + +pub struct DeleteShardKeyRequestBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// Request to delete shard key + pub(crate) request: Option>, + /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied + pub(crate) timeout: Option>, +} + +impl DeleteShardKeyRequestBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(DeleteShardKeyRequest { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + request: self.request.unwrap_or_default(), + timeout: self.timeout.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + request: core::default::Default::default(), + timeout: core::default::Default::default(), + } + } +} + +impl From for DeleteShardKeyRequest { + fn from(value: DeleteShardKeyRequestBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "DeleteShardKeyRequestBuilder", "DeleteShardKeyRequest" + ) + }) + } +} + +impl DeleteShardKeyRequestBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> DeleteShardKeyRequest { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "DeleteShardKeyRequestBuilder", "DeleteShardKeyRequest" + ) + }) + } +} + +impl DeleteShardKeyRequestBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for DeleteShardKeyRequestBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum DeleteShardKeyRequestBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for DeleteShardKeyRequestBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for DeleteShardKeyRequestBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for DeleteShardKeyRequestBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for DeleteShardKeyRequestBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/delete_snapshot_request_builder.rs b/src/builders/delete_snapshot_request_builder.rs new file mode 100644 index 00000000..8c9c3332 --- /dev/null +++ b/src/builders/delete_snapshot_request_builder.rs @@ -0,0 +1,121 @@ +use crate::qdrant::*; + +pub struct DeleteSnapshotRequestBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// Name of the collection snapshot + pub(crate) snapshot_name: Option, +} + +impl DeleteSnapshotRequestBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Name of the collection snapshot + #[allow(unused_mut)] + pub fn snapshot_name(self, value: String) -> Self { + let mut new = self; + new.snapshot_name = Option::Some(value); + new + } + + fn build_inner(self) -> Result { + Ok(DeleteSnapshotRequest { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + snapshot_name: match self.snapshot_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("snapshot_name"), + )); + } + }, + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + snapshot_name: core::default::Default::default(), + } + } +} + +impl From for DeleteSnapshotRequest { + fn from(value: DeleteSnapshotRequestBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "DeleteSnapshotRequestBuilder", "DeleteSnapshotRequest" + ) + }) + } +} + +impl DeleteSnapshotRequestBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> DeleteSnapshotRequest { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "DeleteSnapshotRequestBuilder", "DeleteSnapshotRequest" + ) + }) + } +} + +impl DeleteSnapshotRequestBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for DeleteSnapshotRequestBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum DeleteSnapshotRequestBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for DeleteSnapshotRequestBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for DeleteSnapshotRequestBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for DeleteSnapshotRequestBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for DeleteSnapshotRequestBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/discover_batch_points_builder.rs b/src/builders/discover_batch_points_builder.rs new file mode 100644 index 00000000..8f533797 --- /dev/null +++ b/src/builders/discover_batch_points_builder.rs @@ -0,0 +1,146 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct DiscoverBatchPointsBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + pub(crate) discover_points: Option>, + /// Options for specifying read consistency guarantees + read_consistency: Option, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, +} + +impl DiscoverBatchPointsBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + #[allow(unused_mut)] + pub fn discover_points(self, value: Vec) -> Self { + let mut new = self; + new.discover_points = Option::Some(value); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(value.into()); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(DiscoverBatchPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + discover_points: match self.discover_points { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("discover_points"), + )); + } + }, + read_consistency: { convert_option(&self.read_consistency) }, + timeout: self.timeout.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + discover_points: core::default::Default::default(), + read_consistency: core::default::Default::default(), + timeout: core::default::Default::default(), + } + } +} + +impl From for DiscoverBatchPoints { + fn from(value: DiscoverBatchPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "DiscoverBatchPointsBuilder", "DiscoverBatchPoints" + ) + }) + } +} + +impl DiscoverBatchPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> DiscoverBatchPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "DiscoverBatchPointsBuilder", "DiscoverBatchPoints" + ) + }) + } +} + +impl DiscoverBatchPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +// src/builders/discover_batch_points_builder.rs + +#[non_exhaustive] +#[derive(Debug)] +pub enum DiscoverBatchPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for DiscoverBatchPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for DiscoverBatchPointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for DiscoverBatchPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for DiscoverBatchPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/discover_input_builder.rs b/src/builders/discover_input_builder.rs new file mode 100644 index 00000000..6d87c1f1 --- /dev/null +++ b/src/builders/discover_input_builder.rs @@ -0,0 +1,107 @@ +use crate::qdrant::*; + +pub struct DiscoverInputBuilder { + /// Use this as the primary search objective + pub(crate) target: Option>, + /// Search space will be constrained by these pairs of vectors + pub(crate) context: Option>, +} + +impl DiscoverInputBuilder { + /// Use this as the primary search objective + #[allow(unused_mut)] + pub fn target>(self, value: VALUE) -> Self { + let mut new = self; + new.target = Option::Some(Option::Some(value.into())); + new + } + /// Search space will be constrained by these pairs of vectors + #[allow(unused_mut)] + pub fn context>(self, value: VALUE) -> Self { + let mut new = self; + new.context = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(DiscoverInput { + target: self.target.unwrap_or_default(), + context: self.context.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + target: core::default::Default::default(), + context: core::default::Default::default(), + } + } +} + +impl From for DiscoverInput { + fn from(value: DiscoverInputBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "DiscoverInputBuilder", "DiscoverInput" + ) + }) + } +} + +impl DiscoverInputBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> DiscoverInput { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "DiscoverInputBuilder", "DiscoverInput" + ) + }) + } +} + +impl DiscoverInputBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for DiscoverInputBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum DiscoverInputBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the From trait for conversion from UninitializedFieldError +impl From for DiscoverInputBuilderError { + fn from(s: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(s.field_name()) + } +} + +// Implementing the From trait for conversion from String +impl From for DiscoverInputBuilderError { + fn from(s: String) -> Self { + Self::ValidationError(s) + } +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for DiscoverInputBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(ref field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(ref error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for DiscoverInputBuilderError {} diff --git a/src/builders/discover_points_builder.rs b/src/builders/discover_points_builder.rs new file mode 100644 index 00000000..c3bfb79f --- /dev/null +++ b/src/builders/discover_points_builder.rs @@ -0,0 +1,273 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct DiscoverPointsBuilder { + /// name of the collection + pub(crate) collection_name: Option, + /// Use this as the primary search objective + pub(crate) target: Option>, + /// Search will be constrained by these pairs of examples + pub(crate) context: Option>, + /// Filter conditions - return only those points that satisfy the specified conditions + pub(crate) filter: Option>, + /// Max number of result + pub(crate) limit: Option, + /// Options for specifying which payload to include or not + with_payload: Option, + /// Search config + pub(crate) params: Option>, + /// Offset of the result + pub(crate) offset: Option>, + /// Define which vector to use for recommendation, if not specified - default vector + pub(crate) using: Option>, + /// Options for specifying which vectors to include into response + with_vectors: Option, + /// Name of the collection to use for points lookup, if not specified - use current collection + pub(crate) lookup_from: Option>, + /// Options for specifying read consistency guarantees + read_consistency: Option, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, + /// Specify in which shards to look for the points, if not specified - look in all shards + pub(crate) shard_key_selector: Option>, +} + +impl DiscoverPointsBuilder { + /// name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Use this as the primary search objective + #[allow(unused_mut)] + pub fn target>(self, value: VALUE) -> Self { + let mut new = self; + new.target = Option::Some(Option::Some(value.into())); + new + } + /// Search will be constrained by these pairs of examples + #[allow(unused_mut)] + pub fn context(self, value: Vec) -> Self { + let mut new = self; + new.context = Option::Some(value); + new + } + /// Filter conditions - return only those points that satisfy the specified conditions + #[allow(unused_mut)] + pub fn filter>(self, value: VALUE) -> Self { + let mut new = self; + new.filter = Option::Some(Option::Some(value.into())); + new + } + /// Max number of result + #[allow(unused_mut)] + pub fn limit(self, value: u64) -> Self { + let mut new = self; + new.limit = Option::Some(value); + new + } + /// Options for specifying which payload to include or not + #[allow(unused_mut)] + pub fn with_payload>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_payload = Option::Some(value.into()); + new + } + /// Search config + #[allow(unused_mut)] + pub fn params>(self, value: VALUE) -> Self { + let mut new = self; + new.params = Option::Some(Option::Some(value.into())); + new + } + /// Offset of the result + #[allow(unused_mut)] + pub fn offset(self, value: u64) -> Self { + let mut new = self; + new.offset = Option::Some(Option::Some(value)); + new + } + /// Define which vector to use for recommendation, if not specified - default vector + #[allow(unused_mut)] + pub fn using>(self, value: VALUE) -> Self { + let mut new = self; + new.using = Option::Some(Option::Some(value.into())); + new + } + /// Options for specifying which vectors to include into response + #[allow(unused_mut)] + pub fn with_vectors>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_vectors = Option::Some(value.into()); + new + } + /// Name of the collection to use for points lookup, if not specified - use current collection + #[allow(unused_mut)] + pub fn lookup_from>(self, value: VALUE) -> Self { + let mut new = self; + new.lookup_from = Option::Some(Option::Some(value.into())); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(value.into()); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + /// Specify in which shards to look for the points, if not specified - look in all shards + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(DiscoverPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + target: self.target.unwrap_or_default(), + context: match self.context { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("context"), + )); + } + }, + filter: self.filter.unwrap_or_default(), + limit: match self.limit { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("limit"), + )); + } + }, + with_payload: { convert_option(&self.with_payload) }, + params: self.params.unwrap_or_default(), + offset: self.offset.unwrap_or_default(), + using: self.using.unwrap_or_default(), + with_vectors: { convert_option(&self.with_vectors) }, + lookup_from: self.lookup_from.unwrap_or_default(), + read_consistency: { convert_option(&self.read_consistency) }, + timeout: self.timeout.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + target: core::default::Default::default(), + context: core::default::Default::default(), + filter: core::default::Default::default(), + limit: core::default::Default::default(), + with_payload: core::default::Default::default(), + params: core::default::Default::default(), + offset: core::default::Default::default(), + using: core::default::Default::default(), + with_vectors: core::default::Default::default(), + lookup_from: core::default::Default::default(), + read_consistency: core::default::Default::default(), + timeout: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + } + } +} + +impl From for DiscoverPoints { + fn from(value: DiscoverPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "DiscoverPointsBuilder", "DiscoverPoints" + ) + }) + } +} + +impl DiscoverPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> DiscoverPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "DiscoverPointsBuilder", "DiscoverPoints" + ) + }) + } +} + +impl DiscoverPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for DiscoverPointsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum DiscoverPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for DiscoverPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for DiscoverPointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for DiscoverPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for DiscoverPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/facet_counts_builder.rs b/src/builders/facet_counts_builder.rs new file mode 100644 index 00000000..102c7e73 --- /dev/null +++ b/src/builders/facet_counts_builder.rs @@ -0,0 +1,193 @@ +use crate::qdrant::*; + +pub struct FacetCountsBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// Payload key of the facet + pub(crate) key: Option, + /// Filter conditions - return only those points that satisfy the specified conditions. + pub(crate) filter: Option>, + /// Max number of facets. Default is 10. + pub(crate) limit: Option>, + /// If true, return exact counts, slower but useful for debugging purposes. Default is false. + pub(crate) exact: Option>, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, + /// Options for specifying read consistency guarantees + pub(crate) read_consistency: Option>, + /// Specify in which shards to look for the points, if not specified - look in all shards + pub(crate) shard_key_selector: Option>, +} + +impl FacetCountsBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Payload key of the facet + #[allow(unused_mut)] + pub fn key(self, value: String) -> Self { + let mut new = self; + new.key = Option::Some(value); + new + } + /// Filter conditions - return only those points that satisfy the specified conditions. + #[allow(unused_mut)] + pub fn filter>(self, value: VALUE) -> Self { + let mut new = self; + new.filter = Option::Some(Option::Some(value.into())); + new + } + /// Max number of facets. Default is 10. + #[allow(unused_mut)] + pub fn limit(self, value: u64) -> Self { + let mut new = self; + new.limit = Option::Some(Option::Some(value)); + new + } + /// If true, return exact counts, slower but useful for debugging purposes. Default is false. + #[allow(unused_mut)] + pub fn exact(self, value: bool) -> Self { + let mut new = self; + new.exact = Option::Some(Option::Some(value)); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(Option::Some(value.into())); + new + } + /// Specify in which shards to look for the points, if not specified - look in all shards + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(FacetCounts { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + key: match self.key { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("key"), + )); + } + }, + filter: self.filter.unwrap_or_default(), + limit: self.limit.unwrap_or_default(), + exact: self.exact.unwrap_or_default(), + timeout: self.timeout.unwrap_or_default(), + read_consistency: self.read_consistency.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + key: core::default::Default::default(), + filter: core::default::Default::default(), + limit: core::default::Default::default(), + exact: core::default::Default::default(), + timeout: core::default::Default::default(), + read_consistency: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + } + } +} + +impl From for FacetCounts { + fn from(value: FacetCountsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "FacetCountsBuilder", "FacetCounts" + ) + }) + } +} + +impl FacetCountsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> FacetCounts { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "FacetCountsBuilder", "FacetCounts" + ) + }) + } +} + +impl FacetCountsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for FacetCountsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum FacetCountsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the From trait for conversion from UninitializedFieldError +impl From for FacetCountsBuilderError { + fn from(s: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(s.field_name()) + } +} + +// Implementing the From trait for conversion from String +impl From for FacetCountsBuilderError { + fn from(s: String) -> Self { + Self::ValidationError(s) + } +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for FacetCountsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(ref field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(ref error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for FacetCountsBuilderError {} diff --git a/src/builders/float_index_params_builder.rs b/src/builders/float_index_params_builder.rs new file mode 100644 index 00000000..1c3888ad --- /dev/null +++ b/src/builders/float_index_params_builder.rs @@ -0,0 +1,72 @@ +use crate::qdrant::*; + +pub struct FloatIndexParamsBuilder { + /// If true - store index on disk. + pub(crate) on_disk: Option>, + /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. + pub(crate) is_principal: Option>, +} + +impl Default for FloatIndexParamsBuilder { + fn default() -> Self { + Self::new() + } +} + +impl FloatIndexParamsBuilder { + pub fn new() -> Self { + Self::create_empty() + } + + /// If true - store index on disk. + #[allow(unused_mut)] + pub fn on_disk(self, value: bool) -> Self { + let mut new = self; + new.on_disk = Option::Some(Option::Some(value)); + new + } + /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. + #[allow(unused_mut)] + pub fn is_principal(self, value: bool) -> Self { + let mut new = self; + new.is_principal = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(FloatIndexParams { + on_disk: self.on_disk.unwrap_or_default(), + is_principal: self.is_principal.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + on_disk: core::default::Default::default(), + is_principal: core::default::Default::default(), + } + } +} + +impl From for FloatIndexParams { + fn from(value: FloatIndexParamsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "FloatIndexParamsBuilder", "FloatIndexParams" + ) + }) + } +} + +impl FloatIndexParamsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> FloatIndexParams { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "FloatIndexParamsBuilder", "FloatIndexParams" + ) + }) + } +} diff --git a/src/builders/geo_index_params_builder.rs b/src/builders/geo_index_params_builder.rs new file mode 100644 index 00000000..0be70d02 --- /dev/null +++ b/src/builders/geo_index_params_builder.rs @@ -0,0 +1,61 @@ +use crate::qdrant::*; + +pub struct GeoIndexParamsBuilder { + /// If true - store index on disk. + pub(crate) on_disk: Option>, +} + +impl Default for GeoIndexParamsBuilder { + fn default() -> Self { + Self::new() + } +} + +impl GeoIndexParamsBuilder { + pub fn new() -> Self { + Self::create_empty() + } + + /// If true - store index on disk. + #[allow(unused_mut)] + pub fn on_disk(self, value: bool) -> Self { + let mut new = self; + new.on_disk = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(GeoIndexParams { + on_disk: self.on_disk.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + on_disk: core::default::Default::default(), + } + } +} + +impl From for GeoIndexParams { + fn from(value: GeoIndexParamsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "GeoIndexParamsBuilder", "GeoIndexParams" + ) + }) + } +} + +impl GeoIndexParamsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> GeoIndexParams { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "GeoIndexParamsBuilder", "GeoIndexParams" + ) + }) + } +} diff --git a/src/builders/get_points_builder.rs b/src/builders/get_points_builder.rs new file mode 100644 index 00000000..66395f24 --- /dev/null +++ b/src/builders/get_points_builder.rs @@ -0,0 +1,191 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct GetPointsBuilder { + /// name of the collection + pub(crate) collection_name: Option, + /// List of points to retrieve + pub(crate) ids: Option>, + /// Options for specifying which payload to include or not + with_payload: Option, + /// Options for specifying which vectors to include into response + with_vectors: Option, + /// Options for specifying read consistency guarantees + read_consistency: Option, + /// Specify in which shards to look for the points, if not specified - look in all shards + pub(crate) shard_key_selector: Option>, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, +} + +impl GetPointsBuilder { + /// name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// List of points to retrieve + #[allow(unused_mut)] + pub fn ids(self, value: Vec) -> Self { + let mut new = self; + new.ids = Option::Some(value); + new + } + /// Options for specifying which payload to include or not + #[allow(unused_mut)] + pub fn with_payload>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_payload = Option::Some(value.into()); + new + } + /// Options for specifying which vectors to include into response + #[allow(unused_mut)] + pub fn with_vectors>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_vectors = Option::Some(value.into()); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(value.into()); + new + } + /// Specify in which shards to look for the points, if not specified - look in all shards + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(GetPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + ids: match self.ids { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("ids"), + )); + } + }, + with_payload: { convert_option(&self.with_payload) }, + with_vectors: { convert_option(&self.with_vectors) }, + read_consistency: { convert_option(&self.read_consistency) }, + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + timeout: self.timeout.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + ids: core::default::Default::default(), + with_payload: core::default::Default::default(), + with_vectors: core::default::Default::default(), + read_consistency: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + timeout: core::default::Default::default(), + } + } +} + +impl From for GetPoints { + fn from(value: GetPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "GetPointsBuilder", "GetPoints" + ) + }) + } +} + +impl GetPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> GetPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "GetPointsBuilder", "GetPoints" + ) + }) + } +} + +impl GetPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for GetPointsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum GetPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the From trait for conversion from UninitializedFieldError +impl From for GetPointsBuilderError { + fn from(s: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(s.field_name()) + } +} + +// Implementing the From trait for conversion from String +impl From for GetPointsBuilderError { + fn from(s: String) -> Self { + Self::ValidationError(s) + } +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for GetPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(ref field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(ref error) => { + write!(f, "{}", error) + } + } + } +} + +// Implementing the Error trait +impl std::error::Error for GetPointsBuilderError {} diff --git a/src/builders/hnsw_config_diff_builder.rs b/src/builders/hnsw_config_diff_builder.rs new file mode 100644 index 00000000..8fb171ae --- /dev/null +++ b/src/builders/hnsw_config_diff_builder.rs @@ -0,0 +1,150 @@ +use crate::qdrant::*; + +pub struct HnswConfigDiffBuilder { + /// + /// Number of edges per node in the index graph. Larger the value - more accurate the search, more space required. + pub(crate) m: Option>, + /// + /// Number of neighbours to consider during the index building. Larger the value - more accurate the search, more time required to build the index. + pub(crate) ef_construct: Option>, + /// + /// 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 + pub(crate) full_scan_threshold: Option>, + /// + /// 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. + pub(crate) max_indexing_threads: Option>, + /// + /// Store HNSW index on disk. If set to false, the index will be stored in RAM. + pub(crate) on_disk: Option>, + /// + /// Number of additional payload-aware links per node in the index graph. If not set - regular M parameter will be used. + pub(crate) payload_m: Option>, +} +#[allow(clippy::all)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[allow(dead_code)] +impl HnswConfigDiffBuilder { + /// + /// Number of edges per node in the index graph. Larger the value - more accurate the search, more space required. + #[allow(unused_mut)] + pub fn m(self, value: u64) -> Self { + let mut new = self; + new.m = Option::Some(Option::Some(value)); + new + } + /// + /// Number of neighbours to consider during the index building. Larger the value - more accurate the search, more time required to build the index. + #[allow(unused_mut)] + pub fn ef_construct(self, value: u64) -> Self { + let mut new = self; + new.ef_construct = Option::Some(Option::Some(value)); + new + } + /// + /// 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 + #[allow(unused_mut)] + pub fn full_scan_threshold(self, value: u64) -> Self { + let mut new = self; + new.full_scan_threshold = Option::Some(Option::Some(value)); + new + } + /// + /// 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. + #[allow(unused_mut)] + pub fn max_indexing_threads(self, value: u64) -> Self { + let mut new = self; + new.max_indexing_threads = Option::Some(Option::Some(value)); + new + } + /// + /// Store HNSW index on disk. If set to false, the index will be stored in RAM. + #[allow(unused_mut)] + pub fn on_disk(self, value: bool) -> Self { + let mut new = self; + new.on_disk = Option::Some(Option::Some(value)); + new + } + /// + /// Number of additional payload-aware links per node in the index graph. If not set - regular M parameter will be used. + #[allow(unused_mut)] + pub fn payload_m(self, value: u64) -> Self { + let mut new = self; + new.payload_m = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(HnswConfigDiff { + m: match self.m { + Some(value) => value, + None => core::default::Default::default(), + }, + ef_construct: match self.ef_construct { + Some(value) => value, + None => core::default::Default::default(), + }, + full_scan_threshold: match self.full_scan_threshold { + Some(value) => value, + None => core::default::Default::default(), + }, + max_indexing_threads: match self.max_indexing_threads { + Some(value) => value, + None => core::default::Default::default(), + }, + on_disk: match self.on_disk { + Some(value) => value, + None => core::default::Default::default(), + }, + payload_m: match self.payload_m { + Some(value) => value, + None => core::default::Default::default(), + }, + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + m: core::default::Default::default(), + ef_construct: core::default::Default::default(), + full_scan_threshold: core::default::Default::default(), + max_indexing_threads: core::default::Default::default(), + on_disk: core::default::Default::default(), + payload_m: core::default::Default::default(), + } + } +} + +impl From for HnswConfigDiff { + fn from(value: HnswConfigDiffBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "HnswConfigDiffBuilder", "HnswConfigDiff" + ) + }) + } +} + +impl HnswConfigDiffBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> HnswConfigDiff { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "HnswConfigDiffBuilder", "HnswConfigDiff" + ) + }) + } +} diff --git a/src/builders/integer_index_params_builder.rs b/src/builders/integer_index_params_builder.rs new file mode 100644 index 00000000..72da9b92 --- /dev/null +++ b/src/builders/integer_index_params_builder.rs @@ -0,0 +1,133 @@ +use crate::qdrant::*; + +pub struct IntegerIndexParamsBuilder { + /// If true - support direct lookups. + pub(crate) lookup: Option>, + /// If true - support ranges filters. + pub(crate) range: Option>, + /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. + pub(crate) is_principal: Option>, + /// If true - store index on disk. + pub(crate) on_disk: Option>, +} + +impl IntegerIndexParamsBuilder { + pub fn new(lookup: bool, range: bool) -> Self { + Self::create_empty().lookup(lookup).range(range) + } + + /// If true - support direct lookups. + #[allow(unused_mut)] + pub fn lookup>(self, value: VALUE) -> Self { + let mut new = self; + new.lookup = Option::Some(Option::Some(value.into())); + new + } + /// If true - support ranges filters. + #[allow(unused_mut)] + pub fn range>(self, value: VALUE) -> Self { + let mut new = self; + new.range = Option::Some(Option::Some(value.into())); + new + } + /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. + #[allow(unused_mut)] + pub fn is_principal(self, value: bool) -> Self { + let mut new = self; + new.is_principal = Option::Some(Option::Some(value)); + new + } + /// If true - store index on disk. + #[allow(unused_mut)] + pub fn on_disk(self, value: bool) -> Self { + let mut new = self; + new.on_disk = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(IntegerIndexParams { + lookup: self.lookup.unwrap_or_default(), + range: self.range.unwrap_or_default(), + is_principal: self.is_principal.unwrap_or_default(), + on_disk: self.on_disk.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + lookup: core::default::Default::default(), + range: core::default::Default::default(), + is_principal: core::default::Default::default(), + on_disk: core::default::Default::default(), + } + } +} + +impl From for IntegerIndexParams { + fn from(value: IntegerIndexParamsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "IntegerIndexParamsBuilder", "IntegerIndexParams" + ) + }) + } +} + +impl IntegerIndexParamsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> IntegerIndexParams { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "IntegerIndexParamsBuilder", "IntegerIndexParams" + ) + }) + } +} + +impl Default for IntegerIndexParamsBuilder { + fn default() -> Self { + Self::create_empty() + } +} + +/// Error type for IntegerIndexParamsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum IntegerIndexParamsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for IntegerIndexParamsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for IntegerIndexParamsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for IntegerIndexParamsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for IntegerIndexParamsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/keyword_index_params_builder.rs b/src/builders/keyword_index_params_builder.rs new file mode 100644 index 00000000..1e64d7cd --- /dev/null +++ b/src/builders/keyword_index_params_builder.rs @@ -0,0 +1,68 @@ +use crate::qdrant::*; + +pub struct KeywordIndexParamsBuilder { + /// If true - used for tenant optimization. + pub(crate) is_tenant: Option>, + /// If true - store index on disk. + pub(crate) on_disk: Option>, +} + +impl Default for KeywordIndexParamsBuilder { + fn default() -> Self { + Self::create_empty() + } +} + +impl KeywordIndexParamsBuilder { + /// If true - used for tenant optimization. + #[allow(unused_mut)] + pub fn is_tenant(self, value: bool) -> Self { + let mut new = self; + new.is_tenant = Option::Some(Option::Some(value)); + new + } + /// If true - store index on disk. + #[allow(unused_mut)] + pub fn on_disk(self, value: bool) -> Self { + let mut new = self; + new.on_disk = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(KeywordIndexParams { + is_tenant: self.is_tenant.unwrap_or_default(), + on_disk: self.on_disk.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + is_tenant: core::default::Default::default(), + on_disk: core::default::Default::default(), + } + } +} + +impl From for KeywordIndexParams { + fn from(value: KeywordIndexParamsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "KeywordIndexParamsBuilder", "KeywordIndexParams" + ) + }) + } +} + +impl KeywordIndexParamsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> KeywordIndexParams { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "KeywordIndexParamsBuilder", "KeywordIndexParams" + ) + }) + } +} diff --git a/src/builders/lookup_location_builder.rs b/src/builders/lookup_location_builder.rs new file mode 100644 index 00000000..4af626b5 --- /dev/null +++ b/src/builders/lookup_location_builder.rs @@ -0,0 +1,126 @@ +use crate::qdrant::*; + +pub struct LookupLocationBuilder { + pub(crate) collection_name: Option, + /// Which vector to use for search, if not specified - use default vector + pub(crate) vector_name: Option>, + /// Specify in which shards to look for the points, if not specified - look in all shards + pub(crate) shard_key_selector: Option>, +} + +impl LookupLocationBuilder { + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Which vector to use for search, if not specified - use default vector + #[allow(unused_mut)] + pub fn vector_name>(self, value: VALUE) -> Self { + let mut new = self; + new.vector_name = Option::Some(Option::Some(value.into())); + new + } + /// Specify in which shards to look for the points, if not specified - look in all shards + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(LookupLocation { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + vector_name: self.vector_name.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + vector_name: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + } + } +} + +impl From for LookupLocation { + fn from(value: LookupLocationBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "LookupLocationBuilder", "LookupLocation" + ) + }) + } +} + +impl LookupLocationBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> LookupLocation { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "LookupLocationBuilder", "LookupLocation" + ) + }) + } +} + +impl LookupLocationBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for LookupLocationBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum LookupLocationBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for LookupLocationBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for LookupLocationBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for LookupLocationBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for LookupLocationBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/mod.rs b/src/builders/mod.rs new file mode 100644 index 00000000..1b930152 --- /dev/null +++ b/src/builders/mod.rs @@ -0,0 +1,212 @@ +mod vector_params_builder; +pub use vector_params_builder::VectorParamsBuilder; + +mod vector_params_diff_builder; +pub use vector_params_diff_builder::VectorParamsDiffBuilder; + +mod sparse_vector_params_builder; +pub use sparse_vector_params_builder::SparseVectorParamsBuilder; + +mod multi_vector_config_builder; +pub use multi_vector_config_builder::MultiVectorConfigBuilder; + +mod hnsw_config_diff_builder; +pub use hnsw_config_diff_builder::HnswConfigDiffBuilder; + +mod sparse_index_config_builder; +pub use sparse_index_config_builder::SparseIndexConfigBuilder; + +mod wal_config_diff_builder; +pub use wal_config_diff_builder::WalConfigDiffBuilder; + +mod optimizers_config_diff_builder; +pub use optimizers_config_diff_builder::OptimizersConfigDiffBuilder; + +mod scalar_quantization_builder; +pub use scalar_quantization_builder::ScalarQuantizationBuilder; + +mod product_quantization_builder; +pub use product_quantization_builder::ProductQuantizationBuilder; + +mod binary_quantization_builder; +pub use binary_quantization_builder::BinaryQuantizationBuilder; + +mod strict_mode_config_builder; +pub use strict_mode_config_builder::StrictModeConfigBuilder; + +mod update_collection_builder; +pub use update_collection_builder::UpdateCollectionBuilder; + +mod delete_collection_builder; +pub use delete_collection_builder::DeleteCollectionBuilder; + +mod collection_params_diff_builder; +pub use collection_params_diff_builder::CollectionParamsDiffBuilder; + +mod keyword_index_params_builder; +pub use keyword_index_params_builder::KeywordIndexParamsBuilder; + +mod integer_index_params_builder; +pub use integer_index_params_builder::IntegerIndexParamsBuilder; + +mod float_index_params_builder; +pub use float_index_params_builder::FloatIndexParamsBuilder; + +mod geo_index_params_builder; +pub use geo_index_params_builder::GeoIndexParamsBuilder; + +mod text_index_params_builder; +pub use text_index_params_builder::TextIndexParamsBuilder; + +mod datetime_index_params_builder; +pub use datetime_index_params_builder::DatetimeIndexParamsBuilder; + +mod uuid_index_params_builder; +pub use uuid_index_params_builder::UuidIndexParamsBuilder; + +mod create_alias_builder; +pub use create_alias_builder::CreateAliasBuilder; + +mod rename_alias_builder; +pub use rename_alias_builder::RenameAliasBuilder; + +mod move_shard_builder; +pub use move_shard_builder::MoveShardBuilder; + +mod replicate_shard_builder; +pub use replicate_shard_builder::ReplicateShardBuilder; + +mod abort_shard_transfer_builder; +pub use abort_shard_transfer_builder::AbortShardTransferBuilder; + +mod replica_builder; +pub use replica_builder::ReplicaBuilder; + +mod create_shard_key_builder; +pub use create_shard_key_builder::CreateShardKeyBuilder; + +mod update_collection_cluster_setup_request_builder; +pub use update_collection_cluster_setup_request_builder::UpdateCollectionClusterSetupRequestBuilder; + +mod create_shard_key_request_builder; +pub use create_shard_key_request_builder::CreateShardKeyRequestBuilder; + +mod delete_shard_key_request_builder; +pub use delete_shard_key_request_builder::DeleteShardKeyRequestBuilder; + +mod upsert_points_builder; +pub use upsert_points_builder::UpsertPointsBuilder; + +mod delete_points_builder; +pub use delete_points_builder::DeletePointsBuilder; + +mod get_points_builder; +pub use get_points_builder::GetPointsBuilder; + +mod update_point_vectors_builder; +pub use update_point_vectors_builder::UpdatePointVectorsBuilder; + +mod delete_point_vectors_builder; +pub use delete_point_vectors_builder::DeletePointVectorsBuilder; + +mod set_payload_points_builder; +pub use set_payload_points_builder::SetPayloadPointsBuilder; + +mod delete_payload_points_builder; +pub use delete_payload_points_builder::DeletePayloadPointsBuilder; + +mod clear_payload_points_builder; +pub use clear_payload_points_builder::ClearPayloadPointsBuilder; + +mod create_field_index_collection_builder; +pub use create_field_index_collection_builder::CreateFieldIndexCollectionBuilder; + +mod delete_field_index_collection_builder; +pub use delete_field_index_collection_builder::DeleteFieldIndexCollectionBuilder; + +mod quantization_search_params_builder; +pub use quantization_search_params_builder::QuantizationSearchParamsBuilder; + +mod search_params_builder; +pub use search_params_builder::SearchParamsBuilder; + +mod search_points_builder; +pub use search_points_builder::SearchPointsBuilder; + +mod search_batch_points_builder; +pub use search_batch_points_builder::SearchBatchPointsBuilder; + +mod with_lookup_builder; +pub use with_lookup_builder::WithLookupBuilder; + +mod search_point_groups_builder; +pub use search_point_groups_builder::SearchPointGroupsBuilder; + +mod order_by_builder; +pub use order_by_builder::OrderByBuilder; + +mod scroll_points_builder; +pub use scroll_points_builder::ScrollPointsBuilder; + +mod lookup_location_builder; +pub use lookup_location_builder::LookupLocationBuilder; + +mod recommend_points_builder; +pub use recommend_points_builder::RecommendPointsBuilder; + +mod recommend_batch_points_builder; +pub use recommend_batch_points_builder::RecommendBatchPointsBuilder; + +mod recommend_point_groups_builder; +pub use recommend_point_groups_builder::RecommendPointGroupsBuilder; + +mod context_example_pair_builder; +pub use context_example_pair_builder::ContextExamplePairBuilder; + +mod discover_points_builder; +pub use discover_points_builder::DiscoverPointsBuilder; + +mod discover_batch_points_builder; +pub use discover_batch_points_builder::DiscoverBatchPointsBuilder; + +mod recommend_input_builder; +pub use recommend_input_builder::RecommendInputBuilder; + +mod context_input_pair_builder; +pub use context_input_pair_builder::ContextInputPairBuilder; + +mod discover_input_builder; +pub use discover_input_builder::DiscoverInputBuilder; + +mod context_input_builder; +pub use context_input_builder::ContextInputBuilder; + +mod prefetch_query_builder; +pub use prefetch_query_builder::PrefetchQueryBuilder; + +mod query_points_builder; +pub use query_points_builder::QueryPointsBuilder; + +mod query_batch_points_builder; +pub use query_batch_points_builder::QueryBatchPointsBuilder; + +mod query_point_groups_builder; +pub use query_point_groups_builder::QueryPointGroupsBuilder; + +mod facet_counts_builder; +pub use facet_counts_builder::FacetCountsBuilder; + +mod search_matrix_points_builder; +pub use search_matrix_points_builder::SearchMatrixPointsBuilder; + +mod update_batch_points_builder; +pub use update_batch_points_builder::UpdateBatchPointsBuilder; + +mod delete_snapshot_request_builder; +pub use delete_snapshot_request_builder::DeleteSnapshotRequestBuilder; + +pub mod create_collection_builder; +pub use create_collection_builder::CreateCollectionBuilder; + +pub mod count_points_builder; +pub use count_points_builder::*; diff --git a/src/builders/move_shard_builder.rs b/src/builders/move_shard_builder.rs new file mode 100644 index 00000000..2aa4773f --- /dev/null +++ b/src/builders/move_shard_builder.rs @@ -0,0 +1,153 @@ +use crate::qdrant::*; + +pub struct MoveShardBuilder { + /// Local shard id + pub(crate) shard_id: Option, + pub(crate) to_shard_id: Option>, + pub(crate) from_peer_id: Option, + pub(crate) to_peer_id: Option, + pub(crate) method: Option>, +} + +impl MoveShardBuilder { + /// Local shard id + #[allow(unused_mut)] + pub fn shard_id(self, value: u32) -> Self { + let mut new = self; + new.shard_id = Option::Some(value); + new + } + #[allow(unused_mut)] + pub fn to_shard_id(self, value: u32) -> Self { + let mut new = self; + new.to_shard_id = Option::Some(Option::Some(value)); + new + } + #[allow(unused_mut)] + pub fn from_peer_id(self, value: u64) -> Self { + let mut new = self; + new.from_peer_id = Option::Some(value); + new + } + #[allow(unused_mut)] + pub fn to_peer_id(self, value: u64) -> Self { + let mut new = self; + new.to_peer_id = Option::Some(value); + new + } + #[allow(unused_mut)] + pub fn method>(self, value: VALUE) -> Self { + let mut new = self; + new.method = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(MoveShard { + shard_id: match self.shard_id { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("shard_id"), + )); + } + }, + to_shard_id: self.to_shard_id.unwrap_or_default(), + from_peer_id: match self.from_peer_id { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("from_peer_id"), + )); + } + }, + to_peer_id: match self.to_peer_id { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("to_peer_id"), + )); + } + }, + method: self.method.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + shard_id: core::default::Default::default(), + to_shard_id: core::default::Default::default(), + from_peer_id: core::default::Default::default(), + to_peer_id: core::default::Default::default(), + method: core::default::Default::default(), + } + } +} + +impl From for MoveShard { + fn from(value: MoveShardBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "MoveShardBuilder", "MoveShard" + ) + }) + } +} + +impl MoveShardBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> MoveShard { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "MoveShardBuilder", "MoveShard" + ) + }) + } +} + +impl MoveShardBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for MoveShardBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum MoveShardBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for MoveShardBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for MoveShardBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for MoveShardBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for MoveShardBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/multi_vector_config_builder.rs b/src/builders/multi_vector_config_builder.rs new file mode 100644 index 00000000..07930ada --- /dev/null +++ b/src/builders/multi_vector_config_builder.rs @@ -0,0 +1,96 @@ +use crate::qdrant::*; + +pub struct MultiVectorConfigBuilder { + /// Comparator for multi-vector search + pub(crate) comparator: Option, +} + +impl MultiVectorConfigBuilder { + /// Comparator for multi-vector search + #[allow(unused_mut)] + pub fn comparator>(self, value: VALUE) -> Self { + let mut new = self; + new.comparator = Option::Some(value.into()); + new + } + + fn build_inner(self) -> Result { + Ok(MultiVectorConfig { + comparator: self.comparator.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + comparator: core::default::Default::default(), + } + } +} + +impl From for MultiVectorConfig { + fn from(value: MultiVectorConfigBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "MultiVectorConfigBuilder", "MultiVectorConfig" + ) + }) + } +} + +impl MultiVectorConfigBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> MultiVectorConfig { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "MultiVectorConfigBuilder", "MultiVectorConfig" + ) + }) + } +} + +impl MultiVectorConfigBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for MultiVectorConfigBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum MultiVectorConfigBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for MultiVectorConfigBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for MultiVectorConfigBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for MultiVectorConfigBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for MultiVectorConfigBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/optimizers_config_diff_builder.rs b/src/builders/optimizers_config_diff_builder.rs new file mode 100644 index 00000000..78d1d4f2 --- /dev/null +++ b/src/builders/optimizers_config_diff_builder.rs @@ -0,0 +1,210 @@ +use crate::qdrant::*; + +pub struct OptimizersConfigDiffBuilder { + /// + /// The minimal fraction of deleted vectors in a segment, required to perform segment optimization + pub(crate) deleted_threshold: Option>, + /// + /// The minimal number of vectors in a segment, required to perform segment optimization + pub(crate) vacuum_min_vector_number: Option>, + /// + /// Target amount of segments the optimizer will try to keep. + /// Real amount of segments may vary depending on multiple parameters: + /// + /// - Amount of stored points. + /// - Current write RPS. + /// + /// It is recommended to select the default number of segments as a factor of the number of search threads, + /// so that each segment would be handled evenly by one of the threads. + pub(crate) default_segment_number: Option>, + /// + /// Do not create segments larger this size (in kilobytes). + /// Large segments might require disproportionately long indexation times, + /// therefore it makes sense to limit the size of segments. + /// + /// If indexing speed is more important - make this parameter lower. + /// If search speed is more important - make this parameter higher. + /// Note: 1Kb = 1 vector of size 256 + /// If not set, will be automatically selected considering the number of available CPUs. + pub(crate) max_segment_size: Option>, + /// + /// Maximum size (in kilobytes) of vectors to store in-memory per segment. + /// Segments larger than this threshold will be stored as read-only memmaped file. + /// + /// Memmap storage is disabled by default, to enable it, set this threshold to a reasonable value. + /// + /// To disable memmap storage, set this to `0`. + /// + /// Note: 1Kb = 1 vector of size 256 + pub(crate) memmap_threshold: Option>, + /// + /// Maximum size (in kilobytes) of vectors allowed for plain index, exceeding this threshold will enable vector indexing + /// + /// Default value is 20,000, based on <.> + /// + /// To disable vector indexing, set to `0`. + /// + /// Note: 1kB = 1 vector of size 256. + pub(crate) indexing_threshold: Option>, + /// + /// Interval between forced flushes. + pub(crate) flush_interval_sec: Option>, + /// + /// Max number of threads (jobs) for running optimizations per shard. + /// Note: each optimization job will also use `max_indexing_threads` threads by itself for index building. + /// If null - have no limit and choose dynamically to saturate CPU. + /// If 0 - no optimization threads, optimizations will be disabled. + pub(crate) max_optimization_threads: Option>, +} + +impl OptimizersConfigDiffBuilder { + /// + /// The minimal fraction of deleted vectors in a segment, required to perform segment optimization + #[allow(unused_mut)] + pub fn deleted_threshold(self, value: f64) -> Self { + let mut new = self; + new.deleted_threshold = Option::Some(Option::Some(value)); + new + } + /// + /// The minimal number of vectors in a segment, required to perform segment optimization + #[allow(unused_mut)] + pub fn vacuum_min_vector_number(self, value: u64) -> Self { + let mut new = self; + new.vacuum_min_vector_number = Option::Some(Option::Some(value)); + new + } + /// + /// Target amount of segments the optimizer will try to keep. + /// Real amount of segments may vary depending on multiple parameters: + /// + /// - Amount of stored points. + /// - Current write RPS. + /// + /// It is recommended to select the default number of segments as a factor of the number of search threads, + /// so that each segment would be handled evenly by one of the threads. + #[allow(unused_mut)] + pub fn default_segment_number(self, value: u64) -> Self { + let mut new = self; + new.default_segment_number = Option::Some(Option::Some(value)); + new + } + /// + /// Do not create segments larger this size (in kilobytes). + /// Large segments might require disproportionately long indexation times, + /// therefore it makes sense to limit the size of segments. + /// + /// If indexing speed is more important - make this parameter lower. + /// If search speed is more important - make this parameter higher. + /// Note: 1Kb = 1 vector of size 256 + /// If not set, will be automatically selected considering the number of available CPUs. + #[allow(unused_mut)] + pub fn max_segment_size(self, value: u64) -> Self { + let mut new = self; + new.max_segment_size = Option::Some(Option::Some(value)); + new + } + /// + /// Maximum size (in kilobytes) of vectors to store in-memory per segment. + /// Segments larger than this threshold will be stored as read-only memmaped file. + /// + /// Memmap storage is disabled by default, to enable it, set this threshold to a reasonable value. + /// + /// To disable memmap storage, set this to `0`. + /// + /// Note: 1Kb = 1 vector of size 256 + #[allow(unused_mut)] + pub fn memmap_threshold(self, value: u64) -> Self { + let mut new = self; + new.memmap_threshold = Option::Some(Option::Some(value)); + new + } + /// + /// Maximum size (in kilobytes) of vectors allowed for plain index, exceeding this threshold will enable vector indexing + /// + /// Default value is 20,000, based on <.> + /// + /// To disable vector indexing, set to `0`. + /// + /// Note: 1kB = 1 vector of size 256. + #[allow(unused_mut)] + pub fn indexing_threshold(self, value: u64) -> Self { + let mut new = self; + new.indexing_threshold = Option::Some(Option::Some(value)); + new + } + /// + /// Interval between forced flushes. + #[allow(unused_mut)] + pub fn flush_interval_sec(self, value: u64) -> Self { + let mut new = self; + new.flush_interval_sec = Option::Some(Option::Some(value)); + new + } + /// + /// Max number of threads (jobs) for running optimizations per shard. + /// Note: each optimization job will also use `max_indexing_threads` threads by itself for index building. + /// If null - have no limit and choose dynamically to saturate CPU. + /// If 0 - no optimization threads, optimizations will be disabled. + #[allow(unused_mut)] + pub fn max_optimization_threads(self, value: u64) -> Self { + let mut new = self; + new.max_optimization_threads = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(OptimizersConfigDiff { + deleted_threshold: self.deleted_threshold.unwrap_or_default(), + vacuum_min_vector_number: self.vacuum_min_vector_number.unwrap_or_default(), + default_segment_number: self.default_segment_number.unwrap_or_default(), + max_segment_size: self.max_segment_size.unwrap_or_default(), + memmap_threshold: self.memmap_threshold.unwrap_or_default(), + indexing_threshold: self.indexing_threshold.unwrap_or_default(), + flush_interval_sec: self.flush_interval_sec.unwrap_or_default(), + max_optimization_threads: self.max_optimization_threads.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + deleted_threshold: core::default::Default::default(), + vacuum_min_vector_number: core::default::Default::default(), + default_segment_number: core::default::Default::default(), + max_segment_size: core::default::Default::default(), + memmap_threshold: core::default::Default::default(), + indexing_threshold: core::default::Default::default(), + flush_interval_sec: core::default::Default::default(), + max_optimization_threads: core::default::Default::default(), + } + } +} + +impl From for OptimizersConfigDiff { + fn from(value: OptimizersConfigDiffBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "OptimizersConfigDiffBuilder", "OptimizersConfigDiff" + ) + }) + } +} + +impl OptimizersConfigDiffBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> OptimizersConfigDiff { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "OptimizersConfigDiffBuilder", "OptimizersConfigDiff" + ) + }) + } +} + +impl Default for OptimizersConfigDiffBuilder { + fn default() -> Self { + Self::create_empty() + } +} diff --git a/src/builders/order_by_builder.rs b/src/builders/order_by_builder.rs new file mode 100644 index 00000000..54e7930a --- /dev/null +++ b/src/builders/order_by_builder.rs @@ -0,0 +1,119 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct OrderByBuilder { + /// Payload key to order by + pub(crate) key: Option, + /// Ascending or descending order + pub(crate) direction: Option>, + /// Start from this value + start_from: Option, +} + +impl OrderByBuilder { + /// Payload key to order by + #[allow(unused_mut)] + pub fn key(self, value: String) -> Self { + let mut new = self; + new.key = Option::Some(value); + new + } + /// Ascending or descending order + #[allow(unused_mut)] + pub fn direction(self, value: i32) -> Self { + let mut new = self; + new.direction = Option::Some(Option::Some(value)); + new + } + /// Start from this value + #[allow(unused_mut)] + pub fn start_from>(self, value: VALUE) -> Self { + let mut new = self; + new.start_from = Option::Some(value.into()); + new + } + + fn build_inner(self) -> Result { + Ok(OrderBy { + key: match self.key { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("key"), + )); + } + }, + direction: self.direction.unwrap_or_default(), + start_from: { convert_option(&self.start_from) }, + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + key: core::default::Default::default(), + direction: core::default::Default::default(), + start_from: core::default::Default::default(), + } + } +} + +impl From for OrderBy { + fn from(value: OrderByBuilder) -> Self { + value + .build_inner() + .unwrap_or_else(|_| panic!("Failed to convert {0} to {1}", "OrderByBuilder", "OrderBy")) + } +} + +impl OrderByBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> OrderBy { + self.build_inner() + .unwrap_or_else(|_| panic!("Failed to build {0} into {1}", "OrderByBuilder", "OrderBy")) + } +} + +impl OrderByBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for OrderByBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum OrderByBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for OrderByBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for OrderByBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for OrderByBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for OrderByBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/prefetch_query_builder.rs b/src/builders/prefetch_query_builder.rs new file mode 100644 index 00000000..37b6c65c --- /dev/null +++ b/src/builders/prefetch_query_builder.rs @@ -0,0 +1,134 @@ +use crate::qdrant::*; + +pub struct PrefetchQueryBuilder { + /// Sub-requests to perform first. If present, the query will be performed on the results of the prefetches. + pub(crate) prefetch: Option>, + /// Query to perform. If missing, returns points ordered by their IDs. + pub(crate) query: Option>, + /// Define which vector to use for querying. If missing, the default vector is is used. + pub(crate) using: Option>, + /// Filter conditions - return only those points that satisfy the specified conditions. + pub(crate) filter: Option>, + /// Search params for when there is no prefetch. + pub(crate) params: Option>, + /// Return points with scores better than this threshold. + pub(crate) score_threshold: Option>, + /// Max number of points. Default is 10 + pub(crate) limit: Option>, + /// The location to use for IDs lookup, if not specified - use the current collection and the 'using' vector + pub(crate) lookup_from: Option>, +} + +impl PrefetchQueryBuilder { + /// Sub-requests to perform first. If present, the query will be performed on the results of the prefetches. + #[allow(unused_mut)] + pub fn prefetch>>(self, value: VALUE) -> Self { + let mut new = self; + new.prefetch = Option::Some(value.into()); + new + } + /// Query to perform. If missing, returns points ordered by their IDs. + #[allow(unused_mut)] + pub fn query>(self, value: VALUE) -> Self { + let mut new = self; + new.query = Option::Some(Option::Some(value.into())); + new + } + /// Define which vector to use for querying. If missing, the default vector is is used. + #[allow(unused_mut)] + pub fn using>(self, value: VALUE) -> Self { + let mut new = self; + new.using = Option::Some(Option::Some(value.into())); + new + } + /// Filter conditions - return only those points that satisfy the specified conditions. + #[allow(unused_mut)] + pub fn filter>(self, value: VALUE) -> Self { + let mut new = self; + new.filter = Option::Some(Option::Some(value.into())); + new + } + /// Search params for when there is no prefetch. + #[allow(unused_mut)] + pub fn params>(self, value: VALUE) -> Self { + let mut new = self; + new.params = Option::Some(Option::Some(value.into())); + new + } + /// Return points with scores better than this threshold. + #[allow(unused_mut)] + pub fn score_threshold>(self, value: VALUE) -> Self { + let mut new = self; + new.score_threshold = Option::Some(Option::Some(value.into())); + new + } + /// Max number of points. Default is 10 + #[allow(unused_mut)] + pub fn limit>(self, value: VALUE) -> Self { + let mut new = self; + new.limit = Option::Some(Option::Some(value.into())); + new + } + /// The location to use for IDs lookup, if not specified - use the current collection and the 'using' vector + #[allow(unused_mut)] + pub fn lookup_from>(self, value: VALUE) -> Self { + let mut new = self; + new.lookup_from = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(PrefetchQuery { + prefetch: self.prefetch.unwrap_or_default(), + query: self.query.unwrap_or_default(), + using: self.using.unwrap_or_default(), + filter: self.filter.unwrap_or_default(), + params: self.params.unwrap_or_default(), + score_threshold: self.score_threshold.unwrap_or_default(), + limit: self.limit.unwrap_or_default(), + lookup_from: self.lookup_from.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + prefetch: core::default::Default::default(), + query: core::default::Default::default(), + using: core::default::Default::default(), + filter: core::default::Default::default(), + params: core::default::Default::default(), + score_threshold: core::default::Default::default(), + limit: core::default::Default::default(), + lookup_from: core::default::Default::default(), + } + } +} + +impl From for PrefetchQuery { + fn from(value: PrefetchQueryBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "PrefetchQueryBuilder", "PrefetchQuery" + ) + }) + } +} + +impl PrefetchQueryBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> PrefetchQuery { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "PrefetchQueryBuilder", "PrefetchQuery" + ) + }) + } +} + +impl Default for PrefetchQueryBuilder { + fn default() -> Self { + Self::create_empty() + } +} diff --git a/src/builders/product_quantization_builder.rs b/src/builders/product_quantization_builder.rs new file mode 100644 index 00000000..64769629 --- /dev/null +++ b/src/builders/product_quantization_builder.rs @@ -0,0 +1,114 @@ +use crate::qdrant::*; + +pub struct ProductQuantizationBuilder { + /// Compression ratio + pub(crate) compression: Option, + /// If true - quantized vectors always will be stored in RAM, ignoring the config of main storage + pub(crate) always_ram: Option>, +} + +impl ProductQuantizationBuilder { + /// Compression ratio + #[allow(unused_mut)] + pub fn compression(self, value: i32) -> Self { + let mut new = self; + new.compression = Option::Some(value); + new + } + /// If true - quantized vectors always will be stored in RAM, ignoring the config of main storage + #[allow(unused_mut)] + pub fn always_ram(self, value: bool) -> Self { + let mut new = self; + new.always_ram = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(ProductQuantization { + compression: match self.compression { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("compression"), + )); + } + }, + always_ram: self.always_ram.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + compression: core::default::Default::default(), + always_ram: core::default::Default::default(), + } + } +} + +impl From for ProductQuantization { + fn from(value: ProductQuantizationBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "ProductQuantizationBuilder", "ProductQuantization" + ) + }) + } +} + +impl ProductQuantizationBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> ProductQuantization { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "ProductQuantizationBuilder", "ProductQuantization" + ) + }) + } +} + +impl ProductQuantizationBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for ProductQuantizationBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum ProductQuantizationBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for ProductQuantizationBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for ProductQuantizationBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for ProductQuantizationBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for ProductQuantizationBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/quantization_search_params_builder.rs b/src/builders/quantization_search_params_builder.rs new file mode 100644 index 00000000..f3b4ad28 --- /dev/null +++ b/src/builders/quantization_search_params_builder.rs @@ -0,0 +1,97 @@ +use crate::qdrant::*; + +pub struct QuantizationSearchParamsBuilder { + /// + /// If set to true, search will ignore quantized vector data + pub(crate) ignore: Option>, + /// + /// If true, use original vectors to re-score top-k results. If ignored, qdrant decides automatically does rescore enabled or not. + pub(crate) rescore: Option>, + /// + /// Oversampling factor for quantization. + /// + /// Defines how many extra vectors should be pre-selected using quantized index, + /// and then re-scored using original vectors. + /// + /// For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will be pre-selected using quantized index, + /// and then top-100 will be returned after re-scoring. + pub(crate) oversampling: Option>, +} + +impl QuantizationSearchParamsBuilder { + /// + /// If set to true, search will ignore quantized vector data + #[allow(unused_mut)] + pub fn ignore(self, value: bool) -> Self { + let mut new = self; + new.ignore = Option::Some(Option::Some(value)); + new + } + /// + /// If true, use original vectors to re-score top-k results. If ignored, qdrant decides automatically does rescore enabled or not. + #[allow(unused_mut)] + pub fn rescore(self, value: bool) -> Self { + let mut new = self; + new.rescore = Option::Some(Option::Some(value)); + new + } + /// + /// Oversampling factor for quantization. + /// + /// Defines how many extra vectors should be pre-selected using quantized index, + /// and then re-scored using original vectors. + /// + /// For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will be pre-selected using quantized index, + /// and then top-100 will be returned after re-scoring. + #[allow(unused_mut)] + pub fn oversampling(self, value: f64) -> Self { + let mut new = self; + new.oversampling = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(QuantizationSearchParams { + ignore: self.ignore.unwrap_or_default(), + rescore: self.rescore.unwrap_or_default(), + oversampling: self.oversampling.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + ignore: core::default::Default::default(), + rescore: core::default::Default::default(), + oversampling: core::default::Default::default(), + } + } +} + +impl Default for QuantizationSearchParamsBuilder { + fn default() -> Self { + Self::create_empty() + } +} + +impl From for QuantizationSearchParams { + fn from(value: QuantizationSearchParamsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "QuantizationSearchParamsBuilder", "QuantizationSearchParams" + ) + }) + } +} + +impl QuantizationSearchParamsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> QuantizationSearchParams { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "QuantizationSearchParamsBuilder", "QuantizationSearchParams" + ) + }) + } +} diff --git a/src/builders/query_batch_points_builder.rs b/src/builders/query_batch_points_builder.rs new file mode 100644 index 00000000..8a65b23e --- /dev/null +++ b/src/builders/query_batch_points_builder.rs @@ -0,0 +1,143 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct QueryBatchPointsBuilder { + pub(crate) collection_name: Option, + pub(crate) query_points: Option>, + /// Options for specifying read consistency guarantees + read_consistency: Option, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, +} + +impl QueryBatchPointsBuilder { + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + #[allow(unused_mut)] + pub fn query_points(self, value: Vec) -> Self { + let mut new = self; + new.query_points = Option::Some(value); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(value.into()); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(QueryBatchPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + query_points: match self.query_points { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("query_points"), + )); + } + }, + read_consistency: { convert_option(&self.read_consistency) }, + timeout: self.timeout.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + query_points: core::default::Default::default(), + read_consistency: core::default::Default::default(), + timeout: core::default::Default::default(), + } + } +} + +impl From for QueryBatchPoints { + fn from(value: QueryBatchPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "QueryBatchPointsBuilder", "QueryBatchPoints" + ) + }) + } +} + +impl QueryBatchPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> QueryBatchPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "QueryBatchPointsBuilder", "QueryBatchPoints" + ) + }) + } +} + +impl QueryBatchPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for QueryBatchPointsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum QueryBatchPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for QueryBatchPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for QueryBatchPointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for QueryBatchPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for QueryBatchPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/query_point_groups_builder.rs b/src/builders/query_point_groups_builder.rs new file mode 100644 index 00000000..d4a45d6a --- /dev/null +++ b/src/builders/query_point_groups_builder.rs @@ -0,0 +1,298 @@ +use crate::qdrant::*; + +pub struct QueryPointGroupsBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// Sub-requests to perform first. If present, the query will be performed on the results of the prefetches. + pub(crate) prefetch: Option>, + /// Query to perform. If missing, returns points ordered by their IDs. + pub(crate) query: Option>, + /// Define which vector to use for querying. If missing, the default vector is used. + pub(crate) using: Option>, + /// Filter conditions - return only those points that satisfy the specified conditions. + pub(crate) filter: Option>, + /// Search params for when there is no prefetch. + pub(crate) params: Option>, + /// Return points with scores better than this threshold. + pub(crate) score_threshold: Option>, + /// Options for specifying which payload to include or not + pub(crate) with_payload: Option>, + /// Options for specifying which vectors to include into response + pub(crate) with_vectors: Option>, + /// The location to use for IDs lookup, if not specified - use the current collection and the 'using' vector + pub(crate) lookup_from: Option>, + /// Max number of points. Default is 3. + pub(crate) limit: Option>, + /// Maximum amount of points to return per group. Default to 10. + pub(crate) group_size: Option>, + /// Payload field to group by, must be a string or number field. If there are multiple values for the field, all of them will be used. One point can be in multiple groups. + pub(crate) group_by: Option, + /// Options for specifying read consistency guarantees + pub(crate) read_consistency: Option>, + /// Options for specifying how to use the group id to lookup points in another collection + pub(crate) with_lookup: Option>, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, + /// Specify in which shards to look for the points, if not specified - look in all shards + pub(crate) shard_key_selector: Option>, +} + +impl QueryPointGroupsBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Sub-requests to perform first. If present, the query will be performed on the results of the prefetches. + #[allow(unused_mut)] + pub fn prefetch>>(self, value: VALUE) -> Self { + let mut new = self; + new.prefetch = Option::Some(value.into()); + new + } + /// Query to perform. If missing, returns points ordered by their IDs. + #[allow(unused_mut)] + pub fn query>(self, value: VALUE) -> Self { + let mut new = self; + new.query = Option::Some(Option::Some(value.into())); + new + } + /// Define which vector to use for querying. If missing, the default vector is used. + #[allow(unused_mut)] + pub fn using>(self, value: VALUE) -> Self { + let mut new = self; + new.using = Option::Some(Option::Some(value.into())); + new + } + /// Filter conditions - return only those points that satisfy the specified conditions. + #[allow(unused_mut)] + pub fn filter>(self, value: VALUE) -> Self { + let mut new = self; + new.filter = Option::Some(Option::Some(value.into())); + new + } + /// Search params for when there is no prefetch. + #[allow(unused_mut)] + pub fn params>(self, value: VALUE) -> Self { + let mut new = self; + new.params = Option::Some(Option::Some(value.into())); + new + } + /// Return points with scores better than this threshold. + #[allow(unused_mut)] + pub fn score_threshold>(self, value: VALUE) -> Self { + let mut new = self; + new.score_threshold = Option::Some(Option::Some(value.into())); + new + } + /// Options for specifying which payload to include or not + #[allow(unused_mut)] + pub fn with_payload>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_payload = Option::Some(Option::Some(value.into())); + new + } + /// Options for specifying which vectors to include into response + #[allow(unused_mut)] + pub fn with_vectors>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_vectors = Option::Some(Option::Some(value.into())); + new + } + /// The location to use for IDs lookup, if not specified - use the current collection and the 'using' vector + #[allow(unused_mut)] + pub fn lookup_from>(self, value: VALUE) -> Self { + let mut new = self; + new.lookup_from = Option::Some(Option::Some(value.into())); + new + } + /// Max number of points. Default is 3. + #[allow(unused_mut)] + pub fn limit>(self, value: VALUE) -> Self { + let mut new = self; + new.limit = Option::Some(Option::Some(value.into())); + new + } + /// Maximum amount of points to return per group. Default to 10. + #[allow(unused_mut)] + pub fn group_size>(self, value: VALUE) -> Self { + let mut new = self; + new.group_size = Option::Some(Option::Some(value.into())); + new + } + /// Payload field to group by, must be a string or number field. If there are multiple values for the field, all of them will be used. One point can be in multiple groups. + #[allow(unused_mut)] + pub fn group_by(self, value: String) -> Self { + let mut new = self; + new.group_by = Option::Some(value); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(Option::Some(value.into())); + new + } + /// Options for specifying how to use the group id to lookup points in another collection + #[allow(unused_mut)] + pub fn with_lookup>(self, value: VALUE) -> Self { + let mut new = self; + new.with_lookup = Option::Some(Option::Some(value.into())); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout>(self, value: VALUE) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value.into())); + new + } + /// Specify in which shards to look for the points, if not specified - look in all shards + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(QueryPointGroups { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + prefetch: self.prefetch.unwrap_or_default(), + query: self.query.unwrap_or_default(), + using: self.using.unwrap_or_default(), + filter: self.filter.unwrap_or_default(), + params: self.params.unwrap_or_default(), + score_threshold: self.score_threshold.unwrap_or_default(), + with_payload: self.with_payload.unwrap_or_default(), + with_vectors: self.with_vectors.unwrap_or_default(), + lookup_from: self.lookup_from.unwrap_or_default(), + limit: self.limit.unwrap_or_default(), + group_size: self.group_size.unwrap_or_default(), + group_by: match self.group_by { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("group_by"), + )); + } + }, + read_consistency: self.read_consistency.unwrap_or_default(), + with_lookup: self.with_lookup.unwrap_or_default(), + timeout: self.timeout.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + prefetch: core::default::Default::default(), + query: core::default::Default::default(), + using: core::default::Default::default(), + filter: core::default::Default::default(), + params: core::default::Default::default(), + score_threshold: core::default::Default::default(), + with_payload: core::default::Default::default(), + with_vectors: core::default::Default::default(), + lookup_from: core::default::Default::default(), + limit: core::default::Default::default(), + group_size: core::default::Default::default(), + group_by: core::default::Default::default(), + read_consistency: core::default::Default::default(), + with_lookup: core::default::Default::default(), + timeout: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + } + } +} + +impl From for QueryPointGroups { + fn from(value: QueryPointGroupsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "QueryPointGroupsBuilder", "QueryPointGroups" + ) + }) + } +} + +impl QueryPointGroupsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> QueryPointGroups { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "QueryPointGroupsBuilder", "QueryPointGroups" + ) + }) + } +} + +impl QueryPointGroupsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for QueryPointGroupsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum QueryPointGroupsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for QueryPointGroupsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for QueryPointGroupsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for QueryPointGroupsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for QueryPointGroupsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/query_points_builder.rs b/src/builders/query_points_builder.rs new file mode 100644 index 00000000..19b0f33d --- /dev/null +++ b/src/builders/query_points_builder.rs @@ -0,0 +1,270 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct QueryPointsBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// Sub-requests to perform first. If present, the query will be performed on the results of the prefetches. + pub(crate) prefetch: Option>, + /// Query to perform. If missing, returns points ordered by their IDs. + pub(crate) query: Option>, + /// Define which vector to use for querying. If missing, the default vector is used. + pub(crate) using: Option>, + /// Filter conditions - return only those points that satisfy the specified conditions. + pub(crate) filter: Option>, + /// Search params for when there is no prefetch. + pub(crate) params: Option>, + /// Return points with scores better than this threshold. + pub(crate) score_threshold: Option>, + /// Max number of points. Default is 10. + pub(crate) limit: Option>, + /// Offset of the result. Skip this many points. Default is 0. + pub(crate) offset: Option>, + /// Options for specifying which vectors to include into the response. + with_vectors: Option, + /// Options for specifying which payload to include or not. + with_payload: Option, + /// Options for specifying read consistency guarantees. + read_consistency: Option, + /// Specify in which shards to look for the points, if not specified - look in all shards. + pub(crate) shard_key_selector: Option>, + /// The location to use for IDs lookup, if not specified - use the current collection and the 'using' vector + pub(crate) lookup_from: Option>, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, +} + +impl QueryPointsBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Sub-requests to perform first. If present, the query will be performed on the results of the prefetches. + #[allow(unused_mut)] + pub fn prefetch>>(self, value: VALUE) -> Self { + let mut new = self; + new.prefetch = Option::Some(value.into()); + new + } + /// Query to perform. If missing, returns points ordered by their IDs. + #[allow(unused_mut)] + pub fn query>(self, value: VALUE) -> Self { + let mut new = self; + new.query = Option::Some(Option::Some(value.into())); + new + } + /// Define which vector to use for querying. If missing, the default vector is used. + #[allow(unused_mut)] + pub fn using>(self, value: VALUE) -> Self { + let mut new = self; + new.using = Option::Some(Option::Some(value.into())); + new + } + /// Filter conditions - return only those points that satisfy the specified conditions. + #[allow(unused_mut)] + pub fn filter>(self, value: VALUE) -> Self { + let mut new = self; + new.filter = Option::Some(Option::Some(value.into())); + new + } + /// Search params for when there is no prefetch. + #[allow(unused_mut)] + pub fn params>(self, value: VALUE) -> Self { + let mut new = self; + new.params = Option::Some(Option::Some(value.into())); + new + } + /// Return points with scores better than this threshold. + #[allow(unused_mut)] + pub fn score_threshold>(self, value: VALUE) -> Self { + let mut new = self; + new.score_threshold = Option::Some(Option::Some(value.into())); + new + } + /// Max number of points. Default is 10. + #[allow(unused_mut)] + pub fn limit(self, value: u64) -> Self { + let mut new = self; + new.limit = Option::Some(Option::Some(value)); + new + } + /// Offset of the result. Skip this many points. Default is 0. + #[allow(unused_mut)] + pub fn offset(self, value: u64) -> Self { + let mut new = self; + new.offset = Option::Some(Option::Some(value)); + new + } + /// Options for specifying which vectors to include into the response. + #[allow(unused_mut)] + pub fn with_vectors>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_vectors = Option::Some(value.into()); + new + } + /// Options for specifying which payload to include or not. + #[allow(unused_mut)] + pub fn with_payload>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_payload = Option::Some(value.into()); + new + } + /// Options for specifying read consistency guarantees. + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(value.into()); + new + } + /// Specify in which shards to look for the points, if not specified - look in all shards. + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + /// The location to use for IDs lookup, if not specified - use the current collection and the 'using' vector + #[allow(unused_mut)] + pub fn lookup_from>(self, value: VALUE) -> Self { + let mut new = self; + new.lookup_from = Option::Some(Option::Some(value.into())); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(QueryPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + prefetch: self.prefetch.unwrap_or_default(), + query: self.query.unwrap_or_default(), + using: self.using.unwrap_or_default(), + filter: self.filter.unwrap_or_default(), + params: self.params.unwrap_or_default(), + score_threshold: self.score_threshold.unwrap_or_default(), + limit: self.limit.unwrap_or_default(), + offset: self.offset.unwrap_or_default(), + with_vectors: { convert_option(&self.with_vectors) }, + with_payload: { convert_option(&self.with_payload) }, + read_consistency: { convert_option(&self.read_consistency) }, + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + lookup_from: self.lookup_from.unwrap_or_default(), + timeout: self.timeout.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + prefetch: core::default::Default::default(), + query: core::default::Default::default(), + using: core::default::Default::default(), + filter: core::default::Default::default(), + params: core::default::Default::default(), + score_threshold: core::default::Default::default(), + limit: core::default::Default::default(), + offset: core::default::Default::default(), + with_vectors: core::default::Default::default(), + with_payload: core::default::Default::default(), + read_consistency: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + lookup_from: core::default::Default::default(), + timeout: core::default::Default::default(), + } + } +} + +impl From for QueryPoints { + fn from(value: QueryPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "QueryPointsBuilder", "QueryPoints" + ) + }) + } +} + +impl QueryPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> QueryPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "QueryPointsBuilder", "QueryPoints" + ) + }) + } +} + +impl QueryPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for QueryPointsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum QueryPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the From trait for conversion from UninitializedFieldError +impl From for QueryPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing the From trait for conversion from String +impl From for QueryPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for QueryPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for QueryPointsBuilderError {} diff --git a/src/builders/recommend_batch_points_builder.rs b/src/builders/recommend_batch_points_builder.rs new file mode 100644 index 00000000..4f518264 --- /dev/null +++ b/src/builders/recommend_batch_points_builder.rs @@ -0,0 +1,145 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct RecommendBatchPointsBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + pub(crate) recommend_points: Option>, + /// Options for specifying read consistency guarantees + read_consistency: Option, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, +} + +impl RecommendBatchPointsBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + #[allow(unused_mut)] + pub fn recommend_points(self, value: Vec) -> Self { + let mut new = self; + new.recommend_points = Option::Some(value); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(value.into()); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(RecommendBatchPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + recommend_points: match self.recommend_points { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("recommend_points"), + )); + } + }, + read_consistency: { convert_option(&self.read_consistency) }, + timeout: self.timeout.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + recommend_points: core::default::Default::default(), + read_consistency: core::default::Default::default(), + timeout: core::default::Default::default(), + } + } +} + +impl From for RecommendBatchPoints { + fn from(value: RecommendBatchPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "RecommendBatchPointsBuilder", "RecommendBatchPoints" + ) + }) + } +} + +impl RecommendBatchPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> RecommendBatchPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "RecommendBatchPointsBuilder", "RecommendBatchPoints" + ) + }) + } +} + +impl RecommendBatchPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for RecommendBatchPointsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum RecommendBatchPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for RecommendBatchPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for RecommendBatchPointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for RecommendBatchPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for RecommendBatchPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/recommend_input_builder.rs b/src/builders/recommend_input_builder.rs new file mode 100644 index 00000000..d267f711 --- /dev/null +++ b/src/builders/recommend_input_builder.rs @@ -0,0 +1,79 @@ +use crate::qdrant::*; + +pub struct RecommendInputBuilder { + /// Look for vectors closest to the vectors from these points + pub(crate) positive: Option>, + /// Try to avoid vectors like the vector from these points + pub(crate) negative: Option>, + /// How to use the provided vectors to find the results + pub(crate) strategy: Option>, +} + +impl RecommendInputBuilder { + /// Look for vectors closest to the vectors from these points + #[allow(unused_mut)] + pub fn positive>>(self, value: VALUE) -> Self { + let mut new = self; + new.positive = Option::Some(value.into()); + new + } + /// Try to avoid vectors like the vector from these points + #[allow(unused_mut)] + pub fn negative>>(self, value: VALUE) -> Self { + let mut new = self; + new.negative = Option::Some(value.into()); + new + } + /// How to use the provided vectors to find the results + #[allow(unused_mut)] + pub fn strategy>(self, value: VALUE) -> Self { + let mut new = self; + new.strategy = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(RecommendInput { + positive: self.positive.unwrap_or_default(), + negative: self.negative.unwrap_or_default(), + strategy: self.strategy.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + positive: core::default::Default::default(), + negative: core::default::Default::default(), + strategy: core::default::Default::default(), + } + } +} + +impl From for RecommendInput { + fn from(value: RecommendInputBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "RecommendInputBuilder", "RecommendInput" + ) + }) + } +} + +impl RecommendInputBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> RecommendInput { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "RecommendInputBuilder", "RecommendInput" + ) + }) + } +} + +impl Default for RecommendInputBuilder { + fn default() -> Self { + Self::create_empty() + } +} diff --git a/src/builders/recommend_point_groups_builder.rs b/src/builders/recommend_point_groups_builder.rs new file mode 100644 index 00000000..7ddd47d5 --- /dev/null +++ b/src/builders/recommend_point_groups_builder.rs @@ -0,0 +1,318 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct RecommendPointGroupsBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// Look for vectors closest to the vectors from these points + pub(crate) positive: Option>, + /// Try to avoid vectors like the vector from these points + pub(crate) negative: Option>, + /// Filter conditions - return only those points that satisfy the specified conditions + pub(crate) filter: Option>, + /// Max number of groups in result + pub(crate) limit: Option, + /// Options for specifying which payload to include or not + with_payload: Option, + /// Search config + pub(crate) params: Option>, + /// If provided - cut off results with worse scores + pub(crate) score_threshold: Option>, + /// Define which vector to use for recommendation, if not specified - default vector + pub(crate) using: Option>, + /// Options for specifying which vectors to include into response + with_vectors: Option, + /// Name of the collection to use for points lookup, if not specified - use current collection + pub(crate) lookup_from: Option>, + /// Payload field to group by, must be a string or number field. If there are multiple values for the field, all of them will be used. One point can be in multiple groups. + pub(crate) group_by: Option, + /// Maximum amount of points to return per group + pub(crate) group_size: Option, + /// Options for specifying read consistency guarantees + read_consistency: Option, + /// Options for specifying how to use the group id to lookup points in another collection + pub(crate) with_lookup: Option>, + /// How to use the example vectors to find the results + pub(crate) strategy: Option>, + /// Look for vectors closest to those + pub(crate) positive_vectors: Option>, + /// Try to avoid vectors like this + pub(crate) negative_vectors: Option>, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, + /// Specify in which shards to look for the points, if not specified - look in all shards + pub(crate) shard_key_selector: Option>, +} + +impl RecommendPointGroupsBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Filter conditions - return only those points that satisfy the specified conditions + #[allow(unused_mut)] + pub fn filter>(self, value: VALUE) -> Self { + let mut new = self; + new.filter = Option::Some(Option::Some(value.into())); + new + } + /// Max number of groups in result + #[allow(unused_mut)] + pub fn limit(self, value: u32) -> Self { + let mut new = self; + new.limit = Option::Some(value); + new + } + /// Options for specifying which payload to include or not + #[allow(unused_mut)] + pub fn with_payload>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_payload = Option::Some(value.into()); + new + } + /// Search config + #[allow(unused_mut)] + pub fn params>(self, value: VALUE) -> Self { + let mut new = self; + new.params = Option::Some(Option::Some(value.into())); + new + } + /// If provided - cut off results with worse scores + #[allow(unused_mut)] + pub fn score_threshold(self, value: f32) -> Self { + let mut new = self; + new.score_threshold = Option::Some(Option::Some(value)); + new + } + /// Define which vector to use for recommendation, if not specified - default vector + #[allow(unused_mut)] + pub fn using>(self, value: VALUE) -> Self { + let mut new = self; + new.using = Option::Some(Option::Some(value.into())); + new + } + /// Options for specifying which vectors to include into response + #[allow(unused_mut)] + pub fn with_vectors>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_vectors = Option::Some(value.into()); + new + } + /// Name of the collection to use for points lookup, if not specified - use current collection + #[allow(unused_mut)] + pub fn lookup_from>(self, value: VALUE) -> Self { + let mut new = self; + new.lookup_from = Option::Some(Option::Some(value.into())); + new + } + /// Payload field to group by, must be a string or number field. If there are multiple values for the field, all of them will be used. One point can be in multiple groups. + #[allow(unused_mut)] + pub fn group_by(self, value: String) -> Self { + let mut new = self; + new.group_by = Option::Some(value); + new + } + /// Maximum amount of points to return per group + #[allow(unused_mut)] + pub fn group_size(self, value: u32) -> Self { + let mut new = self; + new.group_size = Option::Some(value); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(value.into()); + new + } + /// Options for specifying how to use the group id to lookup points in another collection + #[allow(unused_mut)] + pub fn with_lookup>(self, value: VALUE) -> Self { + let mut new = self; + new.with_lookup = Option::Some(Option::Some(value.into())); + new + } + /// How to use the example vectors to find the results + #[allow(unused_mut)] + pub fn strategy>(self, value: VALUE) -> Self { + let mut new = self; + new.strategy = Option::Some(Option::Some(value.into())); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + /// Specify in which shards to look for the points, if not specified - look in all shards + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(RecommendPointGroups { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + positive: self.positive.unwrap_or_default(), + negative: self.negative.unwrap_or_default(), + filter: self.filter.unwrap_or_default(), + limit: match self.limit { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("limit"), + )); + } + }, + with_payload: { convert_option(&self.with_payload) }, + params: self.params.unwrap_or_default(), + score_threshold: self.score_threshold.unwrap_or_default(), + using: self.using.unwrap_or_default(), + with_vectors: { convert_option(&self.with_vectors) }, + lookup_from: self.lookup_from.unwrap_or_default(), + group_by: match self.group_by { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("group_by"), + )); + } + }, + group_size: match self.group_size { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("group_size"), + )); + } + }, + read_consistency: { convert_option(&self.read_consistency) }, + with_lookup: self.with_lookup.unwrap_or_default(), + strategy: self.strategy.unwrap_or_default(), + positive_vectors: self.positive_vectors.unwrap_or_default(), + negative_vectors: self.negative_vectors.unwrap_or_default(), + timeout: self.timeout.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + positive: core::default::Default::default(), + negative: core::default::Default::default(), + filter: core::default::Default::default(), + limit: core::default::Default::default(), + with_payload: core::default::Default::default(), + params: core::default::Default::default(), + score_threshold: core::default::Default::default(), + using: core::default::Default::default(), + with_vectors: core::default::Default::default(), + lookup_from: core::default::Default::default(), + group_by: core::default::Default::default(), + group_size: core::default::Default::default(), + read_consistency: core::default::Default::default(), + with_lookup: core::default::Default::default(), + strategy: core::default::Default::default(), + positive_vectors: core::default::Default::default(), + negative_vectors: core::default::Default::default(), + timeout: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + } + } +} + +impl From for RecommendPointGroups { + fn from(value: RecommendPointGroupsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "RecommendPointGroupsBuilder", "RecommendPointGroups" + ) + }) + } +} + +impl RecommendPointGroupsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> RecommendPointGroups { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "RecommendPointGroupsBuilder", "RecommendPointGroups" + ) + }) + } +} + +impl RecommendPointGroupsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for RecommendPointGroupsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum RecommendPointGroupsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for RecommendPointGroupsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for RecommendPointGroupsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for RecommendPointGroupsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for RecommendPointGroupsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/recommend_points_builder.rs b/src/builders/recommend_points_builder.rs new file mode 100644 index 00000000..77d7dd20 --- /dev/null +++ b/src/builders/recommend_points_builder.rs @@ -0,0 +1,282 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct RecommendPointsBuilder { + /// name of the collection + pub(crate) collection_name: Option, + /// Look for vectors closest to the vectors from these points + pub(crate) positive: Option>, + /// Try to avoid vectors like the vector from these points + pub(crate) negative: Option>, + /// Filter conditions - return only those points that satisfy the specified conditions + pub(crate) filter: Option>, + /// Max number of result + pub(crate) limit: Option, + /// Options for specifying which payload to include or not + with_payload: Option, + /// Search config + pub(crate) params: Option>, + /// If provided - cut off results with worse scores + pub(crate) score_threshold: Option>, + /// Offset of the result + pub(crate) offset: Option>, + /// Define which vector to use for recommendation, if not specified - default vector + pub(crate) using: Option>, + /// Options for specifying which vectors to include into response + with_vectors: Option, + /// Name of the collection to use for points lookup, if not specified - use current collection + pub(crate) lookup_from: Option>, + /// Options for specifying read consistency guarantees + read_consistency: Option, + /// How to use the example vectors to find the results + pub(crate) strategy: Option>, + /// Look for vectors closest to those + pub(crate) positive_vectors: Option>, + /// Try to avoid vectors like this + pub(crate) negative_vectors: Option>, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, + /// Specify in which shards to look for the points, if not specified - look in all shards + pub(crate) shard_key_selector: Option>, +} + +impl RecommendPointsBuilder { + /// name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Filter conditions - return only those points that satisfy the specified conditions + #[allow(unused_mut)] + pub fn filter>(self, value: VALUE) -> Self { + let mut new = self; + new.filter = Option::Some(Option::Some(value.into())); + new + } + /// Max number of result + #[allow(unused_mut)] + pub fn limit(self, value: u64) -> Self { + let mut new = self; + new.limit = Option::Some(value); + new + } + /// Options for specifying which payload to include or not + #[allow(unused_mut)] + pub fn with_payload>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_payload = Option::Some(value.into()); + new + } + /// Search config + #[allow(unused_mut)] + pub fn params>(self, value: VALUE) -> Self { + let mut new = self; + new.params = Option::Some(Option::Some(value.into())); + new + } + /// If provided - cut off results with worse scores + #[allow(unused_mut)] + pub fn score_threshold(self, value: f32) -> Self { + let mut new = self; + new.score_threshold = Option::Some(Option::Some(value)); + new + } + /// Offset of the result + #[allow(unused_mut)] + pub fn offset(self, value: u64) -> Self { + let mut new = self; + new.offset = Option::Some(Option::Some(value)); + new + } + /// Define which vector to use for recommendation, if not specified - default vector + #[allow(unused_mut)] + pub fn using>(self, value: VALUE) -> Self { + let mut new = self; + new.using = Option::Some(Option::Some(value.into())); + new + } + /// Options for specifying which vectors to include into response + #[allow(unused_mut)] + pub fn with_vectors>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_vectors = Option::Some(value.into()); + new + } + /// Name of the collection to use for points lookup, if not specified - use current collection + #[allow(unused_mut)] + pub fn lookup_from>(self, value: VALUE) -> Self { + let mut new = self; + new.lookup_from = Option::Some(Option::Some(value.into())); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(value.into()); + new + } + /// How to use the example vectors to find the results + #[allow(unused_mut)] + pub fn strategy>(self, value: VALUE) -> Self { + let mut new = self; + new.strategy = Option::Some(Option::Some(value.into())); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + /// Specify in which shards to look for the points, if not specified - look in all shards + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(RecommendPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + positive: self.positive.unwrap_or_default(), + negative: self.negative.unwrap_or_default(), + filter: self.filter.unwrap_or_default(), + limit: match self.limit { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("limit"), + )); + } + }, + with_payload: { convert_option(&self.with_payload) }, + params: self.params.unwrap_or_default(), + score_threshold: self.score_threshold.unwrap_or_default(), + offset: self.offset.unwrap_or_default(), + using: self.using.unwrap_or_default(), + with_vectors: { convert_option(&self.with_vectors) }, + lookup_from: self.lookup_from.unwrap_or_default(), + read_consistency: { convert_option(&self.read_consistency) }, + strategy: self.strategy.unwrap_or_default(), + positive_vectors: self.positive_vectors.unwrap_or_default(), + negative_vectors: self.negative_vectors.unwrap_or_default(), + timeout: self.timeout.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + positive: core::default::Default::default(), + negative: core::default::Default::default(), + filter: core::default::Default::default(), + limit: core::default::Default::default(), + with_payload: core::default::Default::default(), + params: core::default::Default::default(), + score_threshold: core::default::Default::default(), + offset: core::default::Default::default(), + using: core::default::Default::default(), + with_vectors: core::default::Default::default(), + lookup_from: core::default::Default::default(), + read_consistency: core::default::Default::default(), + strategy: core::default::Default::default(), + positive_vectors: core::default::Default::default(), + negative_vectors: core::default::Default::default(), + timeout: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + } + } +} + +impl From for RecommendPoints { + fn from(value: RecommendPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "RecommendPointsBuilder", "RecommendPoints" + ) + }) + } +} + +impl RecommendPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> RecommendPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "RecommendPointsBuilder", "RecommendPoints" + ) + }) + } +} + +impl RecommendPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for RecommendPointsBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum RecommendPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for RecommendPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for RecommendPointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for RecommendPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for RecommendPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/rename_alias_builder.rs b/src/builders/rename_alias_builder.rs new file mode 100644 index 00000000..9626ed6e --- /dev/null +++ b/src/builders/rename_alias_builder.rs @@ -0,0 +1,121 @@ +use crate::qdrant::*; + +pub struct RenameAliasBuilder { + /// Name of the alias to rename + pub(crate) old_alias_name: Option, + /// Name of the alias + pub(crate) new_alias_name: Option, +} + +impl RenameAliasBuilder { + /// Name of the alias to rename + #[allow(unused_mut)] + pub fn old_alias_name(self, value: String) -> Self { + let mut new = self; + new.old_alias_name = Option::Some(value); + new + } + /// Name of the alias + #[allow(unused_mut)] + pub fn new_alias_name(self, value: String) -> Self { + let mut new = self; + new.new_alias_name = Option::Some(value); + new + } + + fn build_inner(self) -> Result { + Ok(RenameAlias { + old_alias_name: match self.old_alias_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("old_alias_name"), + )); + } + }, + new_alias_name: match self.new_alias_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("new_alias_name"), + )); + } + }, + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + old_alias_name: core::default::Default::default(), + new_alias_name: core::default::Default::default(), + } + } +} + +impl From for RenameAlias { + fn from(value: RenameAliasBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "RenameAliasBuilder", "RenameAlias" + ) + }) + } +} + +impl RenameAliasBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> RenameAlias { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "RenameAliasBuilder", "RenameAlias" + ) + }) + } +} + +impl RenameAliasBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for RenameAliasBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum RenameAliasBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for RenameAliasBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for RenameAliasBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for RenameAliasBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for RenameAliasBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/replica_builder.rs b/src/builders/replica_builder.rs new file mode 100644 index 00000000..f7deb395 --- /dev/null +++ b/src/builders/replica_builder.rs @@ -0,0 +1,110 @@ +use crate::qdrant::*; + +pub struct ReplicaBuilder { + pub(crate) shard_id: Option, + pub(crate) peer_id: Option, +} + +impl ReplicaBuilder { + #[allow(unused_mut)] + pub fn shard_id(self, value: u32) -> Self { + let mut new = self; + new.shard_id = Option::Some(value); + new + } + #[allow(unused_mut)] + pub fn peer_id(self, value: u64) -> Self { + let mut new = self; + new.peer_id = Option::Some(value); + new + } + + fn build_inner(self) -> Result { + Ok(Replica { + shard_id: match self.shard_id { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("shard_id"), + )); + } + }, + peer_id: match self.peer_id { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("peer_id"), + )); + } + }, + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + shard_id: core::default::Default::default(), + peer_id: core::default::Default::default(), + } + } +} + +impl From for Replica { + fn from(value: ReplicaBuilder) -> Self { + value + .build_inner() + .unwrap_or_else(|_| panic!("Failed to convert {0} to {1}", "ReplicaBuilder", "Replica")) + } +} + +impl ReplicaBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> Replica { + self.build_inner() + .unwrap_or_else(|_| panic!("Failed to build {0} into {1}", "ReplicaBuilder", "Replica")) + } +} + +impl ReplicaBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +/// Error type for ReplicaBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum ReplicaBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for ReplicaBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for ReplicaBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for ReplicaBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for ReplicaBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/replicate_shard_builder.rs b/src/builders/replicate_shard_builder.rs new file mode 100644 index 00000000..5867cfe7 --- /dev/null +++ b/src/builders/replicate_shard_builder.rs @@ -0,0 +1,145 @@ +use crate::qdrant::*; + +pub struct ReplicateShardBuilder { + /// Local shard id + pub(crate) shard_id: Option, + pub(crate) to_shard_id: Option>, + pub(crate) from_peer_id: Option, + pub(crate) to_peer_id: Option, + pub(crate) method: Option>, +} + +impl ReplicateShardBuilder { + /// Local shard id + #[allow(unused_mut)] + pub fn shard_id(self, value: u32) -> Self { + let mut new = self; + new.shard_id = Option::Some(value); + new + } + #[allow(unused_mut)] + pub fn to_shard_id(self, value: u32) -> Self { + let mut new = self; + new.to_shard_id = Option::Some(Option::Some(value)); + new + } + #[allow(unused_mut)] + pub fn from_peer_id(self, value: u64) -> Self { + let mut new = self; + new.from_peer_id = Option::Some(value); + new + } + #[allow(unused_mut)] + pub fn to_peer_id(self, value: u64) -> Self { + let mut new = self; + new.to_peer_id = Option::Some(value); + new + } + #[allow(unused_mut)] + pub fn method>(self, value: VALUE) -> Self { + let mut new = self; + new.method = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(ReplicateShard { + shard_id: match self.shard_id { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("shard_id"), + )); + } + }, + to_shard_id: self.to_shard_id.unwrap_or_default(), + from_peer_id: match self.from_peer_id { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("from_peer_id"), + )); + } + }, + to_peer_id: match self.to_peer_id { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("to_peer_id"), + )); + } + }, + method: self.method.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + shard_id: core::default::Default::default(), + to_shard_id: core::default::Default::default(), + from_peer_id: core::default::Default::default(), + to_peer_id: core::default::Default::default(), + method: core::default::Default::default(), + } + } +} + +impl From for ReplicateShard { + fn from(value: ReplicateShardBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "ReplicateShardBuilder", "ReplicateShard" + ) + }) + } +} + +impl ReplicateShardBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> ReplicateShard { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "ReplicateShardBuilder", "ReplicateShard" + ) + }) + } +} + +impl ReplicateShardBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +///Error type for ReplicateShardBuilder +#[non_exhaustive] +#[derive(Debug)] +pub enum ReplicateShardBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} +impl From for ReplicateShardBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} +impl From for ReplicateShardBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} +impl std::fmt::Display for ReplicateShardBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> ::derive_builder::export::core::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} +impl std::error::Error for ReplicateShardBuilderError {} diff --git a/src/builders/scalar_quantization_builder.rs b/src/builders/scalar_quantization_builder.rs new file mode 100644 index 00000000..e1cb8112 --- /dev/null +++ b/src/builders/scalar_quantization_builder.rs @@ -0,0 +1,124 @@ +use crate::qdrant::*; + +pub struct ScalarQuantizationBuilder { + /// Type of quantization + pub(crate) r#type: Option, + /// Number of bits to use for quantization + pub(crate) quantile: Option>, + /// If true - quantized vectors always will be stored in RAM, ignoring the config of main storage + pub(crate) always_ram: Option>, +} + +impl ScalarQuantizationBuilder { + /// Type of quantization + #[allow(unused_mut)] + pub fn r#type(self, value: i32) -> Self { + let mut new = self; + new.r#type = Option::Some(value); + new + } + /// Number of bits to use for quantization + #[allow(unused_mut)] + pub fn quantile(self, value: f32) -> Self { + let mut new = self; + new.quantile = Option::Some(Option::Some(value)); + new + } + /// If true - quantized vectors always will be stored in RAM, ignoring the config of main storage + #[allow(unused_mut)] + pub fn always_ram(self, value: bool) -> Self { + let mut new = self; + new.always_ram = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(ScalarQuantization { + r#type: match self.r#type { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("r#type"), + )); + } + }, + quantile: self.quantile.unwrap_or_default(), + always_ram: self.always_ram.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + r#type: core::default::Default::default(), + quantile: core::default::Default::default(), + always_ram: core::default::Default::default(), + } + } +} + +impl From for ScalarQuantization { + fn from(value: ScalarQuantizationBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "ScalarQuantizationBuilder", "ScalarQuantization" + ) + }) + } +} + +impl ScalarQuantizationBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> ScalarQuantization { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "ScalarQuantizationBuilder", "ScalarQuantization" + ) + }) + } +} + +impl ScalarQuantizationBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +#[non_exhaustive] +#[derive(Debug)] +pub enum ScalarQuantizationBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for ScalarQuantizationBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for ScalarQuantizationBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for ScalarQuantizationBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for ScalarQuantizationBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/scroll_points_builder.rs b/src/builders/scroll_points_builder.rs new file mode 100644 index 00000000..8e0dd99c --- /dev/null +++ b/src/builders/scroll_points_builder.rs @@ -0,0 +1,212 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct ScrollPointsBuilder { + pub(crate) collection_name: Option, + /// Filter conditions - return only those points that satisfy the specified conditions + pub(crate) filter: Option>, + /// Start with this ID + pub(crate) offset: Option>, + /// Max number of result + pub(crate) limit: Option>, + /// Options for specifying which payload to include or not + with_payload: Option, + /// Options for specifying which vectors to include into response + with_vectors: Option, + /// Options for specifying read consistency guarantees + read_consistency: Option, + /// Specify in which shards to look for the points, if not specified - look in all shards + pub(crate) shard_key_selector: Option>, + /// Order the records by a payload field + pub(crate) order_by: Option>, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, +} + +impl ScrollPointsBuilder { + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Filter conditions - return only those points that satisfy the specified conditions + #[allow(unused_mut)] + pub fn filter>(self, value: VALUE) -> Self { + let mut new = self; + new.filter = Option::Some(Option::Some(value.into())); + new + } + /// Start with this ID + #[allow(unused_mut)] + pub fn offset>(self, value: VALUE) -> Self { + let mut new = self; + new.offset = Option::Some(Option::Some(value.into())); + new + } + /// Max number of result + #[allow(unused_mut)] + pub fn limit(self, value: u32) -> Self { + let mut new = self; + new.limit = Option::Some(Option::Some(value)); + new + } + /// Options for specifying which payload to include or not + #[allow(unused_mut)] + pub fn with_payload>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_payload = Option::Some(value.into()); + new + } + /// Options for specifying which vectors to include into response + #[allow(unused_mut)] + pub fn with_vectors>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_vectors = Option::Some(value.into()); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(value.into()); + new + } + /// Specify in which shards to look for the points, if not specified - look in all shards + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + /// Order the records by a payload field + #[allow(unused_mut)] + pub fn order_by>(self, value: VALUE) -> Self { + let mut new = self; + new.order_by = Option::Some(Option::Some(value.into())); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(ScrollPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + filter: self.filter.unwrap_or_default(), + offset: self.offset.unwrap_or_default(), + limit: self.limit.unwrap_or_default(), + with_payload: { convert_option(&self.with_payload) }, + with_vectors: { convert_option(&self.with_vectors) }, + read_consistency: { convert_option(&self.read_consistency) }, + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + order_by: self.order_by.unwrap_or_default(), + timeout: self.timeout.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + filter: core::default::Default::default(), + offset: core::default::Default::default(), + limit: core::default::Default::default(), + with_payload: core::default::Default::default(), + with_vectors: core::default::Default::default(), + read_consistency: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + order_by: core::default::Default::default(), + timeout: core::default::Default::default(), + } + } +} + +impl From for ScrollPoints { + fn from(value: ScrollPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "ScrollPointsBuilder", "ScrollPoints" + ) + }) + } +} + +impl ScrollPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> ScrollPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "ScrollPointsBuilder", "ScrollPoints" + ) + }) + } +} + +impl ScrollPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +#[non_exhaustive] +#[derive(Debug)] +pub enum ScrollPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for ScrollPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for ScrollPointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for ScrollPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for ScrollPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/search_batch_points_builder.rs b/src/builders/search_batch_points_builder.rs new file mode 100644 index 00000000..1bcb2560 --- /dev/null +++ b/src/builders/search_batch_points_builder.rs @@ -0,0 +1,144 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct SearchBatchPointsBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + pub(crate) search_points: Option>, + /// Options for specifying read consistency guarantees + read_consistency: Option, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, +} + +impl SearchBatchPointsBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + #[allow(unused_mut)] + pub fn search_points(self, value: Vec) -> Self { + let mut new = self; + new.search_points = Option::Some(value); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(value.into()); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(SearchBatchPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + search_points: match self.search_points { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("search_points"), + )); + } + }, + read_consistency: { convert_option(&self.read_consistency) }, + timeout: self.timeout.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + search_points: core::default::Default::default(), + read_consistency: core::default::Default::default(), + timeout: core::default::Default::default(), + } + } +} + +impl From for SearchBatchPoints { + fn from(value: SearchBatchPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "SearchBatchPointsBuilder", "SearchBatchPoints" + ) + }) + } +} + +impl SearchBatchPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> SearchBatchPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "SearchBatchPointsBuilder", "SearchBatchPoints" + ) + }) + } +} + +impl SearchBatchPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +#[non_exhaustive] +#[derive(Debug)] +pub enum SearchBatchPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for SearchBatchPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for SearchBatchPointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for SearchBatchPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for SearchBatchPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/search_matrix_points_builder.rs b/src/builders/search_matrix_points_builder.rs new file mode 100644 index 00000000..5be06bda --- /dev/null +++ b/src/builders/search_matrix_points_builder.rs @@ -0,0 +1,185 @@ +use crate::qdrant::*; + +pub struct SearchMatrixPointsBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// Filter conditions - return only those points that satisfy the specified conditions. + pub(crate) filter: Option>, + /// How many points to select and search within. Default is 10. + pub(crate) sample: Option>, + /// How many neighbours per sample to find. Default is 3. + pub(crate) limit: Option>, + /// Define which vector to use for querying. If missing, the default vector is is used. + pub(crate) using: Option>, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, + /// Options for specifying read consistency guarantees + pub(crate) read_consistency: Option>, + /// Specify in which shards to look for the points, if not specified - look in all shards + pub(crate) shard_key_selector: Option>, +} + +impl SearchMatrixPointsBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Filter conditions - return only those points that satisfy the specified conditions. + #[allow(unused_mut)] + pub fn filter>(self, value: VALUE) -> Self { + let mut new = self; + new.filter = Option::Some(Option::Some(value.into())); + new + } + /// How many points to select and search within. Default is 10. + #[allow(unused_mut)] + pub fn sample(self, value: u64) -> Self { + let mut new = self; + new.sample = Option::Some(Option::Some(value)); + new + } + /// How many neighbours per sample to find. Default is 3. + #[allow(unused_mut)] + pub fn limit(self, value: u64) -> Self { + let mut new = self; + new.limit = Option::Some(Option::Some(value)); + new + } + /// Define which vector to use for querying. If missing, the default vector is is used. + #[allow(unused_mut)] + pub fn using>(self, value: VALUE) -> Self { + let mut new = self; + new.using = Option::Some(Option::Some(value.into())); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(Option::Some(value.into())); + new + } + /// Specify in which shards to look for the points, if not specified - look in all shards + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(SearchMatrixPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + filter: self.filter.unwrap_or_default(), + sample: self.sample.unwrap_or_default(), + limit: self.limit.unwrap_or_default(), + using: self.using.unwrap_or_default(), + timeout: self.timeout.unwrap_or_default(), + read_consistency: self.read_consistency.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + filter: core::default::Default::default(), + sample: core::default::Default::default(), + limit: core::default::Default::default(), + using: core::default::Default::default(), + timeout: core::default::Default::default(), + read_consistency: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + } + } +} + +impl From for SearchMatrixPoints { + fn from(value: SearchMatrixPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "SearchMatrixPointsBuilder", "SearchMatrixPoints" + ) + }) + } +} + +impl SearchMatrixPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> SearchMatrixPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "SearchMatrixPointsBuilder", "SearchMatrixPoints" + ) + }) + } +} + +impl SearchMatrixPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +#[non_exhaustive] +#[derive(Debug)] +pub enum SearchMatrixPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for SearchMatrixPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for SearchMatrixPointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for SearchMatrixPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for SearchMatrixPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/search_params_builder.rs b/src/builders/search_params_builder.rs new file mode 100644 index 00000000..cc177dda --- /dev/null +++ b/src/builders/search_params_builder.rs @@ -0,0 +1,107 @@ +use crate::qdrant::*; + +pub struct SearchParamsBuilder { + /// + /// Params relevant to HNSW index. Size of the beam in a beam-search. + /// Larger the value - more accurate the result, more time required for search. + pub(crate) hnsw_ef: Option>, + /// + /// Search without approximation. If set to true, search may run long but with exact results. + pub(crate) exact: Option>, + /// + /// If set to true, search will ignore quantized vector data + pub(crate) quantization: Option>, + /// + /// If enabled, the engine will only perform search among indexed or small segments. + /// Using this option prevents slow searches in case of delayed index, but does not + /// guarantee that all uploaded vectors will be included in search results + pub(crate) indexed_only: Option>, +} + +impl SearchParamsBuilder { + /// + /// Params relevant to HNSW index. Size of the beam in a beam-search. + /// Larger the value - more accurate the result, more time required for search. + #[allow(unused_mut)] + pub fn hnsw_ef(self, value: u64) -> Self { + let mut new = self; + new.hnsw_ef = Option::Some(Option::Some(value)); + new + } + /// + /// Search without approximation. If set to true, search may run long but with exact results. + #[allow(unused_mut)] + pub fn exact(self, value: bool) -> Self { + let mut new = self; + new.exact = Option::Some(Option::Some(value)); + new + } + /// + /// If set to true, search will ignore quantized vector data + #[allow(unused_mut)] + pub fn quantization>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.quantization = Option::Some(Option::Some(value.into())); + new + } + /// + /// If enabled, the engine will only perform search among indexed or small segments. + /// Using this option prevents slow searches in case of delayed index, but does not + /// guarantee that all uploaded vectors will be included in search results + #[allow(unused_mut)] + pub fn indexed_only(self, value: bool) -> Self { + let mut new = self; + new.indexed_only = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(SearchParams { + hnsw_ef: self.hnsw_ef.unwrap_or_default(), + exact: self.exact.unwrap_or_default(), + quantization: self.quantization.unwrap_or_default(), + indexed_only: self.indexed_only.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + hnsw_ef: core::default::Default::default(), + exact: core::default::Default::default(), + quantization: core::default::Default::default(), + indexed_only: core::default::Default::default(), + } + } +} + +impl From for SearchParams { + fn from(value: SearchParamsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "SearchParamsBuilder", "SearchParams" + ) + }) + } +} + +impl SearchParamsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> SearchParams { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "SearchParamsBuilder", "SearchParams" + ) + }) + } +} + +impl Default for SearchParamsBuilder { + fn default() -> Self { + Self::create_empty() + } +} diff --git a/src/builders/search_point_groups_builder.rs b/src/builders/search_point_groups_builder.rs new file mode 100644 index 00000000..169fd64e --- /dev/null +++ b/src/builders/search_point_groups_builder.rs @@ -0,0 +1,308 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct SearchPointGroupsBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// Vector to compare against + pub(crate) vector: Option>, + /// Filter conditions - return only those points that satisfy the specified conditions + pub(crate) filter: Option>, + /// Max number of result + pub(crate) limit: Option, + /// Options for specifying which payload to include or not + with_payload: Option, + /// Search config + pub(crate) params: Option>, + /// If provided - cut off results with worse scores + pub(crate) score_threshold: Option>, + /// Which vector to use for search, if not specified - use default vector + pub(crate) vector_name: Option>, + /// Options for specifying which vectors to include into response + with_vectors: Option, + /// Payload field to group by, must be a string or number field. If there are multiple values for the field, all of them will be used. One point can be in multiple groups. + pub(crate) group_by: Option, + /// Maximum amount of points to return per group + pub(crate) group_size: Option, + /// Options for specifying read consistency guarantees + read_consistency: Option, + /// Options for specifying how to use the group id to lookup points in another collection + pub(crate) with_lookup: Option>, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, + /// Specify in which shards to look for the points, if not specified - look in all shards + pub(crate) shard_key_selector: Option>, + pub(crate) sparse_indices: Option>, +} + +impl SearchPointGroupsBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Vector to compare against + #[allow(unused_mut)] + pub fn vector(self, value: Vec) -> Self { + let mut new = self; + new.vector = Option::Some(value); + new + } + /// Filter conditions - return only those points that satisfy the specified conditions + #[allow(unused_mut)] + pub fn filter>(self, value: VALUE) -> Self { + let mut new = self; + new.filter = Option::Some(Option::Some(value.into())); + new + } + /// Max number of result + #[allow(unused_mut)] + pub fn limit(self, value: u32) -> Self { + let mut new = self; + new.limit = Option::Some(value); + new + } + /// Options for specifying which payload to include or not + #[allow(unused_mut)] + pub fn with_payload>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_payload = Option::Some(value.into()); + new + } + /// Search config + #[allow(unused_mut)] + pub fn params>(self, value: VALUE) -> Self { + let mut new = self; + new.params = Option::Some(Option::Some(value.into())); + new + } + /// If provided - cut off results with worse scores + #[allow(unused_mut)] + pub fn score_threshold>(self, value: VALUE) -> Self { + let mut new = self; + new.score_threshold = Option::Some(Option::Some(value.into())); + new + } + /// Which vector to use for search, if not specified - use default vector + #[allow(unused_mut)] + pub fn vector_name>(self, value: VALUE) -> Self { + let mut new = self; + new.vector_name = Option::Some(Option::Some(value.into())); + new + } + /// Options for specifying which vectors to include into response + #[allow(unused_mut)] + pub fn with_vectors>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_vectors = Option::Some(value.into()); + new + } + /// Payload field to group by, must be a string or number field. If there are multiple values for the field, all of them will be used. One point can be in multiple groups. + #[allow(unused_mut)] + pub fn group_by(self, value: String) -> Self { + let mut new = self; + new.group_by = Option::Some(value); + new + } + /// Maximum amount of points to return per group + #[allow(unused_mut)] + pub fn group_size(self, value: u32) -> Self { + let mut new = self; + new.group_size = Option::Some(value); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(value.into()); + new + } + /// Options for specifying how to use the group id to lookup points in another collection + #[allow(unused_mut)] + pub fn with_lookup>(self, value: VALUE) -> Self { + let mut new = self; + new.with_lookup = Option::Some(Option::Some(value.into())); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout>(self, value: VALUE) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value.into())); + new + } + /// Specify in which shards to look for the points, if not specified - look in all shards + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + #[allow(unused_mut)] + pub fn sparse_indices>(self, value: VALUE) -> Self { + let mut new = self; + new.sparse_indices = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(SearchPointGroups { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + vector: match self.vector { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("vector"), + )); + } + }, + filter: self.filter.unwrap_or_default(), + limit: match self.limit { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("limit"), + )); + } + }, + with_payload: { convert_option(&self.with_payload) }, + params: self.params.unwrap_or_default(), + score_threshold: self.score_threshold.unwrap_or_default(), + vector_name: self.vector_name.unwrap_or_default(), + with_vectors: { convert_option(&self.with_vectors) }, + group_by: match self.group_by { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("group_by"), + )); + } + }, + group_size: match self.group_size { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("group_size"), + )); + } + }, + read_consistency: { convert_option(&self.read_consistency) }, + with_lookup: self.with_lookup.unwrap_or_default(), + timeout: self.timeout.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + sparse_indices: self.sparse_indices.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + vector: core::default::Default::default(), + filter: core::default::Default::default(), + limit: core::default::Default::default(), + with_payload: core::default::Default::default(), + params: core::default::Default::default(), + score_threshold: core::default::Default::default(), + vector_name: core::default::Default::default(), + with_vectors: core::default::Default::default(), + group_by: core::default::Default::default(), + group_size: core::default::Default::default(), + read_consistency: core::default::Default::default(), + with_lookup: core::default::Default::default(), + timeout: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + sparse_indices: core::default::Default::default(), + } + } +} + +impl From for SearchPointGroups { + fn from(value: SearchPointGroupsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "SearchPointGroupsBuilder", "SearchPointGroups" + ) + }) + } +} + +impl SearchPointGroupsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> SearchPointGroups { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "SearchPointGroupsBuilder", "SearchPointGroups" + ) + }) + } +} + +impl SearchPointGroupsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +// src/builders/abort_shard_transfer_builder.rs + +#[non_exhaustive] +#[derive(Debug)] +pub enum SearchPointGroupsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for SearchPointGroupsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for SearchPointGroupsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for SearchPointGroupsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for SearchPointGroupsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/search_points_builder.rs b/src/builders/search_points_builder.rs new file mode 100644 index 00000000..cc870069 --- /dev/null +++ b/src/builders/search_points_builder.rs @@ -0,0 +1,270 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct SearchPointsBuilder { + /// name of the collection + pub(crate) collection_name: Option, + /// vector + pub(crate) vector: Option>, + /// Filter conditions - return only those points that satisfy the specified conditions + pub(crate) filter: Option>, + /// Max number of result + pub(crate) limit: Option, + /// Options for specifying which payload to include or not + with_payload: Option, + /// Search config + pub(crate) params: Option>, + /// If provided - cut off results with worse scores + pub(crate) score_threshold: Option>, + /// Offset of the result + pub(crate) offset: Option>, + /// Which vector to use for search, if not specified - use default vector + pub(crate) vector_name: Option>, + /// Options for specifying which vectors to include into response + with_vectors: Option, + /// Options for specifying read consistency guarantees + read_consistency: Option, + /// If set, overrides global timeout setting for this request. Unit is seconds. + pub(crate) timeout: Option>, + /// Specify in which shards to look for the points, if not specified - look in all shards + pub(crate) shard_key_selector: Option>, + pub(crate) sparse_indices: Option>, +} + +impl SearchPointsBuilder { + /// name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// vector + #[allow(unused_mut)] + pub fn vector(self, value: Vec) -> Self { + let mut new = self; + new.vector = Option::Some(value); + new + } + /// Filter conditions - return only those points that satisfy the specified conditions + #[allow(unused_mut)] + pub fn filter>(self, value: VALUE) -> Self { + let mut new = self; + new.filter = Option::Some(Option::Some(value.into())); + new + } + /// Max number of result + #[allow(unused_mut)] + pub fn limit(self, value: u64) -> Self { + let mut new = self; + new.limit = Option::Some(value); + new + } + /// Options for specifying which payload to include or not + #[allow(unused_mut)] + pub fn with_payload>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_payload = Option::Some(value.into()); + new + } + /// Search config + #[allow(unused_mut)] + pub fn params>(self, value: VALUE) -> Self { + let mut new = self; + new.params = Option::Some(Option::Some(value.into())); + new + } + /// If provided - cut off results with worse scores + #[allow(unused_mut)] + pub fn score_threshold(self, value: f32) -> Self { + let mut new = self; + new.score_threshold = Option::Some(Option::Some(value)); + new + } + /// Offset of the result + #[allow(unused_mut)] + pub fn offset(self, value: u64) -> Self { + let mut new = self; + new.offset = Option::Some(Option::Some(value)); + new + } + /// Which vector to use for search, if not specified - use default vector + #[allow(unused_mut)] + pub fn vector_name>(self, value: VALUE) -> Self { + let mut new = self; + new.vector_name = Option::Some(Option::Some(value.into())); + new + } + /// Options for specifying which vectors to include into response + #[allow(unused_mut)] + pub fn with_vectors>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_vectors = Option::Some(value.into()); + new + } + /// Options for specifying read consistency guarantees + #[allow(unused_mut)] + pub fn read_consistency>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.read_consistency = Option::Some(value.into()); + new + } + /// If set, overrides global timeout setting for this request. Unit is seconds. + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + /// Specify in which shards to look for the points, if not specified - look in all shards + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + #[allow(unused_mut)] + pub fn sparse_indices>(self, value: VALUE) -> Self { + let mut new = self; + new.sparse_indices = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(SearchPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + vector: match self.vector { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("vector"), + )); + } + }, + filter: self.filter.unwrap_or_default(), + limit: match self.limit { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("limit"), + )); + } + }, + with_payload: { convert_option(&self.with_payload) }, + params: self.params.unwrap_or_default(), + score_threshold: self.score_threshold.unwrap_or_default(), + offset: self.offset.unwrap_or_default(), + vector_name: self.vector_name.unwrap_or_default(), + with_vectors: { convert_option(&self.with_vectors) }, + read_consistency: { convert_option(&self.read_consistency) }, + timeout: self.timeout.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + sparse_indices: self.sparse_indices.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + vector: core::default::Default::default(), + filter: core::default::Default::default(), + limit: core::default::Default::default(), + with_payload: core::default::Default::default(), + params: core::default::Default::default(), + score_threshold: core::default::Default::default(), + offset: core::default::Default::default(), + vector_name: core::default::Default::default(), + with_vectors: core::default::Default::default(), + read_consistency: core::default::Default::default(), + timeout: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + sparse_indices: core::default::Default::default(), + } + } +} + +impl From for SearchPoints { + fn from(value: SearchPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "SearchPointsBuilder", "SearchPoints" + ) + }) + } +} + +impl SearchPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> SearchPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "SearchPointsBuilder", "SearchPoints" + ) + }) + } +} + +impl SearchPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +#[non_exhaustive] +#[derive(Debug)] +pub enum SearchPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for SearchPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for SearchPointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for SearchPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for SearchPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/set_payload_points_builder.rs b/src/builders/set_payload_points_builder.rs new file mode 100644 index 00000000..6a6414e9 --- /dev/null +++ b/src/builders/set_payload_points_builder.rs @@ -0,0 +1,182 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct SetPayloadPointsBuilder { + /// name of the collection + pub(crate) collection_name: Option, + /// Wait until the changes have been applied? + pub(crate) wait: Option>, + /// New payload values + pub(crate) payload: Option<::std::collections::HashMap>, + /// Affected points + points_selector: Option, + /// Write ordering guarantees + pub(crate) ordering: Option>, + /// Option for custom sharding to specify used shard keys + pub(crate) shard_key_selector: Option>, + /// Option for indicate property of payload + pub(crate) key: Option>, +} + +impl SetPayloadPointsBuilder { + /// name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Wait until the changes have been applied? + #[allow(unused_mut)] + pub fn wait(self, value: bool) -> Self { + let mut new = self; + new.wait = Option::Some(Option::Some(value)); + new + } + /// New payload values + #[allow(unused_mut)] + pub fn payload(self, value: ::std::collections::HashMap) -> Self { + let mut new = self; + new.payload = Option::Some(value); + new + } + /// Affected points + #[allow(unused_mut)] + pub fn points_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.points_selector = Option::Some(value.into()); + new + } + /// Write ordering guarantees + #[allow(unused_mut)] + pub fn ordering>(self, value: VALUE) -> Self { + let mut new = self; + new.ordering = Option::Some(Option::Some(value.into())); + new + } + /// Option for custom sharding to specify used shard keys + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + /// Option for indicate property of payload + #[allow(unused_mut)] + pub fn key>(self, value: VALUE) -> Self { + let mut new = self; + new.key = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(SetPayloadPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + wait: self.wait.unwrap_or_default(), + payload: match self.payload { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("payload"), + )); + } + }, + points_selector: { convert_option(&self.points_selector) }, + ordering: self.ordering.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + key: self.key.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + wait: core::default::Default::default(), + payload: core::default::Default::default(), + points_selector: core::default::Default::default(), + ordering: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + key: core::default::Default::default(), + } + } +} + +impl From for SetPayloadPoints { + fn from(value: SetPayloadPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "SetPayloadPointsBuilder", "SetPayloadPoints" + ) + }) + } +} + +impl SetPayloadPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> SetPayloadPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "SetPayloadPointsBuilder", "SetPayloadPoints" + ) + }) + } +} + +impl SetPayloadPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +#[non_exhaustive] +#[derive(Debug)] +pub enum SetPayloadPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for SetPayloadPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for SetPayloadPointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for SetPayloadPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for SetPayloadPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/sparse_index_config_builder.rs b/src/builders/sparse_index_config_builder.rs new file mode 100644 index 00000000..e9c5ef8f --- /dev/null +++ b/src/builders/sparse_index_config_builder.rs @@ -0,0 +1,87 @@ +use crate::qdrant::*; + +pub struct SparseIndexConfigBuilder { + /// + /// Prefer a full scan search upto (excluding) this number of vectors. + /// Note: this is number of vectors, not KiloBytes. + pub(crate) full_scan_threshold: Option>, + /// + /// Store inverted index on disk. If set to false, the index will be stored in RAM. + pub(crate) on_disk: Option>, + /// + /// Datatype used to store weights in the index. + pub(crate) datatype: Option>, +} + +impl SparseIndexConfigBuilder { + /// + /// Prefer a full scan search upto (excluding) this number of vectors. + /// Note: this is number of vectors, not KiloBytes. + #[allow(unused_mut)] + pub fn full_scan_threshold>(self, value: VALUE) -> Self { + let mut new = self; + new.full_scan_threshold = Option::Some(Option::Some(value.into())); + new + } + /// + /// Store inverted index on disk. If set to false, the index will be stored in RAM. + #[allow(unused_mut)] + pub fn on_disk(self, value: bool) -> Self { + let mut new = self; + new.on_disk = Option::Some(Option::Some(value)); + new + } + /// + /// Datatype used to store weights in the index. + #[allow(unused_mut)] + pub fn datatype>(self, value: VALUE) -> Self { + let mut new = self; + new.datatype = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(SparseIndexConfig { + full_scan_threshold: self.full_scan_threshold.unwrap_or_default(), + on_disk: self.on_disk.unwrap_or_default(), + datatype: self.datatype.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + full_scan_threshold: core::default::Default::default(), + on_disk: core::default::Default::default(), + datatype: core::default::Default::default(), + } + } +} + +impl From for SparseIndexConfig { + fn from(value: SparseIndexConfigBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "SparseIndexConfigBuilder", "SparseIndexConfig" + ) + }) + } +} + +impl SparseIndexConfigBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> SparseIndexConfig { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "SparseIndexConfigBuilder", "SparseIndexConfig" + ) + }) + } +} + +impl Default for SparseIndexConfigBuilder { + fn default() -> Self { + Self::create_empty() + } +} diff --git a/src/builders/sparse_vector_params_builder.rs b/src/builders/sparse_vector_params_builder.rs new file mode 100644 index 00000000..1bf2d628 --- /dev/null +++ b/src/builders/sparse_vector_params_builder.rs @@ -0,0 +1,68 @@ +use crate::qdrant::*; + +pub struct SparseVectorParamsBuilder { + /// Configuration of sparse index + pub(crate) index: Option>, + /// If set - apply modifier to the vector values + pub(crate) modifier: Option>, +} + +impl SparseVectorParamsBuilder { + /// Configuration of sparse index + #[allow(unused_mut)] + pub fn index>(self, value: VALUE) -> Self { + let mut new = self; + new.index = Option::Some(Option::Some(value.into())); + new + } + /// If set - apply modifier to the vector values + #[allow(unused_mut)] + pub fn modifier>(self, value: VALUE) -> Self { + let mut new = self; + new.modifier = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(SparseVectorParams { + index: self.index.unwrap_or_default(), + modifier: self.modifier.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + index: core::default::Default::default(), + modifier: core::default::Default::default(), + } + } +} + +impl From for SparseVectorParams { + fn from(value: SparseVectorParamsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "SparseVectorParamsBuilder", "SparseVectorParams" + ) + }) + } +} + +impl SparseVectorParamsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> SparseVectorParams { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "SparseVectorParamsBuilder", "SparseVectorParams" + ) + }) + } +} + +impl Default for SparseVectorParamsBuilder { + fn default() -> Self { + Self::create_empty() + } +} diff --git a/src/builders/strict_mode_config_builder.rs b/src/builders/strict_mode_config_builder.rs new file mode 100644 index 00000000..4f124be8 --- /dev/null +++ b/src/builders/strict_mode_config_builder.rs @@ -0,0 +1,118 @@ +use crate::qdrant::*; + +pub struct StrictModeConfigBuilder { + pub(crate) enabled: Option>, + pub(crate) max_query_limit: Option>, + pub(crate) max_timeout: Option>, + pub(crate) unindexed_filtering_retrieve: Option>, + pub(crate) unindexed_filtering_update: Option>, + pub(crate) search_max_hnsw_ef: Option>, + pub(crate) search_allow_exact: Option>, + pub(crate) search_max_oversampling: Option>, +} + +impl StrictModeConfigBuilder { + #[allow(unused_mut)] + pub fn enabled(self, value: bool) -> Self { + let mut new = self; + new.enabled = Option::Some(Option::Some(value)); + new + } + #[allow(unused_mut)] + pub fn max_query_limit(self, value: u32) -> Self { + let mut new = self; + new.max_query_limit = Option::Some(Option::Some(value)); + new + } + #[allow(unused_mut)] + pub fn max_timeout(self, value: u32) -> Self { + let mut new = self; + new.max_timeout = Option::Some(Option::Some(value)); + new + } + #[allow(unused_mut)] + pub fn unindexed_filtering_retrieve(self, value: bool) -> Self { + let mut new = self; + new.unindexed_filtering_retrieve = Option::Some(Option::Some(value)); + new + } + #[allow(unused_mut)] + pub fn unindexed_filtering_update(self, value: bool) -> Self { + let mut new = self; + new.unindexed_filtering_update = Option::Some(Option::Some(value)); + new + } + #[allow(unused_mut)] + pub fn search_max_hnsw_ef(self, value: u32) -> Self { + let mut new = self; + new.search_max_hnsw_ef = Option::Some(Option::Some(value)); + new + } + #[allow(unused_mut)] + pub fn search_allow_exact(self, value: bool) -> Self { + let mut new = self; + new.search_allow_exact = Option::Some(Option::Some(value)); + new + } + #[allow(unused_mut)] + pub fn search_max_oversampling(self, value: f32) -> Self { + let mut new = self; + new.search_max_oversampling = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(StrictModeConfig { + enabled: self.enabled.unwrap_or_default(), + max_query_limit: self.max_query_limit.unwrap_or_default(), + max_timeout: self.max_timeout.unwrap_or_default(), + unindexed_filtering_retrieve: self.unindexed_filtering_retrieve.unwrap_or_default(), + unindexed_filtering_update: self.unindexed_filtering_update.unwrap_or_default(), + search_max_hnsw_ef: self.search_max_hnsw_ef.unwrap_or_default(), + search_allow_exact: self.search_allow_exact.unwrap_or_default(), + search_max_oversampling: self.search_max_oversampling.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + enabled: core::default::Default::default(), + max_query_limit: core::default::Default::default(), + max_timeout: core::default::Default::default(), + unindexed_filtering_retrieve: core::default::Default::default(), + unindexed_filtering_update: core::default::Default::default(), + search_max_hnsw_ef: core::default::Default::default(), + search_allow_exact: core::default::Default::default(), + search_max_oversampling: core::default::Default::default(), + } + } +} + +impl Default for StrictModeConfigBuilder { + fn default() -> Self { + Self::create_empty() + } +} + +impl From for StrictModeConfig { + fn from(value: StrictModeConfigBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "StrictModeConfigBuilder", "StrictModeConfig" + ) + }) + } +} + +impl StrictModeConfigBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> StrictModeConfig { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "StrictModeConfigBuilder", "StrictModeConfig" + ) + }) + } +} diff --git a/src/builders/text_index_params_builder.rs b/src/builders/text_index_params_builder.rs new file mode 100644 index 00000000..ed82fa91 --- /dev/null +++ b/src/builders/text_index_params_builder.rs @@ -0,0 +1,146 @@ +use crate::qdrant::*; + +pub struct TextIndexParamsBuilder { + /// Tokenizer type + pub(crate) tokenizer: Option, + /// If true - all tokens will be lowercase + pub(crate) lowercase: Option>, + /// Minimal token length + pub(crate) min_token_len: Option>, + /// Maximal token length + pub(crate) max_token_len: Option>, + /// If true - store index on disk. + pub(crate) on_disk: Option>, +} + +impl TextIndexParamsBuilder { + pub fn new(tokenizer: TokenizerType) -> Self { + let mut builder = Self::create_empty(); + builder.tokenizer = Some(tokenizer.into()); + builder + } + + /// Tokenizer type + #[allow(unused_mut)] + pub fn tokenizer(self, value: i32) -> Self { + let mut new = self; + new.tokenizer = Option::Some(value); + new + } + /// If true - all tokens will be lowercase + #[allow(unused_mut)] + pub fn lowercase(self, value: bool) -> Self { + let mut new = self; + new.lowercase = Option::Some(Option::Some(value)); + new + } + /// Minimal token length + #[allow(unused_mut)] + pub fn min_token_len(self, value: u64) -> Self { + let mut new = self; + new.min_token_len = Option::Some(Option::Some(value)); + new + } + /// Maximal token length + #[allow(unused_mut)] + pub fn max_token_len(self, value: u64) -> Self { + let mut new = self; + new.max_token_len = Option::Some(Option::Some(value)); + new + } + /// If true - store index on disk. + #[allow(unused_mut)] + pub fn on_disk(self, value: bool) -> Self { + let mut new = self; + new.on_disk = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(TextIndexParams { + tokenizer: match self.tokenizer { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("tokenizer"), + )); + } + }, + lowercase: self.lowercase.unwrap_or_default(), + min_token_len: self.min_token_len.unwrap_or_default(), + max_token_len: self.max_token_len.unwrap_or_default(), + on_disk: self.on_disk.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + tokenizer: core::default::Default::default(), + lowercase: core::default::Default::default(), + min_token_len: core::default::Default::default(), + max_token_len: core::default::Default::default(), + on_disk: core::default::Default::default(), + } + } +} + +impl From for TextIndexParams { + fn from(value: TextIndexParamsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "TextIndexParamsBuilder", "TextIndexParams" + ) + }) + } +} + +impl TextIndexParamsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> TextIndexParams { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "TextIndexParamsBuilder", "TextIndexParams" + ) + }) + } +} + +#[non_exhaustive] +#[derive(Debug)] +pub enum TextIndexParamsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for TextIndexParamsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for TextIndexParamsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for TextIndexParamsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for TextIndexParamsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/update_batch_points_builder.rs b/src/builders/update_batch_points_builder.rs new file mode 100644 index 00000000..f2918845 --- /dev/null +++ b/src/builders/update_batch_points_builder.rs @@ -0,0 +1,140 @@ +use crate::qdrant::*; + +pub struct UpdateBatchPointsBuilder { + /// name of the collection + pub(crate) collection_name: Option, + /// Wait until the changes have been applied? + pub(crate) wait: Option>, + pub(crate) operations: Option>, + /// Write ordering guarantees + pub(crate) ordering: Option>, +} + +impl UpdateBatchPointsBuilder { + /// name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Wait until the changes have been applied? + #[allow(unused_mut)] + pub fn wait(self, value: bool) -> Self { + let mut new = self; + new.wait = Option::Some(Option::Some(value)); + new + } + #[allow(unused_mut)] + pub fn operations(self, value: Vec) -> Self { + let mut new = self; + new.operations = Option::Some(value); + new + } + /// Write ordering guarantees + #[allow(unused_mut)] + pub fn ordering>(self, value: VALUE) -> Self { + let mut new = self; + new.ordering = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(UpdateBatchPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + wait: self.wait.unwrap_or_default(), + operations: match self.operations { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("operations"), + )); + } + }, + ordering: self.ordering.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + wait: core::default::Default::default(), + operations: core::default::Default::default(), + ordering: core::default::Default::default(), + } + } +} + +impl From for UpdateBatchPoints { + fn from(value: UpdateBatchPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "UpdateBatchPointsBuilder", "UpdateBatchPoints" + ) + }) + } +} + +impl UpdateBatchPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> UpdateBatchPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "UpdateBatchPointsBuilder", "UpdateBatchPoints" + ) + }) + } +} + +impl UpdateBatchPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +#[non_exhaustive] +#[derive(Debug)] +pub enum UpdateBatchPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for UpdateBatchPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for UpdateBatchPointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for UpdateBatchPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for UpdateBatchPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/update_collection_builder.rs b/src/builders/update_collection_builder.rs new file mode 100644 index 00000000..f260e345 --- /dev/null +++ b/src/builders/update_collection_builder.rs @@ -0,0 +1,194 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct UpdateCollectionBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// New configuration parameters for the collection. This operation is blocking, it will only proceed once all current optimizations are complete + pub(crate) optimizers_config: Option>, + /// Wait timeout for operation commit in seconds if blocking, if not specified - default value will be supplied + pub(crate) timeout: Option>, + /// New configuration parameters for the collection + pub(crate) params: Option>, + /// New HNSW parameters for the collection index + pub(crate) hnsw_config: Option>, + /// New vector parameters + pub(crate) vectors_config: Option>, + /// Quantization configuration of vector + quantization_config: Option, + /// New sparse vector parameters + pub(crate) sparse_vectors_config: Option>, +} + +impl UpdateCollectionBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// New configuration parameters for the collection. This operation is blocking, it will only proceed once all current optimizations are complete + #[allow(unused_mut)] + pub fn optimizers_config>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.optimizers_config = Option::Some(Option::Some(value.into())); + new + } + /// Wait timeout for operation commit in seconds if blocking, if not specified - default value will be supplied + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + /// New configuration parameters for the collection + #[allow(unused_mut)] + pub fn params>(self, value: VALUE) -> Self { + let mut new = self; + new.params = Option::Some(Option::Some(value.into())); + new + } + /// New HNSW parameters for the collection index + #[allow(unused_mut)] + pub fn hnsw_config>(self, value: VALUE) -> Self { + let mut new = self; + new.hnsw_config = Option::Some(Option::Some(value.into())); + new + } + /// New vector parameters + #[allow(unused_mut)] + pub fn vectors_config>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.vectors_config = Option::Some(Option::Some(value.into())); + new + } + /// Quantization configuration of vector + #[allow(unused_mut)] + pub fn quantization_config< + VALUE: core::convert::Into, + >( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.quantization_config = Option::Some(value.into()); + new + } + /// New sparse vector parameters + #[allow(unused_mut)] + pub fn sparse_vectors_config>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.sparse_vectors_config = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(UpdateCollection { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + optimizers_config: self.optimizers_config.unwrap_or_default(), + timeout: self.timeout.unwrap_or_default(), + params: self.params.unwrap_or_default(), + hnsw_config: self.hnsw_config.unwrap_or_default(), + vectors_config: self.vectors_config.unwrap_or_default(), + quantization_config: { convert_option(&self.quantization_config) }, + sparse_vectors_config: self.sparse_vectors_config.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + optimizers_config: core::default::Default::default(), + timeout: core::default::Default::default(), + params: core::default::Default::default(), + hnsw_config: core::default::Default::default(), + vectors_config: core::default::Default::default(), + quantization_config: core::default::Default::default(), + sparse_vectors_config: core::default::Default::default(), + } + } +} + +impl From for UpdateCollection { + fn from(value: UpdateCollectionBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "UpdateCollectionBuilder", "UpdateCollection" + ) + }) + } +} + +impl UpdateCollectionBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> UpdateCollection { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "UpdateCollectionBuilder", "UpdateCollection" + ) + }) + } +} + +impl UpdateCollectionBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +#[non_exhaustive] +#[derive(Debug)] +pub enum UpdateCollectionBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for UpdateCollectionBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for UpdateCollectionBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for UpdateCollectionBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for UpdateCollectionBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/update_collection_cluster_setup_request_builder.rs b/src/builders/update_collection_cluster_setup_request_builder.rs new file mode 100644 index 00000000..c4c9014a --- /dev/null +++ b/src/builders/update_collection_cluster_setup_request_builder.rs @@ -0,0 +1,137 @@ +use crate::qdrant::*; + +pub struct UpdateCollectionClusterSetupRequestBuilder { + /// Name of the collection + pub(crate) collection_name: Option, + /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied + pub(crate) timeout: Option>, + pub(crate) operation: Option>, +} + +impl UpdateCollectionClusterSetupRequestBuilder { + /// Name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied + #[allow(unused_mut)] + pub fn timeout(self, value: u64) -> Self { + let mut new = self; + new.timeout = Option::Some(Option::Some(value)); + new + } + #[allow(unused_mut)] + pub fn operation( + self, + value: Option, + ) -> Self { + let mut new = self; + new.operation = Option::Some(value); + new + } + + fn build_inner( + self, + ) -> Result + { + Ok(UpdateCollectionClusterSetupRequest { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + timeout: self.timeout.unwrap_or_default(), + operation: match self.operation { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("operation"), + )); + } + }, + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + timeout: core::default::Default::default(), + operation: core::default::Default::default(), + } + } +} + +impl From for UpdateCollectionClusterSetupRequest { + fn from(value: UpdateCollectionClusterSetupRequestBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "UpdateCollectionClusterSetupRequestBuilder", "UpdateCollectionClusterSetupRequest" + ) + }) + } +} + +impl UpdateCollectionClusterSetupRequestBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> UpdateCollectionClusterSetupRequest { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "UpdateCollectionClusterSetupRequestBuilder", "UpdateCollectionClusterSetupRequest" + ) + }) + } +} + +impl UpdateCollectionClusterSetupRequestBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +#[non_exhaustive] +#[derive(Debug)] +pub enum UpdateCollectionClusterSetupRequestBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for UpdateCollectionClusterSetupRequestBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for UpdateCollectionClusterSetupRequestBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From + for UpdateCollectionClusterSetupRequestBuilderError +{ + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for UpdateCollectionClusterSetupRequestBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/update_point_vectors_builder.rs b/src/builders/update_point_vectors_builder.rs new file mode 100644 index 00000000..aac19207 --- /dev/null +++ b/src/builders/update_point_vectors_builder.rs @@ -0,0 +1,156 @@ +use crate::qdrant::*; + +pub struct UpdatePointVectorsBuilder { + /// name of the collection + pub(crate) collection_name: Option, + /// Wait until the changes have been applied? + pub(crate) wait: Option>, + /// List of points and vectors to update + pub(crate) points: Option>, + /// Write ordering guarantees + pub(crate) ordering: Option>, + /// Option for custom sharding to specify used shard keys + pub(crate) shard_key_selector: Option>, +} + +impl UpdatePointVectorsBuilder { + /// name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Wait until the changes have been applied? + #[allow(unused_mut)] + pub fn wait(self, value: bool) -> Self { + let mut new = self; + new.wait = Option::Some(Option::Some(value)); + new + } + /// List of points and vectors to update + #[allow(unused_mut)] + pub fn points(self, value: Vec) -> Self { + let mut new = self; + new.points = Option::Some(value); + new + } + /// Write ordering guarantees + #[allow(unused_mut)] + pub fn ordering>(self, value: VALUE) -> Self { + let mut new = self; + new.ordering = Option::Some(Option::Some(value.into())); + new + } + /// Option for custom sharding to specify used shard keys + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(UpdatePointVectors { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + wait: self.wait.unwrap_or_default(), + points: match self.points { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("points"), + )); + } + }, + ordering: self.ordering.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + wait: core::default::Default::default(), + points: core::default::Default::default(), + ordering: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + } + } +} + +impl From for UpdatePointVectors { + fn from(value: UpdatePointVectorsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "UpdatePointVectorsBuilder", "UpdatePointVectors" + ) + }) + } +} + +impl UpdatePointVectorsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> UpdatePointVectors { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "UpdatePointVectorsBuilder", "UpdatePointVectors" + ) + }) + } +} + +impl UpdatePointVectorsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +#[non_exhaustive] +#[derive(Debug)] +pub enum UpdatePointVectorsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for UpdatePointVectorsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for UpdatePointVectorsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for UpdatePointVectorsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for UpdatePointVectorsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/upsert_points_builder.rs b/src/builders/upsert_points_builder.rs new file mode 100644 index 00000000..14499c9e --- /dev/null +++ b/src/builders/upsert_points_builder.rs @@ -0,0 +1,154 @@ +use crate::qdrant::*; + +pub struct UpsertPointsBuilder { + /// name of the collection + pub(crate) collection_name: Option, + /// Wait until the changes have been applied? + pub(crate) wait: Option>, + pub(crate) points: Option>, + /// Write ordering guarantees + pub(crate) ordering: Option>, + /// Option for custom sharding to specify used shard keys + pub(crate) shard_key_selector: Option>, +} + +impl UpsertPointsBuilder { + /// name of the collection + #[allow(unused_mut)] + pub fn collection_name(self, value: String) -> Self { + let mut new = self; + new.collection_name = Option::Some(value); + new + } + /// Wait until the changes have been applied? + #[allow(unused_mut)] + pub fn wait(self, value: bool) -> Self { + let mut new = self; + new.wait = Option::Some(Option::Some(value)); + new + } + #[allow(unused_mut)] + pub fn points(self, value: Vec) -> Self { + let mut new = self; + new.points = Option::Some(value); + new + } + /// Write ordering guarantees + #[allow(unused_mut)] + pub fn ordering>(self, value: VALUE) -> Self { + let mut new = self; + new.ordering = Option::Some(Option::Some(value.into())); + new + } + /// Option for custom sharding to specify used shard keys + #[allow(unused_mut)] + pub fn shard_key_selector>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.shard_key_selector = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(UpsertPoints { + collection_name: match self.collection_name { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection_name"), + )); + } + }, + wait: self.wait.unwrap_or_default(), + points: match self.points { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("points"), + )); + } + }, + ordering: self.ordering.unwrap_or_default(), + shard_key_selector: self.shard_key_selector.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection_name: core::default::Default::default(), + wait: core::default::Default::default(), + points: core::default::Default::default(), + ordering: core::default::Default::default(), + shard_key_selector: core::default::Default::default(), + } + } +} + +impl From for UpsertPoints { + fn from(value: UpsertPointsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "UpsertPointsBuilder", "UpsertPoints" + ) + }) + } +} + +impl UpsertPointsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> UpsertPoints { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "UpsertPointsBuilder", "UpsertPoints" + ) + }) + } +} + +impl UpsertPointsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +#[non_exhaustive] +#[derive(Debug)] +pub enum UpsertPointsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for UpsertPointsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for UpsertPointsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for UpsertPointsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for UpsertPointsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/uuid_index_params_builder.rs b/src/builders/uuid_index_params_builder.rs new file mode 100644 index 00000000..cea869c2 --- /dev/null +++ b/src/builders/uuid_index_params_builder.rs @@ -0,0 +1,68 @@ +use crate::qdrant::*; + +pub struct UuidIndexParamsBuilder { + /// If true - used for tenant optimization. + pub(crate) is_tenant: Option>, + /// If true - store index on disk. + pub(crate) on_disk: Option>, +} + +impl UuidIndexParamsBuilder { + /// If true - used for tenant optimization. + #[allow(unused_mut)] + pub fn is_tenant(self, value: bool) -> Self { + let mut new = self; + new.is_tenant = Option::Some(Option::Some(value)); + new + } + /// If true - store index on disk. + #[allow(unused_mut)] + pub fn on_disk(self, value: bool) -> Self { + let mut new = self; + new.on_disk = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(UuidIndexParams { + is_tenant: self.is_tenant.unwrap_or_default(), + on_disk: self.on_disk.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + is_tenant: core::default::Default::default(), + on_disk: core::default::Default::default(), + } + } +} + +impl Default for UuidIndexParamsBuilder { + fn default() -> Self { + Self::create_empty() + } +} + +impl From for UuidIndexParams { + fn from(value: UuidIndexParamsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "UuidIndexParamsBuilder", "UuidIndexParams" + ) + }) + } +} + +impl UuidIndexParamsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> UuidIndexParams { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "UuidIndexParamsBuilder", "UuidIndexParams" + ) + }) + } +} diff --git a/src/builders/vector_params_builder.rs b/src/builders/vector_params_builder.rs new file mode 100644 index 00000000..8777eaa3 --- /dev/null +++ b/src/builders/vector_params_builder.rs @@ -0,0 +1,168 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct VectorParamsBuilder { + /// Size of the vectors + pub(crate) size: Option, + /// Distance function used for comparing vectors + pub(crate) distance: Option, + /// Configuration of vector HNSW graph. If omitted - the collection configuration will be used + pub(crate) hnsw_config: Option>, + /// Configuration of vector quantization config. If omitted - the collection configuration will be used + quantization_config: Option, + /// If true - serve vectors from disk. If set to false, the vectors will be loaded in RAM. + pub(crate) on_disk: Option>, + /// Data type of the vectors + pub(crate) datatype: Option>, + /// Configuration for multi-vector search + pub(crate) multivector_config: Option>, +} + +impl VectorParamsBuilder { + /// Size of the vectors + #[allow(unused_mut)] + pub fn size(self, value: u64) -> Self { + let mut new = self; + new.size = Option::Some(value); + new + } + /// Distance function used for comparing vectors + #[allow(unused_mut)] + pub fn distance>(self, value: VALUE) -> Self { + let mut new = self; + new.distance = Option::Some(value.into()); + new + } + /// Configuration of vector HNSW graph. If omitted - the collection configuration will be used + #[allow(unused_mut)] + pub fn hnsw_config>(self, value: VALUE) -> Self { + let mut new = self; + new.hnsw_config = Option::Some(Option::Some(value.into())); + new + } + /// Configuration of vector quantization config. If omitted - the collection configuration will be used + #[allow(unused_mut)] + pub fn quantization_config>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.quantization_config = Option::Some(value.into()); + new + } + /// If true - serve vectors from disk. If set to false, the vectors will be loaded in RAM. + #[allow(unused_mut)] + pub fn on_disk(self, value: bool) -> Self { + let mut new = self; + new.on_disk = Option::Some(Option::Some(value)); + new + } + /// Data type of the vectors + #[allow(unused_mut)] + pub fn datatype>(self, value: VALUE) -> Self { + let mut new = self; + new.datatype = Option::Some(Option::Some(value.into())); + new + } + /// Configuration for multi-vector search + #[allow(unused_mut)] + pub fn multivector_config>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.multivector_config = Option::Some(Option::Some(value.into())); + new + } + + fn build_inner(self) -> Result { + Ok(VectorParams { + size: self.size.unwrap_or_default(), + distance: self.distance.unwrap_or_default(), + hnsw_config: self.hnsw_config.unwrap_or_default(), + quantization_config: { convert_option(&self.quantization_config) }, + on_disk: self.on_disk.unwrap_or_default(), + datatype: self.datatype.unwrap_or_default(), + multivector_config: self.multivector_config.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + size: core::default::Default::default(), + distance: core::default::Default::default(), + hnsw_config: core::default::Default::default(), + quantization_config: core::default::Default::default(), + on_disk: core::default::Default::default(), + datatype: core::default::Default::default(), + multivector_config: core::default::Default::default(), + } + } +} + +impl From for VectorParams { + fn from(value: VectorParamsBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "VectorParamsBuilder", "VectorParams" + ) + }) + } +} + +impl VectorParamsBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> VectorParams { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "VectorParamsBuilder", "VectorParams" + ) + }) + } +} + +impl VectorParamsBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +#[non_exhaustive] +#[derive(Debug)] +pub enum VectorParamsBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for VectorParamsBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for VectorParamsBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for VectorParamsBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for VectorParamsBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/builders/vector_params_diff_builder.rs b/src/builders/vector_params_diff_builder.rs new file mode 100644 index 00000000..4b05a91e --- /dev/null +++ b/src/builders/vector_params_diff_builder.rs @@ -0,0 +1,85 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct VectorParamsDiffBuilder { + /// Update params for HNSW index. If empty object - it will be unset + pub(crate) hnsw_config: Option>, + /// Update quantization params. If none - it is left unchanged. + quantization_config: Option, + /// If true - serve vectors from disk. If set to false, the vectors will be loaded in RAM. + pub(crate) on_disk: Option>, +} + +impl VectorParamsDiffBuilder { + /// Update params for HNSW index. If empty object - it will be unset + #[allow(unused_mut)] + pub fn hnsw_config>(self, value: VALUE) -> Self { + let mut new = self; + new.hnsw_config = Option::Some(Option::Some(value.into())); + new + } + /// Update quantization params. If none - it is left unchanged. + #[allow(unused_mut)] + pub fn quantization_config< + VALUE: core::convert::Into, + >( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.quantization_config = Option::Some(value.into()); + new + } + /// If true - serve vectors from disk. If set to false, the vectors will be loaded in RAM. + #[allow(unused_mut)] + pub fn on_disk(self, value: bool) -> Self { + let mut new = self; + new.on_disk = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(VectorParamsDiff { + hnsw_config: self.hnsw_config.unwrap_or_default(), + quantization_config: { convert_option(&self.quantization_config) }, + on_disk: self.on_disk.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + hnsw_config: core::default::Default::default(), + quantization_config: core::default::Default::default(), + on_disk: core::default::Default::default(), + } + } +} + +impl Default for VectorParamsDiffBuilder { + fn default() -> Self { + Self::create_empty() + } +} + +impl From for VectorParamsDiff { + fn from(value: VectorParamsDiffBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "VectorParamsDiffBuilder", "VectorParamsDiff" + ) + }) + } +} + +impl VectorParamsDiffBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> VectorParamsDiff { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "VectorParamsDiffBuilder", "VectorParamsDiff" + ) + }) + } +} diff --git a/src/builders/wal_config_diff_builder.rs b/src/builders/wal_config_diff_builder.rs new file mode 100644 index 00000000..d69a297e --- /dev/null +++ b/src/builders/wal_config_diff_builder.rs @@ -0,0 +1,68 @@ +use crate::qdrant::*; + +pub struct WalConfigDiffBuilder { + /// Size of a single WAL block file + pub(crate) wal_capacity_mb: Option>, + /// Number of segments to create in advance + pub(crate) wal_segments_ahead: Option>, +} + +impl WalConfigDiffBuilder { + /// Size of a single WAL block file + #[allow(unused_mut)] + pub fn wal_capacity_mb(self, value: u64) -> Self { + let mut new = self; + new.wal_capacity_mb = Option::Some(Option::Some(value)); + new + } + /// Number of segments to create in advance + #[allow(unused_mut)] + pub fn wal_segments_ahead(self, value: u64) -> Self { + let mut new = self; + new.wal_segments_ahead = Option::Some(Option::Some(value)); + new + } + + fn build_inner(self) -> Result { + Ok(WalConfigDiff { + wal_capacity_mb: self.wal_capacity_mb.unwrap_or_default(), + wal_segments_ahead: self.wal_segments_ahead.unwrap_or_default(), + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + wal_capacity_mb: core::default::Default::default(), + wal_segments_ahead: core::default::Default::default(), + } + } +} + +impl Default for WalConfigDiffBuilder { + fn default() -> Self { + Self::create_empty() + } +} + +impl From for WalConfigDiff { + fn from(value: WalConfigDiffBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "WalConfigDiffBuilder", "WalConfigDiff" + ) + }) + } +} + +impl WalConfigDiffBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> WalConfigDiff { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "WalConfigDiffBuilder", "WalConfigDiff" + ) + }) + } +} diff --git a/src/builders/with_lookup_builder.rs b/src/builders/with_lookup_builder.rs new file mode 100644 index 00000000..5cf86604 --- /dev/null +++ b/src/builders/with_lookup_builder.rs @@ -0,0 +1,131 @@ +use crate::grpc_macros::convert_option; +use crate::qdrant::*; + +pub struct WithLookupBuilder { + /// Name of the collection to use for points lookup + pub(crate) collection: Option, + /// Options for specifying which payload to include (or not) + with_payload: Option, + /// Options for specifying which vectors to include (or not) + with_vectors: Option, +} + +impl WithLookupBuilder { + /// Name of the collection to use for points lookup + #[allow(unused_mut)] + pub fn collection(self, value: String) -> Self { + let mut new = self; + new.collection = Option::Some(value); + new + } + /// Options for specifying which payload to include (or not) + #[allow(unused_mut)] + pub fn with_payload>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_payload = Option::Some(value.into()); + new + } + /// Options for specifying which vectors to include (or not) + #[allow(unused_mut)] + pub fn with_vectors>( + self, + value: VALUE, + ) -> Self { + let mut new = self; + new.with_vectors = Option::Some(value.into()); + new + } + + fn build_inner(self) -> Result { + Ok(WithLookup { + collection: match self.collection { + Some(value) => value, + None => { + return Result::Err(core::convert::Into::into( + ::derive_builder::UninitializedFieldError::from("collection"), + )); + } + }, + with_payload: { convert_option(&self.with_payload) }, + with_vectors: { convert_option(&self.with_vectors) }, + }) + } + /// Create an empty builder, with all fields set to `None` or `PhantomData`. + fn create_empty() -> Self { + Self { + collection: core::default::Default::default(), + with_payload: core::default::Default::default(), + with_vectors: core::default::Default::default(), + } + } +} + +impl From for WithLookup { + fn from(value: WithLookupBuilder) -> Self { + value.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to convert {0} to {1}", + "WithLookupBuilder", "WithLookup" + ) + }) + } +} + +impl WithLookupBuilder { + /// Builds the desired type. Can often be omitted. + pub fn build(self) -> WithLookup { + self.build_inner().unwrap_or_else(|_| { + panic!( + "Failed to build {0} into {1}", + "WithLookupBuilder", "WithLookup" + ) + }) + } +} + +impl WithLookupBuilder { + pub(crate) fn empty() -> Self { + Self::create_empty() + } +} + +#[non_exhaustive] +#[derive(Debug)] +pub enum WithLookupBuilderError { + /// Uninitialized field + UninitializedField(&'static str), + /// Custom validation error + ValidationError(String), +} + +// Implementing the Display trait for better error messages +impl std::fmt::Display for WithLookupBuilderError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::UninitializedField(field) => { + write!(f, "`{}` must be initialized", field) + } + Self::ValidationError(error) => write!(f, "{}", error), + } + } +} + +// Implementing the Error trait +impl std::error::Error for WithLookupBuilderError {} + +// Implementing From trait for conversion from UninitializedFieldError +impl From for WithLookupBuilderError { + fn from(error: derive_builder::UninitializedFieldError) -> Self { + Self::UninitializedField(error.field_name()) + } +} + +// Implementing From trait for conversion from String +impl From for WithLookupBuilderError { + fn from(error: String) -> Self { + Self::ValidationError(error) + } +} diff --git a/src/lib.rs b/src/lib.rs index d4cf651c..45107608 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -131,6 +131,7 @@ pub mod qdrant; mod auth; mod builder_ext; mod builder_types; +mod builders; mod channel_pool; mod filters; mod grpc_conversions; @@ -138,7 +139,6 @@ mod grpc_macros; mod manual_builder; mod payload; mod qdrant_client; - // Deprecated modules /// Deprecated Qdrant client #[deprecated( @@ -180,13 +180,14 @@ pub mod config { mod tests { use std::collections::HashMap; + use crate::builders::CreateCollectionBuilder; use crate::payload::Payload; use crate::qdrant::value::Kind::*; use crate::qdrant::{ - Condition, CreateCollectionBuilder, CreateFieldIndexCollection, DeletePayloadPointsBuilder, - DeletePointsBuilder, Distance, FieldType, Filter, GetPointsBuilder, ListValue, PointStruct, - SearchPointsBuilder, SetPayloadPointsBuilder, SnapshotDownloadBuilder, Struct, - UpsertPointsBuilder, Value, VectorParamsBuilder, + Condition, CreateFieldIndexCollection, DeletePayloadPointsBuilder, DeletePointsBuilder, + Distance, FieldType, Filter, GetPointsBuilder, ListValue, PointStruct, SearchPointsBuilder, + SetPayloadPointsBuilder, SnapshotDownloadBuilder, Struct, UpsertPointsBuilder, Value, + VectorParamsBuilder, }; use crate::Qdrant; diff --git a/src/qdrant.rs b/src/qdrant.rs index ba162768..acf5bf26 100644 --- a/src/qdrant.rs +++ b/src/qdrant.rs @@ -1,82 +1,45 @@ // This file is @generated by prost-build. -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct VectorParams { /// Size of the vectors #[prost(uint64, tag = "1")] - #[builder(default, field(vis = "pub(crate)"))] pub size: u64, /// Distance function used for comparing vectors #[prost(enumeration = "Distance", tag = "2")] - #[builder(default, setter(into), field(vis = "pub(crate)"))] pub distance: i32, /// Configuration of vector HNSW graph. If omitted - the collection configuration will be used #[prost(message, optional, tag = "3")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub hnsw_config: ::core::option::Option, /// Configuration of vector quantization config. If omitted - the collection configuration will be used #[prost(message, optional, tag = "4")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.quantization_config)" - ) - )] pub quantization_config: ::core::option::Option, /// If true - serve vectors from disk. If set to false, the vectors will be loaded in RAM. #[prost(bool, optional, tag = "5")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub on_disk: ::core::option::Option, /// Data type of the vectors #[prost(enumeration = "Datatype", optional, tag = "6")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub datatype: ::core::option::Option, /// Configuration for multi-vector search #[prost(message, optional, tag = "7")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub multivector_config: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct VectorParamsDiff { /// Update params for HNSW index. If empty object - it will be unset #[prost(message, optional, tag = "1")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub hnsw_config: ::core::option::Option, /// Update quantization params. If none - it is left unchanged. #[prost(message, optional, tag = "2")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.quantization_config)" - ) - )] pub quantization_config: ::core::option::Option, /// If true - serve vectors from disk. If set to false, the vectors will be loaded in RAM. #[prost(bool, optional, tag = "3")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub on_disk: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct VectorParamsMap { #[prost(map = "string, message", tag = "1")] pub map: ::std::collections::HashMap<::prost::alloc::string::String, VectorParams>, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct VectorParamsDiffMap { #[prost(map = "string, message", tag = "1")] @@ -85,7 +48,6 @@ pub struct VectorParamsDiffMap { VectorParamsDiff, >, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct VectorsConfig { #[prost(oneof = "vectors_config::Config", tags = "1, 2")] @@ -93,7 +55,6 @@ pub struct VectorsConfig { } /// Nested message and enum types in `VectorsConfig`. pub mod vectors_config { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Config { #[prost(message, tag = "1")] @@ -102,7 +63,6 @@ pub mod vectors_config { ParamsMap(super::VectorParamsMap), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct VectorsConfigDiff { #[prost(oneof = "vectors_config_diff::Config", tags = "1, 2")] @@ -110,7 +70,6 @@ pub struct VectorsConfigDiff { } /// Nested message and enum types in `VectorsConfigDiff`. pub mod vectors_config_diff { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Config { #[prost(message, tag = "1")] @@ -119,24 +78,15 @@ pub mod vectors_config_diff { ParamsMap(super::VectorParamsDiffMap), } } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct SparseVectorParams { /// Configuration of sparse index #[prost(message, optional, tag = "1")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub index: ::core::option::Option, /// If set - apply modifier to the vector values #[prost(enumeration = "Modifier", optional, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub modifier: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SparseVectorConfig { #[prost(map = "string, message", tag = "1")] @@ -145,40 +95,28 @@ pub struct SparseVectorConfig { SparseVectorParams, >, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct MultiVectorConfig { /// Comparator for multi-vector search #[prost(enumeration = "MultiVectorComparator", tag = "1")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub comparator: i32, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetCollectionInfoRequest { /// Name of the collection #[prost(string, tag = "1")] pub collection_name: ::prost::alloc::string::String, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CollectionExistsRequest { #[prost(string, tag = "1")] pub collection_name: ::prost::alloc::string::String, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct CollectionExists { #[prost(bool, tag = "1")] pub exists: bool, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct CollectionExistsResponse { #[prost(message, optional, tag = "1")] @@ -187,17 +125,14 @@ pub struct CollectionExistsResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ListCollectionsRequest {} -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CollectionDescription { /// Name of the collection #[prost(string, tag = "1")] pub name: ::prost::alloc::string::String, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetCollectionInfoResponse { #[prost(message, optional, tag = "1")] @@ -206,7 +141,6 @@ pub struct GetCollectionInfoResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ListCollectionsResponse { #[prost(message, repeated, tag = "1")] @@ -215,7 +149,6 @@ pub struct ListCollectionsResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct OptimizerStatus { #[prost(bool, tag = "1")] @@ -223,23 +156,15 @@ 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"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, 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), field(vis = "pub(crate)"))] pub m: ::core::option::Option, /// /// 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), field(vis = "pub(crate)"))] pub ef_construct: ::core::option::Option, /// /// Minimal size (in KiloBytes) of vectors for additional payload-based indexing. @@ -247,7 +172,6 @@ pub struct HnswConfigDiff { /// 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), field(vis = "pub(crate)"))] pub full_scan_threshold: ::core::option::Option, /// /// Number of parallel threads used for background index building. @@ -255,78 +179,50 @@ pub struct HnswConfigDiff { /// 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), field(vis = "pub(crate)"))] pub max_indexing_threads: ::core::option::Option, /// /// 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), field(vis = "pub(crate)"))] pub on_disk: ::core::option::Option, /// /// 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), field(vis = "pub(crate)"))] pub payload_m: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct SparseIndexConfig { /// /// Prefer a full scan search upto (excluding) this number of vectors. /// Note: this is number of vectors, not KiloBytes. #[prost(uint64, optional, tag = "1")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub full_scan_threshold: ::core::option::Option, /// /// Store inverted index on disk. If set to false, the index will be stored in RAM. #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub on_disk: ::core::option::Option, /// /// Datatype used to store weights in the index. #[prost(enumeration = "Datatype", optional, tag = "3")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub datatype: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct WalConfigDiff { /// Size of a single WAL block file #[prost(uint64, optional, tag = "1")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub wal_capacity_mb: ::core::option::Option, /// Number of segments to create in advance #[prost(uint64, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub wal_segments_ahead: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct OptimizersConfigDiff { /// /// The minimal fraction of deleted vectors in a segment, required to perform segment optimization #[prost(double, optional, tag = "1")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub deleted_threshold: ::core::option::Option, /// /// The minimal number of vectors in a segment, required to perform segment optimization #[prost(uint64, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub vacuum_min_vector_number: ::core::option::Option, /// /// Target amount of segments the optimizer will try to keep. @@ -338,7 +234,6 @@ pub struct OptimizersConfigDiff { /// It is recommended to select the default number of segments as a factor of the number of search threads, /// so that each segment would be handled evenly by one of the threads. #[prost(uint64, optional, tag = "3")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub default_segment_number: ::core::option::Option, /// /// Do not create segments larger this size (in kilobytes). @@ -350,7 +245,6 @@ pub struct OptimizersConfigDiff { /// Note: 1Kb = 1 vector of size 256 /// If not set, will be automatically selected considering the number of available CPUs. #[prost(uint64, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub max_segment_size: ::core::option::Option, /// /// Maximum size (in kilobytes) of vectors to store in-memory per segment. @@ -362,7 +256,6 @@ pub struct OptimizersConfigDiff { /// /// Note: 1Kb = 1 vector of size 256 #[prost(uint64, optional, tag = "5")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub memmap_threshold: ::core::option::Option, /// /// Maximum size (in kilobytes) of vectors allowed for plain index, exceeding this threshold will enable vector indexing @@ -373,12 +266,10 @@ pub struct OptimizersConfigDiff { /// /// Note: 1kB = 1 vector of size 256. #[prost(uint64, optional, tag = "6")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub indexing_threshold: ::core::option::Option, /// /// Interval between forced flushes. #[prost(uint64, optional, tag = "7")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub flush_interval_sec: ::core::option::Option, /// /// Max number of threads (jobs) for running optimizations per shard. @@ -386,64 +277,35 @@ pub struct OptimizersConfigDiff { /// If null - have no limit and choose dynamically to saturate CPU. /// If 0 - no optimization threads, optimizations will be disabled. #[prost(uint64, optional, tag = "8")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub max_optimization_threads: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ScalarQuantization { /// Type of quantization #[prost(enumeration = "QuantizationType", tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub r#type: i32, /// Number of bits to use for quantization #[prost(float, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub quantile: ::core::option::Option, /// If true - quantized vectors always will be stored in RAM, ignoring the config of main storage #[prost(bool, optional, tag = "3")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub always_ram: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ProductQuantization { /// Compression ratio #[prost(enumeration = "CompressionRatio", tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub compression: i32, /// If true - quantized vectors always will be stored in RAM, ignoring the config of main storage #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub always_ram: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct BinaryQuantization { /// If true - quantized vectors always will be stored in RAM, ignoring the config of main storage #[prost(bool, optional, tag = "1")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub always_ram: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct QuantizationConfig { #[prost(oneof = "quantization_config::Quantization", tags = "1, 2, 3")] @@ -451,7 +313,6 @@ pub struct QuantizationConfig { } /// Nested message and enum types in `QuantizationConfig`. pub mod quantization_config { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] pub enum Quantization { #[prost(message, tag = "1")] @@ -462,10 +323,8 @@ pub mod quantization_config { Binary(super::BinaryQuantization), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct Disabled {} -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct QuantizationConfigDiff { #[prost(oneof = "quantization_config_diff::Quantization", tags = "1, 2, 3, 4")] @@ -473,7 +332,6 @@ pub struct QuantizationConfigDiff { } /// Nested message and enum types in `QuantizationConfigDiff`. pub mod quantization_config_diff { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] pub enum Quantization { #[prost(message, tag = "1")] @@ -486,181 +344,109 @@ pub mod quantization_config_diff { Binary(super::BinaryQuantization), } } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct StrictModeConfig { #[prost(bool, optional, tag = "1")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub enabled: ::core::option::Option, #[prost(uint32, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub max_query_limit: ::core::option::Option, #[prost(uint32, optional, tag = "3")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub max_timeout: ::core::option::Option, #[prost(bool, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub unindexed_filtering_retrieve: ::core::option::Option, #[prost(bool, optional, tag = "5")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub unindexed_filtering_update: ::core::option::Option, #[prost(uint32, optional, tag = "6")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub search_max_hnsw_ef: ::core::option::Option, #[prost(bool, optional, tag = "7")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub search_allow_exact: ::core::option::Option, #[prost(float, optional, tag = "8")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub search_max_oversampling: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CreateCollection { /// Name of the collection #[prost(string, tag = "1")] - #[builder(default, setter(into), field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Configuration of vector index #[prost(message, optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub hnsw_config: ::core::option::Option, /// Configuration of the Write-Ahead-Log #[prost(message, optional, tag = "5")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub wal_config: ::core::option::Option, /// Configuration of the optimizers #[prost(message, optional, tag = "6")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub optimizers_config: ::core::option::Option, /// Number of shards in the collection, default is 1 for standalone, otherwise equal to the number of nodes. Minimum is 1 #[prost(uint32, optional, tag = "7")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub shard_number: ::core::option::Option, /// If true - point's payload will not be stored in memory #[prost(bool, optional, tag = "8")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub on_disk_payload: ::core::option::Option, /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied #[prost(uint64, optional, tag = "9")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, /// Configuration for vectors #[prost(message, optional, tag = "10")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub vectors_config: ::core::option::Option, /// Number of replicas of each shard that network tries to maintain, default = 1 #[prost(uint32, optional, tag = "11")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub replication_factor: ::core::option::Option, /// How many replicas should apply the operation for us to consider it successful, default = 1 #[prost(uint32, optional, tag = "12")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub write_consistency_factor: ::core::option::Option, /// Specify name of the other collection to copy data from #[prost(string, optional, tag = "13")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub init_from_collection: ::core::option::Option<::prost::alloc::string::String>, /// Quantization configuration of vector #[prost(message, optional, tag = "14")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.quantization_config)" - ) - )] pub quantization_config: ::core::option::Option, /// Sharding method #[prost(enumeration = "ShardingMethod", optional, tag = "15")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub sharding_method: ::core::option::Option, /// Configuration for sparse vectors #[prost(message, optional, tag = "16")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub sparse_vectors_config: ::core::option::Option, /// Configuration for strict mode #[prost(message, optional, tag = "17")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub strict_mode_config: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct UpdateCollection { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// New configuration parameters for the collection. This operation is blocking, it will only proceed once all current optimizations are complete #[prost(message, optional, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub optimizers_config: ::core::option::Option, /// Wait timeout for operation commit in seconds if blocking, if not specified - default value will be supplied #[prost(uint64, optional, tag = "3")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, /// New configuration parameters for the collection #[prost(message, optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub params: ::core::option::Option, /// New HNSW parameters for the collection index #[prost(message, optional, tag = "5")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub hnsw_config: ::core::option::Option, /// New vector parameters #[prost(message, optional, tag = "6")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub vectors_config: ::core::option::Option, /// Quantization configuration of vector #[prost(message, optional, tag = "7")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.quantization_config)" - ) - )] pub quantization_config: ::core::option::Option, /// New sparse vector parameters #[prost(message, optional, tag = "8")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub sparse_vectors_config: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeleteCollection { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied #[prost(uint64, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct CollectionOperationResponse { /// if operation made changes @@ -670,7 +456,6 @@ pub struct CollectionOperationResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CollectionParams { /// Number of shards in collection @@ -698,32 +483,21 @@ pub struct CollectionParams { #[prost(message, optional, tag = "10")] pub sparse_vectors_config: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct CollectionParamsDiff { /// Number of replicas of each shard that network tries to maintain #[prost(uint32, optional, tag = "1")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub replication_factor: ::core::option::Option, /// How many replicas should apply the operation for us to consider it successful #[prost(uint32, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub write_consistency_factor: ::core::option::Option, /// If true - point's payload will not be stored in memory #[prost(bool, optional, tag = "3")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub on_disk_payload: ::core::option::Option, /// Fan-out every read request to these many additional remote nodes (and return first available response) #[prost(uint32, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub read_fan_out_factor: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CollectionConfig { /// Collection parameters @@ -745,147 +519,83 @@ pub struct CollectionConfig { #[prost(message, optional, tag = "6")] pub strict_mode_config: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct KeywordIndexParams { /// If true - used for tenant optimization. #[prost(bool, optional, tag = "1")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub is_tenant: ::core::option::Option, /// If true - store index on disk. #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub on_disk: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct IntegerIndexParams { /// If true - support direct lookups. #[prost(bool, optional, tag = "1")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub lookup: ::core::option::Option, /// If true - support ranges filters. #[prost(bool, optional, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub range: ::core::option::Option, /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. #[prost(bool, optional, tag = "3")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub is_principal: ::core::option::Option, /// If true - store index on disk. #[prost(bool, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub on_disk: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct FloatIndexParams { /// If true - store index on disk. #[prost(bool, optional, tag = "1")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub on_disk: ::core::option::Option, /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub is_principal: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct GeoIndexParams { /// If true - store index on disk. #[prost(bool, optional, tag = "1")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub on_disk: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct TextIndexParams { /// Tokenizer type #[prost(enumeration = "TokenizerType", tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub tokenizer: i32, /// If true - all tokens will be lowercase #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub lowercase: ::core::option::Option, /// Minimal token length #[prost(uint64, optional, tag = "3")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub min_token_len: ::core::option::Option, /// Maximal token length #[prost(uint64, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub max_token_len: ::core::option::Option, /// If true - store index on disk. #[prost(bool, optional, tag = "5")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub on_disk: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct BoolIndexParams {} -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct DatetimeIndexParams { /// If true - store index on disk. #[prost(bool, optional, tag = "1")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub on_disk: ::core::option::Option, /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub is_principal: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct UuidIndexParams { /// If true - used for tenant optimization. #[prost(bool, optional, tag = "1")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub is_tenant: ::core::option::Option, /// If true - store index on disk. #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub on_disk: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct PayloadIndexParams { #[prost( @@ -896,7 +606,6 @@ pub struct PayloadIndexParams { } /// Nested message and enum types in `PayloadIndexParams`. pub mod payload_index_params { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] pub enum IndexParams { /// Parameters for keyword index @@ -925,7 +634,6 @@ pub mod payload_index_params { UuidIndexParams(super::UuidIndexParams), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct PayloadSchemaInfo { /// Field data type @@ -938,7 +646,6 @@ pub struct PayloadSchemaInfo { #[prost(uint64, optional, tag = "3")] pub points: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CollectionInfo { /// operating condition of the collection @@ -969,7 +676,6 @@ pub struct CollectionInfo { #[prost(uint64, optional, tag = "10")] pub indexed_vectors_count: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ChangeAliases { /// List of actions @@ -979,7 +685,6 @@ pub struct ChangeAliases { #[prost(uint64, optional, tag = "2")] pub timeout: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct AliasOperations { #[prost(oneof = "alias_operations::Action", tags = "1, 2, 3")] @@ -987,7 +692,6 @@ pub struct AliasOperations { } /// Nested message and enum types in `AliasOperations`. pub mod alias_operations { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Action { #[prost(message, tag = "1")] @@ -998,60 +702,38 @@ pub mod alias_operations { DeleteAlias(super::DeleteAlias), } } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CreateAlias { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// New name of the alias #[prost(string, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub alias_name: ::prost::alloc::string::String, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RenameAlias { /// Name of the alias to rename #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub old_alias_name: ::prost::alloc::string::String, /// Name of the alias #[prost(string, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub new_alias_name: ::prost::alloc::string::String, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeleteAlias { /// Name of the alias #[prost(string, tag = "1")] pub alias_name: ::prost::alloc::string::String, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ListAliasesRequest {} -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ListCollectionAliasesRequest { /// Name of the collection #[prost(string, tag = "1")] pub collection_name: ::prost::alloc::string::String, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct AliasDescription { /// Name of the alias @@ -1061,7 +743,6 @@ pub struct AliasDescription { #[prost(string, tag = "2")] pub collection_name: ::prost::alloc::string::String, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ListAliasesResponse { #[prost(message, repeated, tag = "1")] @@ -1070,14 +751,12 @@ pub struct ListAliasesResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CollectionClusterInfoRequest { /// Name of the collection #[prost(string, tag = "1")] pub collection_name: ::prost::alloc::string::String, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ShardKey { #[prost(oneof = "shard_key::Key", tags = "1, 2")] @@ -1085,7 +764,6 @@ pub struct ShardKey { } /// Nested message and enum types in `ShardKey`. pub mod shard_key { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Key { /// String key @@ -1096,7 +774,6 @@ pub mod shard_key { Number(u64), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct LocalShardInfo { /// Local shard id @@ -1112,7 +789,6 @@ pub struct LocalShardInfo { #[prost(message, optional, tag = "4")] pub shard_key: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RemoteShardInfo { /// Local shard id @@ -1128,7 +804,6 @@ pub struct RemoteShardInfo { #[prost(message, optional, tag = "4")] pub shard_key: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ShardTransferInfo { /// Local shard id @@ -1144,7 +819,6 @@ pub struct ShardTransferInfo { #[prost(bool, tag = "4")] pub sync: bool, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ReshardingInfo { #[prost(uint32, tag = "1")] @@ -1154,7 +828,6 @@ pub struct ReshardingInfo { #[prost(message, optional, tag = "3")] pub shard_key: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CollectionClusterInfoResponse { /// ID of this peer @@ -1173,82 +846,46 @@ pub struct CollectionClusterInfoResponse { #[prost(message, repeated, tag = "5")] pub shard_transfers: ::prost::alloc::vec::Vec, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct MoveShard { /// Local shard id #[prost(uint32, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub shard_id: u32, #[prost(uint32, optional, tag = "5")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub to_shard_id: ::core::option::Option, #[prost(uint64, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub from_peer_id: u64, #[prost(uint64, tag = "3")] - #[builder(field(vis = "pub(crate)"))] pub to_peer_id: u64, #[prost(enumeration = "ShardTransferMethod", optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub method: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ReplicateShard { /// Local shard id #[prost(uint32, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub shard_id: u32, #[prost(uint32, optional, tag = "5")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub to_shard_id: ::core::option::Option, #[prost(uint64, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub from_peer_id: u64, #[prost(uint64, tag = "3")] - #[builder(field(vis = "pub(crate)"))] pub to_peer_id: u64, #[prost(enumeration = "ShardTransferMethod", optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub method: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct AbortShardTransfer { /// Local shard id #[prost(uint32, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub shard_id: u32, #[prost(uint32, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub to_shard_id: ::core::option::Option, #[prost(uint64, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub from_peer_id: u64, #[prost(uint64, tag = "3")] - #[builder(field(vis = "pub(crate)"))] pub to_peer_id: u64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct RestartTransfer { /// Local shard id @@ -1263,83 +900,52 @@ pub struct RestartTransfer { #[prost(enumeration = "ShardTransferMethod", tag = "4")] pub method: i32, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct Replica { #[prost(uint32, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub shard_id: u32, #[prost(uint64, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub peer_id: u64, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CreateShardKey { /// User-defined shard key #[prost(message, optional, tag = "1")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key: ::core::option::Option, /// Number of shards to create per shard key #[prost(uint32, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub shards_number: ::core::option::Option, /// Number of replicas of each shard to create #[prost(uint32, optional, tag = "3")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub replication_factor: ::core::option::Option, /// List of peer ids, allowed to create shards. If empty - all peers are allowed #[prost(uint64, repeated, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub placement: ::prost::alloc::vec::Vec, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeleteShardKey { /// Shard key to delete #[prost(message, optional, tag = "1")] pub shard_key: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct UpdateCollectionClusterSetupRequest { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied #[prost(uint64, optional, tag = "6")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, #[prost( oneof = "update_collection_cluster_setup_request::Operation", tags = "2, 3, 4, 5, 7, 8, 9" )] - #[builder(field(vis = "pub(crate)"))] pub operation: ::core::option::Option< update_collection_cluster_setup_request::Operation, >, } /// Nested message and enum types in `UpdateCollectionClusterSetupRequest`. pub mod update_collection_cluster_setup_request { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Operation { #[prost(message, tag = "2")] @@ -1358,63 +964,40 @@ pub mod update_collection_cluster_setup_request { RestartTransfer(super::RestartTransfer), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct UpdateCollectionClusterSetupResponse { #[prost(bool, tag = "1")] pub result: bool, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CreateShardKeyRequest { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Request to create shard key #[prost(message, optional, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub request: ::core::option::Option, /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied #[prost(uint64, optional, tag = "3")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeleteShardKeyRequest { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Request to delete shard key #[prost(message, optional, tag = "2")] - #[builder(default, setter(custom), field(vis = "pub(crate)"))] pub request: ::core::option::Option, /// Wait timeout for operation commit in seconds, if not specified - default value will be supplied #[prost(uint64, optional, tag = "3")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct CreateShardKeyResponse { #[prost(bool, tag = "1")] pub result: bool, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct DeleteShardKeyResponse { #[prost(bool, tag = "1")] @@ -1435,10 +1018,10 @@ impl Datatype { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - Datatype::Default => "Default", - Datatype::Float32 => "Float32", - Datatype::Uint8 => "Uint8", - Datatype::Float16 => "Float16", + Self::Default => "Default", + Self::Float32 => "Float32", + Self::Uint8 => "Uint8", + Self::Float16 => "Float16", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -1466,8 +1049,8 @@ impl Modifier { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - Modifier::None => "None", - Modifier::Idf => "Idf", + Self::None => "None", + Self::Idf => "Idf", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -1491,7 +1074,7 @@ impl MultiVectorComparator { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - MultiVectorComparator::MaxSim => "MaxSim", + Self::MaxSim => "MaxSim", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -1518,11 +1101,11 @@ impl Distance { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - Distance::UnknownDistance => "UnknownDistance", - Distance::Cosine => "Cosine", - Distance::Euclid => "Euclid", - Distance::Dot => "Dot", - Distance::Manhattan => "Manhattan", + Self::UnknownDistance => "UnknownDistance", + Self::Cosine => "Cosine", + Self::Euclid => "Euclid", + Self::Dot => "Dot", + Self::Manhattan => "Manhattan", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -1557,11 +1140,11 @@ impl CollectionStatus { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - CollectionStatus::UnknownCollectionStatus => "UnknownCollectionStatus", - CollectionStatus::Green => "Green", - CollectionStatus::Yellow => "Yellow", - CollectionStatus::Red => "Red", - CollectionStatus::Grey => "Grey", + Self::UnknownCollectionStatus => "UnknownCollectionStatus", + Self::Green => "Green", + Self::Yellow => "Yellow", + Self::Red => "Red", + Self::Grey => "Grey", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -1596,15 +1179,15 @@ impl PayloadSchemaType { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - PayloadSchemaType::UnknownType => "UnknownType", - PayloadSchemaType::Keyword => "Keyword", - PayloadSchemaType::Integer => "Integer", - PayloadSchemaType::Float => "Float", - PayloadSchemaType::Geo => "Geo", - PayloadSchemaType::Text => "Text", - PayloadSchemaType::Bool => "Bool", - PayloadSchemaType::Datetime => "Datetime", - PayloadSchemaType::Uuid => "Uuid", + Self::UnknownType => "UnknownType", + Self::Keyword => "Keyword", + Self::Integer => "Integer", + Self::Float => "Float", + Self::Geo => "Geo", + Self::Text => "Text", + Self::Bool => "Bool", + Self::Datetime => "Datetime", + Self::Uuid => "Uuid", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -1636,8 +1219,8 @@ impl QuantizationType { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - QuantizationType::UnknownQuantization => "UnknownQuantization", - QuantizationType::Int8 => "Int8", + Self::UnknownQuantization => "UnknownQuantization", + Self::Int8 => "Int8", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -1665,11 +1248,11 @@ impl CompressionRatio { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - CompressionRatio::X4 => "x4", - CompressionRatio::X8 => "x8", - CompressionRatio::X16 => "x16", - CompressionRatio::X32 => "x32", - CompressionRatio::X64 => "x64", + Self::X4 => "x4", + Self::X8 => "x8", + Self::X16 => "x16", + Self::X32 => "x32", + Self::X64 => "x64", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -1699,8 +1282,8 @@ impl ShardingMethod { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - ShardingMethod::Auto => "Auto", - ShardingMethod::Custom => "Custom", + Self::Auto => "Auto", + Self::Custom => "Custom", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -1728,11 +1311,11 @@ impl TokenizerType { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - TokenizerType::Unknown => "Unknown", - TokenizerType::Prefix => "Prefix", - TokenizerType::Whitespace => "Whitespace", - TokenizerType::Word => "Word", - TokenizerType::Multilingual => "Multilingual", + Self::Unknown => "Unknown", + Self::Prefix => "Prefix", + Self::Whitespace => "Whitespace", + Self::Word => "Word", + Self::Multilingual => "Multilingual", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -1774,14 +1357,14 @@ impl ReplicaState { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - ReplicaState::Active => "Active", - ReplicaState::Dead => "Dead", - ReplicaState::Partial => "Partial", - ReplicaState::Initializing => "Initializing", - ReplicaState::Listener => "Listener", - ReplicaState::PartialSnapshot => "PartialSnapshot", - ReplicaState::Recovery => "Recovery", - ReplicaState::Resharding => "Resharding", + Self::Active => "Active", + Self::Dead => "Dead", + Self::Partial => "Partial", + Self::Initializing => "Initializing", + Self::Listener => "Listener", + Self::PartialSnapshot => "PartialSnapshot", + Self::Recovery => "Recovery", + Self::Resharding => "Resharding", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -1818,10 +1401,10 @@ impl ShardTransferMethod { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - ShardTransferMethod::StreamRecords => "StreamRecords", - ShardTransferMethod::Snapshot => "Snapshot", - ShardTransferMethod::WalDelta => "WalDelta", - ShardTransferMethod::ReshardingStreamRecords => "ReshardingStreamRecords", + Self::StreamRecords => "StreamRecords", + Self::Snapshot => "Snapshot", + Self::WalDelta => "WalDelta", + Self::ReshardingStreamRecords => "ReshardingStreamRecords", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -3106,7 +2689,6 @@ pub mod collections_server { /// with the proto support for the language. /// /// The JSON representation for `Struct` is a JSON object. -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Struct { /// Unordered map of dynamically typed values. @@ -3119,7 +2701,6 @@ pub struct Struct { /// variants, absence of any variant indicates an error. /// /// The JSON representation for `Value` is a JSON value. -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Value { /// The kind of value. @@ -3129,7 +2710,6 @@ pub struct Value { /// Nested message and enum types in `Value`. pub mod value { /// The kind of value. - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Kind { /// Represents a null value. @@ -3158,7 +2738,6 @@ pub mod value { /// `ListValue` is a wrapper around a repeated field of values. /// /// The JSON representation for `ListValue` is a JSON array. -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ListValue { /// Repeated field of dynamically typed values. @@ -3182,7 +2761,7 @@ impl NullValue { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - NullValue::NullValue => "NULL_VALUE", + Self::NullValue => "NULL_VALUE", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -3193,14 +2772,12 @@ impl NullValue { } } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct WriteOrdering { /// Write ordering guarantees #[prost(enumeration = "WriteOrderingType", tag = "1")] pub r#type: i32, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ReadConsistency { #[prost(oneof = "read_consistency::Value", tags = "1, 2")] @@ -3208,7 +2785,6 @@ pub struct ReadConsistency { } /// Nested message and enum types in `ReadConsistency`. pub mod read_consistency { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] pub enum Value { /// Common read consistency configurations @@ -3219,7 +2795,6 @@ pub mod read_consistency { Factor(u64), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PointId { #[prost(oneof = "point_id::PointIdOptions", tags = "1, 2")] @@ -3227,7 +2802,6 @@ pub struct PointId { } /// Nested message and enum types in `PointId`. pub mod point_id { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum PointIdOptions { /// Numerical ID of the point @@ -3238,14 +2812,12 @@ pub mod point_id { Uuid(::prost::alloc::string::String), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SparseIndices { #[prost(uint32, repeated, tag = "1")] pub data: ::prost::alloc::vec::Vec, } /// Legacy vector format, which determines the vector type by the configuration of its fields. -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Vector { /// Vector data (flatten for multi vectors) @@ -3258,13 +2830,11 @@ pub struct Vector { #[prost(uint32, optional, tag = "3")] pub vectors_count: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DenseVector { #[prost(float, repeated, tag = "1")] pub data: ::prost::alloc::vec::Vec, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SparseVector { #[prost(float, repeated, tag = "1")] @@ -3272,14 +2842,12 @@ pub struct SparseVector { #[prost(uint32, repeated, tag = "2")] pub indices: ::prost::alloc::vec::Vec, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct MultiDenseVector { #[prost(message, repeated, tag = "1")] pub vectors: ::prost::alloc::vec::Vec, } /// Vector type to be used in queries. Ids will be substituted with their corresponding vectors from the collection. -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct VectorInput { #[prost(oneof = "vector_input::Variant", tags = "1, 2, 3, 4")] @@ -3287,7 +2855,6 @@ pub struct VectorInput { } /// Nested message and enum types in `VectorInput`. pub mod vector_input { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Variant { #[prost(message, tag = "1")] @@ -3300,165 +2867,89 @@ pub mod vector_input { MultiDense(super::MultiDenseVector), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ShardKeySelector { /// List of shard keys which should be used in the request #[prost(message, repeated, tag = "1")] pub shard_keys: ::prost::alloc::vec::Vec, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct UpsertPoints { /// name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Wait until the changes have been applied? #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub wait: ::core::option::Option, #[prost(message, repeated, tag = "3")] - #[builder(field(vis = "pub(crate)"))] pub points: ::prost::alloc::vec::Vec, /// Write ordering guarantees #[prost(message, optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub ordering: ::core::option::Option, /// Option for custom sharding to specify used shard keys #[prost(message, optional, tag = "5")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeletePoints { /// name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Wait until the changes have been applied? #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub wait: ::core::option::Option, /// Affected points #[prost(message, optional, tag = "3")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.points)" - ) - )] pub points: ::core::option::Option, /// Write ordering guarantees #[prost(message, optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub ordering: ::core::option::Option, /// Option for custom sharding to specify used shard keys #[prost(message, optional, tag = "5")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetPoints { /// name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// List of points to retrieve #[prost(message, repeated, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub ids: ::prost::alloc::vec::Vec, /// Options for specifying which payload to include or not #[prost(message, optional, tag = "4")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_payload)" - ) - )] pub with_payload: ::core::option::Option, /// Options for specifying which vectors to include into response #[prost(message, optional, tag = "5")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_vectors)" - ) - )] pub with_vectors: ::core::option::Option, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "6")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.read_consistency)" - ) - )] pub read_consistency: ::core::option::Option, /// Specify in which shards to look for the points, if not specified - look in all shards #[prost(message, optional, tag = "7")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "8")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct UpdatePointVectors { /// name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Wait until the changes have been applied? #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub wait: ::core::option::Option, /// List of points and vectors to update #[prost(message, repeated, tag = "3")] - #[builder(field(vis = "pub(crate)"))] pub points: ::prost::alloc::vec::Vec, /// Write ordering guarantees #[prost(message, optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub ordering: ::core::option::Option, /// Option for custom sharding to specify used shard keys #[prost(message, optional, tag = "5")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PointVectors { /// ID to update vectors for @@ -3468,247 +2959,138 @@ pub struct PointVectors { #[prost(message, optional, tag = "2")] pub vectors: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeletePointVectors { /// name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Wait until the changes have been applied? #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub wait: ::core::option::Option, /// Affected points #[prost(message, optional, tag = "3")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.points_selector)" - ) - )] pub points_selector: ::core::option::Option, /// List of vector names to delete #[prost(message, optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub vectors: ::core::option::Option, /// Write ordering guarantees #[prost(message, optional, tag = "5")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub ordering: ::core::option::Option, /// Option for custom sharding to specify used shard keys #[prost(message, optional, tag = "6")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SetPayloadPoints { /// name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Wait until the changes have been applied? #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub wait: ::core::option::Option, /// New payload values #[prost(map = "string, message", tag = "3")] - #[builder(field(vis = "pub(crate)"))] pub payload: ::std::collections::HashMap<::prost::alloc::string::String, Value>, /// Affected points #[prost(message, optional, tag = "5")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.points_selector)" - ) - )] pub points_selector: ::core::option::Option, /// Write ordering guarantees #[prost(message, optional, tag = "6")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub ordering: ::core::option::Option, /// Option for custom sharding to specify used shard keys #[prost(message, optional, tag = "7")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, /// Option for indicate property of payload #[prost(string, optional, tag = "8")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub key: ::core::option::Option<::prost::alloc::string::String>, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeletePayloadPoints { /// name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Wait until the changes have been applied? #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub wait: ::core::option::Option, /// List of keys to delete #[prost(string, repeated, tag = "3")] - #[builder(field(vis = "pub(crate)"))] pub keys: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, /// Affected points #[prost(message, optional, tag = "5")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.points_selector)" - ) - )] pub points_selector: ::core::option::Option, /// Write ordering guarantees #[prost(message, optional, tag = "6")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub ordering: ::core::option::Option, /// Option for custom sharding to specify used shard keys #[prost(message, optional, tag = "7")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ClearPayloadPoints { /// name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Wait until the changes have been applied? #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub wait: ::core::option::Option, /// Affected points #[prost(message, optional, tag = "3")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.points)" - ) - )] pub points: ::core::option::Option, /// Write ordering guarantees #[prost(message, optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub ordering: ::core::option::Option, /// Option for custom sharding to specify used shard keys #[prost(message, optional, tag = "5")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CreateFieldIndexCollection { /// name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Wait until the changes have been applied? #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub wait: ::core::option::Option, /// Field name to index #[prost(string, tag = "3")] - #[builder(field(vis = "pub(crate)"))] pub field_name: ::prost::alloc::string::String, /// Field type. #[prost(enumeration = "FieldType", optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub field_type: ::core::option::Option, /// Payload index params. #[prost(message, optional, tag = "5")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.field_index_params)" - ) - )] pub field_index_params: ::core::option::Option, /// Write ordering guarantees #[prost(message, optional, tag = "6")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub ordering: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeleteFieldIndexCollection { /// name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Wait until the changes have been applied? #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub wait: ::core::option::Option, /// Field name to delete #[prost(string, tag = "3")] - #[builder(field(vis = "pub(crate)"))] pub field_name: ::prost::alloc::string::String, /// Write ordering guarantees #[prost(message, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub ordering: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PayloadIncludeSelector { /// List of payload keys to include into result #[prost(string, repeated, tag = "1")] pub fields: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PayloadExcludeSelector { /// List of payload keys to exclude from the result #[prost(string, repeated, tag = "1")] pub fields: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct WithPayloadSelector { #[prost(oneof = "with_payload_selector::SelectorOptions", tags = "1, 2, 3")] @@ -3716,7 +3098,6 @@ pub struct WithPayloadSelector { } /// Nested message and enum types in `WithPayloadSelector`. pub mod with_payload_selector { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum SelectorOptions { /// If `true` - return all payload, if `false` - none @@ -3728,13 +3109,11 @@ pub mod with_payload_selector { Exclude(super::PayloadExcludeSelector), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct NamedVectors { #[prost(map = "string, message", tag = "1")] pub vectors: ::std::collections::HashMap<::prost::alloc::string::String, Vector>, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Vectors { #[prost(oneof = "vectors::VectorsOptions", tags = "1, 2")] @@ -3742,7 +3121,6 @@ pub struct Vectors { } /// Nested message and enum types in `Vectors`. pub mod vectors { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum VectorsOptions { #[prost(message, tag = "1")] @@ -3751,14 +3129,12 @@ pub mod vectors { Vectors(super::NamedVectors), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct VectorsSelector { /// List of vectors to include into result #[prost(string, repeated, tag = "1")] pub names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct WithVectorsSelector { #[prost(oneof = "with_vectors_selector::SelectorOptions", tags = "1, 2")] @@ -3766,7 +3142,6 @@ pub struct WithVectorsSelector { } /// Nested message and enum types in `WithVectorsSelector`. pub mod with_vectors_selector { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum SelectorOptions { /// If `true` - return all vectors, if `false` - none @@ -3777,23 +3152,15 @@ pub mod with_vectors_selector { Include(super::VectorsSelector), } } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct QuantizationSearchParams { /// /// If set to true, search will ignore quantized vector data #[prost(bool, optional, tag = "1")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub ignore: ::core::option::Option, /// /// If true, use original vectors to re-score top-k results. If ignored, qdrant decides automatically does rescore enabled or not. #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub rescore: ::core::option::Option, /// /// Oversampling factor for quantization. @@ -3804,281 +3171,150 @@ pub struct QuantizationSearchParams { /// For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will be pre-selected using quantized index, /// and then top-100 will be returned after re-scoring. #[prost(double, optional, tag = "3")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub oversampling: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct SearchParams { /// /// Params relevant to HNSW index. Size of the beam in a beam-search. /// Larger the value - more accurate the result, more time required for search. #[prost(uint64, optional, tag = "1")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub hnsw_ef: ::core::option::Option, /// /// Search without approximation. If set to true, search may run long but with exact results. #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub exact: ::core::option::Option, /// /// If set to true, search will ignore quantized vector data #[prost(message, optional, tag = "3")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub quantization: ::core::option::Option, /// /// If enabled, the engine will only perform search among indexed or small segments. /// Using this option prevents slow searches in case of delayed index, but does not /// guarantee that all uploaded vectors will be included in search results #[prost(bool, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub indexed_only: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SearchPoints { /// name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// vector #[prost(float, repeated, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub vector: ::prost::alloc::vec::Vec, /// Filter conditions - return only those points that satisfy the specified conditions #[prost(message, optional, tag = "3")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub filter: ::core::option::Option, /// Max number of result #[prost(uint64, tag = "4")] - #[builder(field(vis = "pub(crate)"))] pub limit: u64, /// Options for specifying which payload to include or not #[prost(message, optional, tag = "6")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_payload)" - ) - )] pub with_payload: ::core::option::Option, /// Search config #[prost(message, optional, tag = "7")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub params: ::core::option::Option, /// If provided - cut off results with worse scores #[prost(float, optional, tag = "8")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub score_threshold: ::core::option::Option, /// Offset of the result #[prost(uint64, optional, tag = "9")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub offset: ::core::option::Option, /// Which vector to use for search, if not specified - use default vector #[prost(string, optional, tag = "10")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub vector_name: ::core::option::Option<::prost::alloc::string::String>, /// Options for specifying which vectors to include into response #[prost(message, optional, tag = "11")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_vectors)" - ) - )] pub with_vectors: ::core::option::Option, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "12")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.read_consistency)" - ) - )] pub read_consistency: ::core::option::Option, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "13")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, /// Specify in which shards to look for the points, if not specified - look in all shards #[prost(message, optional, tag = "14")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, #[prost(message, optional, tag = "15")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub sparse_indices: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SearchBatchPoints { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, #[prost(message, repeated, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub search_points: ::prost::alloc::vec::Vec, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "3")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.read_consistency)" - ) - )] pub read_consistency: ::core::option::Option, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct WithLookup { /// Name of the collection to use for points lookup #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection: ::prost::alloc::string::String, /// Options for specifying which payload to include (or not) #[prost(message, optional, tag = "2")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_payload)" - ) - )] pub with_payload: ::core::option::Option, /// Options for specifying which vectors to include (or not) #[prost(message, optional, tag = "3")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_vectors)" - ) - )] pub with_vectors: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SearchPointGroups { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Vector to compare against #[prost(float, repeated, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub vector: ::prost::alloc::vec::Vec, /// Filter conditions - return only those points that satisfy the specified conditions #[prost(message, optional, tag = "3")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub filter: ::core::option::Option, /// Max number of result #[prost(uint32, tag = "4")] - #[builder(field(vis = "pub(crate)"))] pub limit: u32, /// Options for specifying which payload to include or not #[prost(message, optional, tag = "5")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_payload)" - ) - )] pub with_payload: ::core::option::Option, /// Search config #[prost(message, optional, tag = "6")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub params: ::core::option::Option, /// If provided - cut off results with worse scores #[prost(float, optional, tag = "7")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub score_threshold: ::core::option::Option, /// Which vector to use for search, if not specified - use default vector #[prost(string, optional, tag = "8")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub vector_name: ::core::option::Option<::prost::alloc::string::String>, /// Options for specifying which vectors to include into response #[prost(message, optional, tag = "9")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_vectors)" - ) - )] pub with_vectors: ::core::option::Option, /// Payload field to group by, must be a string or number field. If there are multiple values for the field, all of them will be used. One point can be in multiple groups. #[prost(string, tag = "10")] - #[builder(field(vis = "pub(crate)"))] pub group_by: ::prost::alloc::string::String, /// Maximum amount of points to return per group #[prost(uint32, tag = "11")] - #[builder(field(vis = "pub(crate)"))] pub group_size: u32, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "12")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.read_consistency)" - ) - )] pub read_consistency: ::core::option::Option, /// Options for specifying how to use the group id to lookup points in another collection #[prost(message, optional, tag = "13")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub with_lookup: ::core::option::Option, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "14")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, /// Specify in which shards to look for the points, if not specified - look in all shards #[prost(message, optional, tag = "15")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, #[prost(message, optional, tag = "16")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub sparse_indices: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct StartFrom { #[prost(oneof = "start_from::Value", tags = "1, 2, 3, 4")] @@ -4086,7 +3322,6 @@ pub struct StartFrom { } /// Nested message and enum types in `StartFrom`. pub mod start_from { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Value { #[prost(double, tag = "1")] @@ -4099,362 +3334,195 @@ pub mod start_from { Datetime(::prost::alloc::string::String), } } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct OrderBy { /// Payload key to order by #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub key: ::prost::alloc::string::String, /// Ascending or descending order #[prost(enumeration = "Direction", optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub direction: ::core::option::Option, /// Start from this value #[prost(message, optional, tag = "3")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.start_from)" - ) - )] pub start_from: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ScrollPoints { #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Filter conditions - return only those points that satisfy the specified conditions #[prost(message, optional, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub filter: ::core::option::Option, /// Start with this ID #[prost(message, optional, tag = "3")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub offset: ::core::option::Option, /// Max number of result #[prost(uint32, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub limit: ::core::option::Option, /// Options for specifying which payload to include or not #[prost(message, optional, tag = "6")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_payload)" - ) - )] pub with_payload: ::core::option::Option, /// Options for specifying which vectors to include into response #[prost(message, optional, tag = "7")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_vectors)" - ) - )] pub with_vectors: ::core::option::Option, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "8")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.read_consistency)" - ) - )] pub read_consistency: ::core::option::Option, /// Specify in which shards to look for the points, if not specified - look in all shards #[prost(message, optional, tag = "9")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, /// Order the records by a payload field #[prost(message, optional, tag = "10")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub order_by: ::core::option::Option, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "11")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct LookupLocation { #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Which vector to use for search, if not specified - use default vector #[prost(string, optional, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub vector_name: ::core::option::Option<::prost::alloc::string::String>, /// Specify in which shards to look for the points, if not specified - look in all shards #[prost(message, optional, tag = "3")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RecommendPoints { /// name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Look for vectors closest to the vectors from these points #[prost(message, repeated, tag = "2")] - #[builder(default, setter(custom), field(vis = "pub(crate)"))] pub positive: ::prost::alloc::vec::Vec, /// Try to avoid vectors like the vector from these points #[prost(message, repeated, tag = "3")] - #[builder(default, setter(custom), field(vis = "pub(crate)"))] pub negative: ::prost::alloc::vec::Vec, /// Filter conditions - return only those points that satisfy the specified conditions #[prost(message, optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub filter: ::core::option::Option, /// Max number of result #[prost(uint64, tag = "5")] - #[builder(field(vis = "pub(crate)"))] pub limit: u64, /// Options for specifying which payload to include or not #[prost(message, optional, tag = "7")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_payload)" - ) - )] pub with_payload: ::core::option::Option, /// Search config #[prost(message, optional, tag = "8")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub params: ::core::option::Option, /// If provided - cut off results with worse scores #[prost(float, optional, tag = "9")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub score_threshold: ::core::option::Option, /// Offset of the result #[prost(uint64, optional, tag = "10")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub offset: ::core::option::Option, /// Define which vector to use for recommendation, if not specified - default vector #[prost(string, optional, tag = "11")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub using: ::core::option::Option<::prost::alloc::string::String>, /// Options for specifying which vectors to include into response #[prost(message, optional, tag = "12")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_vectors)" - ) - )] pub with_vectors: ::core::option::Option, /// Name of the collection to use for points lookup, if not specified - use current collection #[prost(message, optional, tag = "13")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub lookup_from: ::core::option::Option, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "14")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.read_consistency)" - ) - )] pub read_consistency: ::core::option::Option, /// How to use the example vectors to find the results #[prost(enumeration = "RecommendStrategy", optional, tag = "16")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub strategy: ::core::option::Option, /// Look for vectors closest to those #[prost(message, repeated, tag = "17")] - #[builder(default, setter(custom), field(vis = "pub(crate)"))] pub positive_vectors: ::prost::alloc::vec::Vec, /// Try to avoid vectors like this #[prost(message, repeated, tag = "18")] - #[builder(default, setter(custom), field(vis = "pub(crate)"))] pub negative_vectors: ::prost::alloc::vec::Vec, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "19")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, /// Specify in which shards to look for the points, if not specified - look in all shards #[prost(message, optional, tag = "20")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RecommendBatchPoints { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, #[prost(message, repeated, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub recommend_points: ::prost::alloc::vec::Vec, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "3")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.read_consistency)" - ) - )] pub read_consistency: ::core::option::Option, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RecommendPointGroups { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Look for vectors closest to the vectors from these points #[prost(message, repeated, tag = "2")] - #[builder(default, setter(custom), field(vis = "pub(crate)"))] pub positive: ::prost::alloc::vec::Vec, /// Try to avoid vectors like the vector from these points #[prost(message, repeated, tag = "3")] - #[builder(default, setter(custom), field(vis = "pub(crate)"))] pub negative: ::prost::alloc::vec::Vec, /// Filter conditions - return only those points that satisfy the specified conditions #[prost(message, optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub filter: ::core::option::Option, /// Max number of groups in result #[prost(uint32, tag = "5")] - #[builder(field(vis = "pub(crate)"))] pub limit: u32, /// Options for specifying which payload to include or not #[prost(message, optional, tag = "6")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_payload)" - ) - )] pub with_payload: ::core::option::Option, /// Search config #[prost(message, optional, tag = "7")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub params: ::core::option::Option, /// If provided - cut off results with worse scores #[prost(float, optional, tag = "8")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub score_threshold: ::core::option::Option, /// Define which vector to use for recommendation, if not specified - default vector #[prost(string, optional, tag = "9")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub using: ::core::option::Option<::prost::alloc::string::String>, /// Options for specifying which vectors to include into response #[prost(message, optional, tag = "10")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_vectors)" - ) - )] pub with_vectors: ::core::option::Option, /// Name of the collection to use for points lookup, if not specified - use current collection #[prost(message, optional, tag = "11")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub lookup_from: ::core::option::Option, /// Payload field to group by, must be a string or number field. If there are multiple values for the field, all of them will be used. One point can be in multiple groups. #[prost(string, tag = "12")] - #[builder(field(vis = "pub(crate)"))] pub group_by: ::prost::alloc::string::String, /// Maximum amount of points to return per group #[prost(uint32, tag = "13")] - #[builder(field(vis = "pub(crate)"))] pub group_size: u32, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "14")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.read_consistency)" - ) - )] pub read_consistency: ::core::option::Option, /// Options for specifying how to use the group id to lookup points in another collection #[prost(message, optional, tag = "15")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub with_lookup: ::core::option::Option, /// How to use the example vectors to find the results #[prost(enumeration = "RecommendStrategy", optional, tag = "17")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub strategy: ::core::option::Option, /// Look for vectors closest to those #[prost(message, repeated, tag = "18")] - #[builder(default, setter(custom), field(vis = "pub(crate)"))] pub positive_vectors: ::prost::alloc::vec::Vec, /// Try to avoid vectors like this #[prost(message, repeated, tag = "19")] - #[builder(default, setter(custom), field(vis = "pub(crate)"))] pub negative_vectors: ::prost::alloc::vec::Vec, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "20")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, /// Specify in which shards to look for the points, if not specified - look in all shards #[prost(message, optional, tag = "21")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct TargetVector { #[prost(oneof = "target_vector::Target", tags = "1")] @@ -4462,14 +3530,12 @@ pub struct TargetVector { } /// Nested message and enum types in `TargetVector`. pub mod target_vector { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Target { #[prost(message, tag = "1")] Single(super::VectorExample), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct VectorExample { #[prost(oneof = "vector_example::Example", tags = "1, 2")] @@ -4477,7 +3543,6 @@ pub struct VectorExample { } /// Nested message and enum types in `VectorExample`. pub mod vector_example { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Example { #[prost(message, tag = "1")] @@ -4486,247 +3551,129 @@ pub mod vector_example { Vector(super::Vector), } } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ContextExamplePair { #[prost(message, optional, tag = "1")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub positive: ::core::option::Option, #[prost(message, optional, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub negative: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DiscoverPoints { /// name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Use this as the primary search objective #[prost(message, optional, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub target: ::core::option::Option, /// Search will be constrained by these pairs of examples #[prost(message, repeated, tag = "3")] - #[builder(field(vis = "pub(crate)"))] pub context: ::prost::alloc::vec::Vec, /// Filter conditions - return only those points that satisfy the specified conditions #[prost(message, optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub filter: ::core::option::Option, /// Max number of result #[prost(uint64, tag = "5")] - #[builder(field(vis = "pub(crate)"))] pub limit: u64, /// Options for specifying which payload to include or not #[prost(message, optional, tag = "6")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_payload)" - ) - )] pub with_payload: ::core::option::Option, /// Search config #[prost(message, optional, tag = "7")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub params: ::core::option::Option, /// Offset of the result #[prost(uint64, optional, tag = "8")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub offset: ::core::option::Option, /// Define which vector to use for recommendation, if not specified - default vector #[prost(string, optional, tag = "9")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub using: ::core::option::Option<::prost::alloc::string::String>, /// Options for specifying which vectors to include into response #[prost(message, optional, tag = "10")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_vectors)" - ) - )] pub with_vectors: ::core::option::Option, /// Name of the collection to use for points lookup, if not specified - use current collection #[prost(message, optional, tag = "11")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub lookup_from: ::core::option::Option, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "12")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.read_consistency)" - ) - )] pub read_consistency: ::core::option::Option, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "13")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, /// Specify in which shards to look for the points, if not specified - look in all shards #[prost(message, optional, tag = "14")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DiscoverBatchPoints { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, #[prost(message, repeated, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub discover_points: ::prost::alloc::vec::Vec, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "3")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.read_consistency)" - ) - )] pub read_consistency: ::core::option::Option, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CountPoints { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Filter conditions - return only those points that satisfy the specified conditions #[prost(message, optional, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub filter: ::core::option::Option, /// If `true` - return exact count, if `false` - return approximate count #[prost(bool, optional, tag = "3")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub exact: ::core::option::Option, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "4")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.read_consistency)" - ) - )] pub read_consistency: ::core::option::Option, /// Specify in which shards to look for the points, if not specified - look in all shards #[prost(message, optional, tag = "5")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "6")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RecommendInput { /// Look for vectors closest to the vectors from these points #[prost(message, repeated, tag = "1")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub positive: ::prost::alloc::vec::Vec, /// Try to avoid vectors like the vector from these points #[prost(message, repeated, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub negative: ::prost::alloc::vec::Vec, /// How to use the provided vectors to find the results #[prost(enumeration = "RecommendStrategy", optional, tag = "3")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub strategy: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ContextInputPair { /// A positive vector #[prost(message, optional, tag = "1")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub positive: ::core::option::Option, /// Repel from this vector #[prost(message, optional, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub negative: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DiscoverInput { /// Use this as the primary search objective #[prost(message, optional, tag = "1")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub target: ::core::option::Option, /// Search space will be constrained by these pairs of vectors #[prost(message, optional, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub context: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ContextInput { /// Search space will be constrained by these pairs of vectors #[prost(message, repeated, tag = "1")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub pairs: ::prost::alloc::vec::Vec, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Query { #[prost(oneof = "query::Variant", tags = "1, 2, 3, 4, 5, 6, 7")] @@ -4734,7 +3681,6 @@ pub struct Query { } /// Nested message and enum types in `Query`. pub mod query { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Variant { /// Find the nearest neighbors to this vector. @@ -4760,286 +3706,175 @@ pub mod query { Sample(i32), } } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, error = "std::convert::Infallible", name = "build_inner"), - pattern = "owned" -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PrefetchQuery { /// Sub-requests to perform first. If present, the query will be performed on the results of the prefetches. #[prost(message, repeated, tag = "1")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub prefetch: ::prost::alloc::vec::Vec, /// Query to perform. If missing, returns points ordered by their IDs. #[prost(message, optional, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub query: ::core::option::Option, /// Define which vector to use for querying. If missing, the default vector is is used. #[prost(string, optional, tag = "3")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub using: ::core::option::Option<::prost::alloc::string::String>, /// Filter conditions - return only those points that satisfy the specified conditions. #[prost(message, optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub filter: ::core::option::Option, /// Search params for when there is no prefetch. #[prost(message, optional, tag = "5")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub params: ::core::option::Option, /// Return points with scores better than this threshold. #[prost(float, optional, tag = "6")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub score_threshold: ::core::option::Option, /// Max number of points. Default is 10 #[prost(uint64, optional, tag = "7")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub limit: ::core::option::Option, /// The location to use for IDs lookup, if not specified - use the current collection and the 'using' vector #[prost(message, optional, tag = "8")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub lookup_from: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct QueryPoints { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Sub-requests to perform first. If present, the query will be performed on the results of the prefetches. #[prost(message, repeated, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub prefetch: ::prost::alloc::vec::Vec, /// Query to perform. If missing, returns points ordered by their IDs. #[prost(message, optional, tag = "3")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub query: ::core::option::Option, /// Define which vector to use for querying. If missing, the default vector is used. #[prost(string, optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub using: ::core::option::Option<::prost::alloc::string::String>, /// Filter conditions - return only those points that satisfy the specified conditions. #[prost(message, optional, tag = "5")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub filter: ::core::option::Option, /// Search params for when there is no prefetch. #[prost(message, optional, tag = "6")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub params: ::core::option::Option, /// Return points with scores better than this threshold. #[prost(float, optional, tag = "7")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub score_threshold: ::core::option::Option, /// Max number of points. Default is 10. #[prost(uint64, optional, tag = "8")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub limit: ::core::option::Option, /// Offset of the result. Skip this many points. Default is 0. #[prost(uint64, optional, tag = "9")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub offset: ::core::option::Option, /// Options for specifying which vectors to include into the response. #[prost(message, optional, tag = "10")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_vectors)" - ) - )] pub with_vectors: ::core::option::Option, /// Options for specifying which payload to include or not. #[prost(message, optional, tag = "11")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.with_payload)" - ) - )] pub with_payload: ::core::option::Option, /// Options for specifying read consistency guarantees. #[prost(message, optional, tag = "12")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.read_consistency)" - ) - )] pub read_consistency: ::core::option::Option, /// Specify in which shards to look for the points, if not specified - look in all shards. #[prost(message, optional, tag = "13")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, /// The location to use for IDs lookup, if not specified - use the current collection and the 'using' vector #[prost(message, optional, tag = "14")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub lookup_from: ::core::option::Option, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "15")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct QueryBatchPoints { #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, #[prost(message, repeated, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub query_points: ::prost::alloc::vec::Vec, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "3")] - #[builder( - setter(into, strip_option), - field( - ty = "Option", - build = "convert_option(&self.read_consistency)" - ) - )] pub read_consistency: ::core::option::Option, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct QueryPointGroups { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Sub-requests to perform first. If present, the query will be performed on the results of the prefetches. #[prost(message, repeated, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub prefetch: ::prost::alloc::vec::Vec, /// Query to perform. If missing, returns points ordered by their IDs. #[prost(message, optional, tag = "3")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub query: ::core::option::Option, /// Define which vector to use for querying. If missing, the default vector is used. #[prost(string, optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub using: ::core::option::Option<::prost::alloc::string::String>, /// Filter conditions - return only those points that satisfy the specified conditions. #[prost(message, optional, tag = "5")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub filter: ::core::option::Option, /// Search params for when there is no prefetch. #[prost(message, optional, tag = "6")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub params: ::core::option::Option, /// Return points with scores better than this threshold. #[prost(float, optional, tag = "7")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub score_threshold: ::core::option::Option, /// Options for specifying which payload to include or not #[prost(message, optional, tag = "8")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub with_payload: ::core::option::Option, /// Options for specifying which vectors to include into response #[prost(message, optional, tag = "9")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub with_vectors: ::core::option::Option, /// The location to use for IDs lookup, if not specified - use the current collection and the 'using' vector #[prost(message, optional, tag = "10")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub lookup_from: ::core::option::Option, /// Max number of points. Default is 3. #[prost(uint64, optional, tag = "11")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub limit: ::core::option::Option, /// Maximum amount of points to return per group. Default to 10. #[prost(uint64, optional, tag = "12")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub group_size: ::core::option::Option, /// Payload field to group by, must be a string or number field. If there are multiple values for the field, all of them will be used. One point can be in multiple groups. #[prost(string, tag = "13")] - #[builder(field(vis = "pub(crate)"))] pub group_by: ::prost::alloc::string::String, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "14")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub read_consistency: ::core::option::Option, /// Options for specifying how to use the group id to lookup points in another collection #[prost(message, optional, tag = "15")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub with_lookup: ::core::option::Option, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "16")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, /// Specify in which shards to look for the points, if not specified - look in all shards #[prost(message, optional, tag = "17")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FacetCounts { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Payload key of the facet #[prost(string, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub key: ::prost::alloc::string::String, /// Filter conditions - return only those points that satisfy the specified conditions. #[prost(message, optional, tag = "3")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub filter: ::core::option::Option, /// Max number of facets. Default is 10. #[prost(uint64, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub limit: ::core::option::Option, /// If true, return exact counts, slower but useful for debugging purposes. Default is false. #[prost(bool, optional, tag = "5")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub exact: ::core::option::Option, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "6")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "7")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub read_consistency: ::core::option::Option, /// Specify in which shards to look for the points, if not specified - look in all shards #[prost(message, optional, tag = "8")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FacetValue { #[prost(oneof = "facet_value::Variant", tags = "1, 2, 3")] @@ -5047,7 +3882,6 @@ pub struct FacetValue { } /// Nested message and enum types in `FacetValue`. pub mod facet_value { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Variant { /// String value from the facet @@ -5061,7 +3895,6 @@ pub mod facet_value { BoolValue(bool), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FacetHit { /// Value from the facet @@ -5071,56 +3904,39 @@ pub struct FacetHit { #[prost(uint64, tag = "2")] pub count: u64, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SearchMatrixPoints { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Filter conditions - return only those points that satisfy the specified conditions. #[prost(message, optional, tag = "2")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub filter: ::core::option::Option, /// How many points to select and search within. Default is 10. #[prost(uint64, optional, tag = "3")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub sample: ::core::option::Option, /// How many neighbours per sample to find. Default is 3. #[prost(uint64, optional, tag = "4")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub limit: ::core::option::Option, /// Define which vector to use for querying. If missing, the default vector is is used. #[prost(string, optional, tag = "5")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub using: ::core::option::Option<::prost::alloc::string::String>, /// If set, overrides global timeout setting for this request. Unit is seconds. #[prost(uint64, optional, tag = "6")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub timeout: ::core::option::Option, /// Options for specifying read consistency guarantees #[prost(message, optional, tag = "7")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub read_consistency: ::core::option::Option, /// Specify in which shards to look for the points, if not specified - look in all shards #[prost(message, optional, tag = "8")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub shard_key_selector: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SearchMatrixPairs { /// List of pairs of points with scores #[prost(message, repeated, tag = "1")] pub pairs: ::prost::alloc::vec::Vec, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SearchMatrixPair { /// first id of the pair @@ -5133,7 +3949,6 @@ pub struct SearchMatrixPair { #[prost(float, tag = "3")] pub score: f32, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SearchMatrixOffsets { /// Row indices of the matrix @@ -5149,7 +3964,6 @@ pub struct SearchMatrixOffsets { #[prost(message, repeated, tag = "4")] pub ids: ::prost::alloc::vec::Vec, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PointsUpdateOperation { #[prost( @@ -5160,7 +3974,6 @@ pub struct PointsUpdateOperation { } /// Nested message and enum types in `PointsUpdateOperation`. pub mod points_update_operation { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PointStructList { #[prost(message, repeated, tag = "1")] @@ -5169,7 +3982,6 @@ pub mod points_update_operation { #[prost(message, optional, tag = "2")] pub shard_key_selector: ::core::option::Option, } - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SetPayload { #[prost(map = "string, message", tag = "1")] @@ -5187,7 +3999,6 @@ pub mod points_update_operation { #[prost(string, optional, tag = "4")] pub key: ::core::option::Option<::prost::alloc::string::String>, } - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct OverwritePayload { #[prost(map = "string, message", tag = "1")] @@ -5205,7 +4016,6 @@ pub mod points_update_operation { #[prost(string, optional, tag = "4")] pub key: ::core::option::Option<::prost::alloc::string::String>, } - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeletePayload { #[prost(string, repeated, tag = "1")] @@ -5217,7 +4027,6 @@ pub mod points_update_operation { #[prost(message, optional, tag = "3")] pub shard_key_selector: ::core::option::Option, } - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct UpdateVectors { /// List of points and vectors to update @@ -5227,7 +4036,6 @@ pub mod points_update_operation { #[prost(message, optional, tag = "2")] pub shard_key_selector: ::core::option::Option, } - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeleteVectors { /// Affected points @@ -5240,7 +4048,6 @@ pub mod points_update_operation { #[prost(message, optional, tag = "3")] pub shard_key_selector: ::core::option::Option, } - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeletePoints { /// Affected points @@ -5250,7 +4057,6 @@ pub mod points_update_operation { #[prost(message, optional, tag = "2")] pub shard_key_selector: ::core::option::Option, } - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ClearPayload { /// Affected points @@ -5260,7 +4066,6 @@ pub mod points_update_operation { #[prost(message, optional, tag = "2")] pub shard_key_selector: ::core::option::Option, } - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Operation { #[prost(message, tag = "1")] @@ -5287,32 +4092,20 @@ pub mod points_update_operation { ClearPayload(ClearPayload), } } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct UpdateBatchPoints { /// name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Wait until the changes have been applied? #[prost(bool, optional, tag = "2")] - #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub wait: ::core::option::Option, #[prost(message, repeated, tag = "3")] - #[builder(field(vis = "pub(crate)"))] pub operations: ::prost::alloc::vec::Vec, /// Write ordering guarantees #[prost(message, optional, tag = "4")] - #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub ordering: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct PointsOperationResponse { #[prost(message, optional, tag = "1")] @@ -5321,7 +4114,6 @@ pub struct PointsOperationResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct UpdateResult { /// Number of operation @@ -5331,7 +4123,6 @@ pub struct UpdateResult { #[prost(enumeration = "UpdateStatus", tag = "2")] pub status: i32, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct OrderValue { #[prost(oneof = "order_value::Variant", tags = "1, 2")] @@ -5339,7 +4130,6 @@ pub struct OrderValue { } /// Nested message and enum types in `OrderValue`. pub mod order_value { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] pub enum Variant { #[prost(int64, tag = "1")] @@ -5348,7 +4138,6 @@ pub mod order_value { Float(f64), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ScoredPoint { /// Point id @@ -5373,7 +4162,6 @@ pub struct ScoredPoint { #[prost(message, optional, tag = "8")] pub order_value: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GroupId { #[prost(oneof = "group_id::Kind", tags = "1, 2, 3")] @@ -5381,7 +4169,6 @@ pub struct GroupId { } /// Nested message and enum types in `GroupId`. pub mod group_id { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Kind { /// Represents a double value. @@ -5395,7 +4182,6 @@ pub mod group_id { StringValue(::prost::alloc::string::String), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PointGroup { /// Group id @@ -5408,14 +4194,12 @@ pub struct PointGroup { #[prost(message, optional, tag = "3")] pub lookup: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GroupsResult { /// Groups #[prost(message, repeated, tag = "1")] pub groups: ::prost::alloc::vec::Vec, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SearchResponse { #[prost(message, repeated, tag = "1")] @@ -5424,7 +4208,6 @@ pub struct SearchResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct QueryResponse { #[prost(message, repeated, tag = "1")] @@ -5433,7 +4216,6 @@ pub struct QueryResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct QueryBatchResponse { #[prost(message, repeated, tag = "1")] @@ -5442,7 +4224,6 @@ pub struct QueryBatchResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct QueryGroupsResponse { #[prost(message, optional, tag = "1")] @@ -5451,13 +4232,11 @@ pub struct QueryGroupsResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct BatchResult { #[prost(message, repeated, tag = "1")] pub result: ::prost::alloc::vec::Vec, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SearchBatchResponse { #[prost(message, repeated, tag = "1")] @@ -5466,7 +4245,6 @@ pub struct SearchBatchResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SearchGroupsResponse { #[prost(message, optional, tag = "1")] @@ -5475,7 +4253,6 @@ pub struct SearchGroupsResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct CountResponse { #[prost(message, optional, tag = "1")] @@ -5484,7 +4261,6 @@ pub struct CountResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ScrollResponse { /// Use this offset for the next query @@ -5496,13 +4272,11 @@ pub struct ScrollResponse { #[prost(double, tag = "3")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct CountResult { #[prost(uint64, tag = "1")] pub count: u64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RetrievedPoint { #[prost(message, optional, tag = "1")] @@ -5518,7 +4292,6 @@ pub struct RetrievedPoint { #[prost(message, optional, tag = "6")] pub order_value: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetResponse { #[prost(message, repeated, tag = "1")] @@ -5527,7 +4300,6 @@ pub struct GetResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RecommendResponse { #[prost(message, repeated, tag = "1")] @@ -5536,7 +4308,6 @@ pub struct RecommendResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RecommendBatchResponse { #[prost(message, repeated, tag = "1")] @@ -5545,7 +4316,6 @@ pub struct RecommendBatchResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DiscoverResponse { #[prost(message, repeated, tag = "1")] @@ -5554,7 +4324,6 @@ pub struct DiscoverResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DiscoverBatchResponse { #[prost(message, repeated, tag = "1")] @@ -5563,7 +4332,6 @@ pub struct DiscoverBatchResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RecommendGroupsResponse { #[prost(message, optional, tag = "1")] @@ -5572,7 +4340,6 @@ pub struct RecommendGroupsResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct UpdateBatchResponse { #[prost(message, repeated, tag = "1")] @@ -5581,7 +4348,6 @@ pub struct UpdateBatchResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FacetResponse { #[prost(message, repeated, tag = "1")] @@ -5590,7 +4356,6 @@ pub struct FacetResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SearchMatrixPairsResponse { #[prost(message, optional, tag = "1")] @@ -5599,7 +4364,6 @@ pub struct SearchMatrixPairsResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SearchMatrixOffsetsResponse { #[prost(message, optional, tag = "1")] @@ -5608,7 +4372,6 @@ pub struct SearchMatrixOffsetsResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Filter { /// At least one of those conditions should match @@ -5624,7 +4387,6 @@ pub struct Filter { #[prost(message, optional, tag = "4")] pub min_should: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct MinShould { #[prost(message, repeated, tag = "1")] @@ -5632,7 +4394,6 @@ pub struct MinShould { #[prost(uint64, tag = "2")] pub min_count: u64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Condition { #[prost(oneof = "condition::ConditionOneOf", tags = "1, 2, 3, 4, 5, 6")] @@ -5640,7 +4401,6 @@ pub struct Condition { } /// Nested message and enum types in `Condition`. pub mod condition { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum ConditionOneOf { #[prost(message, tag = "1")] @@ -5657,25 +4417,21 @@ pub mod condition { Nested(super::NestedCondition), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct IsEmptyCondition { #[prost(string, tag = "1")] pub key: ::prost::alloc::string::String, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct IsNullCondition { #[prost(string, tag = "1")] pub key: ::prost::alloc::string::String, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct HasIdCondition { #[prost(message, repeated, tag = "1")] pub has_id: ::prost::alloc::vec::Vec, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct NestedCondition { /// Path to nested object @@ -5685,7 +4441,6 @@ pub struct NestedCondition { #[prost(message, optional, tag = "2")] pub filter: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FieldCondition { #[prost(string, tag = "1")] @@ -5712,7 +4467,6 @@ pub struct FieldCondition { #[prost(message, optional, tag = "8")] pub datetime_range: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Match { #[prost(oneof = "r#match::MatchValue", tags = "1, 2, 3, 4, 5, 6, 7, 8")] @@ -5720,7 +4474,6 @@ pub struct Match { } /// Nested message and enum types in `Match`. pub mod r#match { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum MatchValue { /// Match string keyword @@ -5749,19 +4502,16 @@ pub mod r#match { ExceptKeywords(super::RepeatedStrings), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RepeatedStrings { #[prost(string, repeated, tag = "1")] pub strings: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RepeatedIntegers { #[prost(int64, repeated, tag = "1")] pub integers: ::prost::alloc::vec::Vec, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct Range { #[prost(double, optional, tag = "1")] @@ -5773,7 +4523,6 @@ pub struct Range { #[prost(double, optional, tag = "4")] pub lte: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct DatetimeRange { #[prost(message, optional, tag = "1")] @@ -5785,7 +4534,6 @@ pub struct DatetimeRange { #[prost(message, optional, tag = "4")] pub lte: ::core::option::Option<::prost_types::Timestamp>, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct GeoBoundingBox { /// north-west corner @@ -5795,7 +4543,6 @@ pub struct GeoBoundingBox { #[prost(message, optional, tag = "2")] pub bottom_right: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct GeoRadius { /// Center of the circle @@ -5805,7 +4552,6 @@ pub struct GeoRadius { #[prost(float, tag = "2")] pub radius: f32, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GeoLineString { /// Ordered sequence of GeoPoints representing the line @@ -5814,7 +4560,6 @@ pub struct GeoLineString { } /// For a valid GeoPolygon, both the exterior and interior GeoLineStrings must consist of a minimum of 4 points. /// Additionally, the first and last points of each GeoLineString must be the same. -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GeoPolygon { /// The exterior line bounds the surface @@ -5824,7 +4569,6 @@ pub struct GeoPolygon { #[prost(message, repeated, tag = "2")] pub interiors: ::prost::alloc::vec::Vec, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ValuesCount { #[prost(uint64, optional, tag = "1")] @@ -5836,7 +4580,6 @@ pub struct ValuesCount { #[prost(uint64, optional, tag = "4")] pub lte: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PointsSelector { #[prost(oneof = "points_selector::PointsSelectorOneOf", tags = "1, 2")] @@ -5846,7 +4589,6 @@ pub struct PointsSelector { } /// Nested message and enum types in `PointsSelector`. pub mod points_selector { - #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum PointsSelectorOneOf { #[prost(message, tag = "1")] @@ -5855,13 +4597,11 @@ pub mod points_selector { Filter(super::Filter), } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PointsIdsList { #[prost(message, repeated, tag = "1")] pub ids: ::prost::alloc::vec::Vec, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PointStruct { #[prost(message, optional, tag = "1")] @@ -5871,7 +4611,6 @@ pub struct PointStruct { #[prost(message, optional, tag = "4")] pub vectors: ::core::option::Option, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct GeoPoint { #[prost(double, tag = "1")] @@ -5896,9 +4635,9 @@ impl WriteOrderingType { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - WriteOrderingType::Weak => "Weak", - WriteOrderingType::Medium => "Medium", - WriteOrderingType::Strong => "Strong", + Self::Weak => "Weak", + Self::Medium => "Medium", + Self::Strong => "Strong", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -5928,9 +4667,9 @@ impl ReadConsistencyType { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - ReadConsistencyType::All => "All", - ReadConsistencyType::Majority => "Majority", - ReadConsistencyType::Quorum => "Quorum", + Self::All => "All", + Self::Majority => "Majority", + Self::Quorum => "Quorum", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -5962,14 +4701,14 @@ impl FieldType { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - FieldType::Keyword => "FieldTypeKeyword", - FieldType::Integer => "FieldTypeInteger", - FieldType::Float => "FieldTypeFloat", - FieldType::Geo => "FieldTypeGeo", - FieldType::Text => "FieldTypeText", - FieldType::Bool => "FieldTypeBool", - FieldType::Datetime => "FieldTypeDatetime", - FieldType::Uuid => "FieldTypeUuid", + Self::Keyword => "FieldTypeKeyword", + Self::Integer => "FieldTypeInteger", + Self::Float => "FieldTypeFloat", + Self::Geo => "FieldTypeGeo", + Self::Text => "FieldTypeText", + Self::Bool => "FieldTypeBool", + Self::Datetime => "FieldTypeDatetime", + Self::Uuid => "FieldTypeUuid", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -6000,8 +4739,8 @@ impl Direction { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - Direction::Asc => "Asc", - Direction::Desc => "Desc", + Self::Asc => "Asc", + Self::Desc => "Desc", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -6032,8 +4771,8 @@ impl RecommendStrategy { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - RecommendStrategy::AverageVector => "AverageVector", - RecommendStrategy::BestScore => "BestScore", + Self::AverageVector => "AverageVector", + Self::BestScore => "BestScore", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -6060,8 +4799,8 @@ impl Fusion { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - Fusion::Rrf => "RRF", - Fusion::Dbsf => "DBSF", + Self::Rrf => "RRF", + Self::Dbsf => "DBSF", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -6090,7 +4829,7 @@ impl Sample { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - Sample::Random => "Random", + Self::Random => "Random", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -6119,10 +4858,10 @@ impl UpdateStatus { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - UpdateStatus::UnknownUpdateStatus => "UnknownUpdateStatus", - UpdateStatus::Acknowledged => "Acknowledged", - UpdateStatus::Completed => "Completed", - UpdateStatus::ClockRejected => "ClockRejected", + Self::UnknownUpdateStatus => "UnknownUpdateStatus", + Self::Acknowledged => "Acknowledged", + Self::Completed => "Completed", + Self::ClockRejected => "ClockRejected", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -8516,52 +7255,37 @@ pub mod points_server { const NAME: &'static str = SERVICE_NAME; } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct CreateFullSnapshotRequest {} -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct ListFullSnapshotsRequest {} -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeleteFullSnapshotRequest { /// Name of the full snapshot #[prost(string, tag = "1")] pub snapshot_name: ::prost::alloc::string::String, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CreateSnapshotRequest { /// Name of the collection #[prost(string, tag = "1")] pub collection_name: ::prost::alloc::string::String, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ListSnapshotsRequest { /// Name of the collection #[prost(string, tag = "1")] pub collection_name: ::prost::alloc::string::String, } -#[derive(derive_builder::Builder)] -#[builder( - build_fn(private, name = "build_inner"), - pattern = "owned", - custom_constructor -)] -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DeleteSnapshotRequest { /// Name of the collection #[prost(string, tag = "1")] - #[builder(field(vis = "pub(crate)"))] pub collection_name: ::prost::alloc::string::String, /// Name of the collection snapshot #[prost(string, tag = "2")] - #[builder(field(vis = "pub(crate)"))] pub snapshot_name: ::prost::alloc::string::String, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SnapshotDescription { /// Name of the snapshot @@ -8577,7 +7301,6 @@ pub struct SnapshotDescription { #[prost(string, optional, tag = "4")] pub checksum: ::core::option::Option<::prost::alloc::string::String>, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CreateSnapshotResponse { #[prost(message, optional, tag = "1")] @@ -8586,7 +7309,6 @@ pub struct CreateSnapshotResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ListSnapshotsResponse { #[prost(message, repeated, tag = "1")] @@ -8595,7 +7317,6 @@ pub struct ListSnapshotsResponse { #[prost(double, tag = "2")] pub time: f64, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct DeleteSnapshotResponse { /// Time spent to process @@ -9293,10 +8014,8 @@ pub mod snapshots_server { const NAME: &'static str = SERVICE_NAME; } } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct HealthCheckRequest {} -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct HealthCheckReply { #[prost(string, tag = "1")] @@ -9602,80 +8321,8 @@ pub mod qdrant_server { const NAME: &'static str = SERVICE_NAME; } } -use crate::grpc_macros::*; -builder_type_conversions!(CreateCollection, CreateCollectionBuilder); -builder_type_conversions!(VectorParams, VectorParamsBuilder, true); -builder_type_conversions!(HnswConfigDiff, HnswConfigDiffBuilder); -builder_type_conversions!(ScalarQuantization, ScalarQuantizationBuilder, true); -builder_type_conversions!(ProductQuantization, ProductQuantizationBuilder, true); -builder_type_conversions!(BinaryQuantization, BinaryQuantizationBuilder, true); -builder_type_conversions!(OptimizersConfigDiff, OptimizersConfigDiffBuilder); -builder_type_conversions!(WalConfigDiff, WalConfigDiffBuilder); -builder_type_conversions!(SearchPoints, SearchPointsBuilder, true); -builder_type_conversions!(SearchParams, SearchParamsBuilder); -builder_type_conversions!(QuantizationSearchParams, QuantizationSearchParamsBuilder); -builder_type_conversions!(UpdateCollection, UpdateCollectionBuilder, true); -builder_type_conversions!(SetPayloadPoints, SetPayloadPointsBuilder, true); -builder_type_conversions!(UpsertPoints, UpsertPointsBuilder, true); -builder_type_conversions!(UpdateBatchPoints, UpdateBatchPointsBuilder, true); -builder_type_conversions!(DeletePayloadPoints, DeletePayloadPointsBuilder, true); -builder_type_conversions!(ClearPayloadPoints, ClearPayloadPointsBuilder, true); -builder_type_conversions!(GetPoints, GetPointsBuilder, true); -builder_type_conversions!(SearchBatchPoints, SearchBatchPointsBuilder, true); -builder_type_conversions!(SearchPointGroups, SearchPointGroupsBuilder, true); -builder_type_conversions!(WithLookup, WithLookupBuilder, true); -builder_type_conversions!(DeletePointVectors, DeletePointVectorsBuilder, true); -builder_type_conversions!(UpdatePointVectors, UpdatePointVectorsBuilder, true); -builder_type_conversions!(ScrollPoints, ScrollPointsBuilder, true); -builder_type_conversions!(OrderBy, OrderByBuilder, true); -builder_type_conversions!(RecommendPoints, RecommendPointsBuilder, true); -builder_type_conversions!(LookupLocation, LookupLocationBuilder, true); -builder_type_conversions!(RecommendBatchPoints, RecommendBatchPointsBuilder, true); -builder_type_conversions!(RecommendPointGroups, RecommendPointGroupsBuilder, true); -builder_type_conversions!(DiscoverPoints, DiscoverPointsBuilder, true); -builder_type_conversions!(DiscoverBatchPoints, DiscoverBatchPointsBuilder, true); -builder_type_conversions!(QueryPoints, QueryPointsBuilder, true); -builder_type_conversions!(QueryBatchPoints, QueryBatchPointsBuilder, true); -builder_type_conversions!(CountPoints, CountPointsBuilder, true); -builder_type_conversions!(CreateFieldIndexCollection, CreateFieldIndexCollectionBuilder, true); -builder_type_conversions!(DeleteFieldIndexCollection, DeleteFieldIndexCollectionBuilder, true); -builder_type_conversions!(UpdateCollectionClusterSetupRequest, UpdateCollectionClusterSetupRequestBuilder, true); -builder_type_conversions!(MoveShard, MoveShardBuilder, true); -builder_type_conversions!(ReplicateShard, ReplicateShardBuilder, true); -builder_type_conversions!(AbortShardTransfer, AbortShardTransferBuilder, true); -builder_type_conversions!(Replica, ReplicaBuilder, true); -builder_type_conversions!(CreateShardKeyRequest, CreateShardKeyRequestBuilder, true); -builder_type_conversions!(DeleteShardKeyRequest, DeleteShardKeyRequestBuilder, true); -builder_type_conversions!(DeleteCollection, DeleteCollectionBuilder, true); -builder_type_conversions!(CollectionParamsDiff, CollectionParamsDiffBuilder); -builder_type_conversions!(VectorParamsDiff, VectorParamsDiffBuilder); -builder_type_conversions!(SparseVectorParams, SparseVectorParamsBuilder); -builder_type_conversions!(SparseIndexConfig, SparseIndexConfigBuilder); -builder_type_conversions!(CreateShardKey, CreateShardKeyBuilder); -builder_type_conversions!(ContextExamplePair, ContextExamplePairBuilder); -builder_type_conversions!(TextIndexParams, TextIndexParamsBuilder, true); -builder_type_conversions!(IntegerIndexParams, IntegerIndexParamsBuilder, true); -builder_type_conversions!(KeywordIndexParams, KeywordIndexParamsBuilder); -builder_type_conversions!(DatetimeIndexParams, DatetimeIndexParamsBuilder); -builder_type_conversions!(UuidIndexParams, UuidIndexParamsBuilder); -builder_type_conversions!(FloatIndexParams, FloatIndexParamsBuilder); -builder_type_conversions!(GeoIndexParams, GeoIndexParamsBuilder); -builder_type_conversions!(CreateAlias, CreateAliasBuilder, true); -builder_type_conversions!(RenameAlias, RenameAliasBuilder, true); -builder_type_conversions!(DeleteSnapshotRequest, DeleteSnapshotRequestBuilder, true); -builder_type_conversions!(PrefetchQuery, PrefetchQueryBuilder); -builder_type_conversions!(RecommendInput, RecommendInputBuilder); -builder_type_conversions!(DiscoverInput, DiscoverInputBuilder, true); -builder_type_conversions!(ContextInput, ContextInputBuilder); -builder_type_conversions!(ContextInputPair, ContextInputPairBuilder, true); -builder_type_conversions!(MultiVectorConfig, MultiVectorConfigBuilder, true); -builder_type_conversions!(QueryPointGroups, QueryPointGroupsBuilder, true); -builder_type_conversions!(StrictModeConfig, StrictModeConfigBuilder); -builder_type_conversions!(FacetCounts, FacetCountsBuilder, true); -builder_type_conversions!(SearchMatrixPoints, SearchMatrixPointsBuilder, true); -builder_type_conversions!(DeletePoints, DeletePointsBuilder, true); - pub use crate::manual_builder::*; pub use crate::builder_types::*; pub use crate::qdrant_client::builders::*; +pub use crate::builders::*; pub use prost_types::Timestamp; diff --git a/src/qdrant_client/builders/mod.rs b/src/qdrant_client/builders/mod.rs index a74e60e8..04564a88 100644 --- a/src/qdrant_client/builders/mod.rs +++ b/src/qdrant_client/builders/mod.rs @@ -1,4 +1,3 @@ -mod payloads; mod query; // Keeping this public because 1.10-1.10.1 users may use it pub mod sparse_vectors_config; diff --git a/src/qdrant_client/builders/payloads.rs b/src/qdrant_client/builders/payloads.rs deleted file mode 100644 index b21e77d4..00000000 --- a/src/qdrant_client/builders/payloads.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::qdrant::{IntegerIndexParamsBuilder, TextIndexParamsBuilder, TokenizerType}; - -impl TextIndexParamsBuilder { - pub fn new(tokenizer: TokenizerType) -> Self { - let mut builder = Self::empty(); - builder.tokenizer = Some(tokenizer.into()); - builder - } -} - -impl IntegerIndexParamsBuilder { - pub fn new(lookup: bool, range: bool) -> Self { - Self::empty().lookup(lookup).range(range) - } -} diff --git a/src/qdrant_client/collection.rs b/src/qdrant_client/collection.rs index 141f360b..1bb1527c 100644 --- a/src/qdrant_client/collection.rs +++ b/src/qdrant_client/collection.rs @@ -435,10 +435,11 @@ mod tests { use tokio::time::sleep; use super::*; + use crate::builders::CreateCollectionBuilder; use crate::payload::Payload; use crate::qdrant::{ - CountPointsBuilder, CreateCollectionBuilder, Distance, PointStruct, SearchPointsBuilder, - UpsertPointsBuilder, VectorParamsBuilder, + CountPointsBuilder, Distance, PointStruct, SearchPointsBuilder, UpsertPointsBuilder, + VectorParamsBuilder, }; #[tokio::test] diff --git a/src/qdrant_client/query.rs b/src/qdrant_client/query.rs index afd08680..900c9c9d 100644 --- a/src/qdrant_client/query.rs +++ b/src/qdrant_client/query.rs @@ -133,13 +133,14 @@ mod tests { use serde_json::json; use super::*; + use crate::builders::CreateCollectionBuilder; use crate::qdrant::{ - ContextInputBuilder, CreateCollectionBuilder, CreateFieldIndexCollectionBuilder, Datatype, - DiscoverInputBuilder, Distance, FieldType, Fusion, IntegerIndexParamsBuilder, Modifier, - MultiVectorConfig, NamedVectors, PointId, PointStruct, PrefetchQueryBuilder, Query, - QueryPointsBuilder, RecommendInputBuilder, ScalarQuantizationBuilder, - SparseIndexConfigBuilder, SparseVectorParamsBuilder, SparseVectorsConfigBuilder, - UpsertPointsBuilder, Vector, VectorInput, VectorParamsBuilder, VectorsConfigBuilder, + ContextInputBuilder, CreateFieldIndexCollectionBuilder, Datatype, DiscoverInputBuilder, + Distance, FieldType, Fusion, IntegerIndexParamsBuilder, Modifier, MultiVectorConfig, + NamedVectors, PointId, PointStruct, PrefetchQueryBuilder, Query, QueryPointsBuilder, + RecommendInputBuilder, ScalarQuantizationBuilder, SparseIndexConfigBuilder, + SparseVectorParamsBuilder, SparseVectorsConfigBuilder, UpsertPointsBuilder, Vector, + VectorInput, VectorParamsBuilder, VectorsConfigBuilder, }; use crate::Payload; diff --git a/tests/protos.rs b/tests/protos.rs index 6e656867..599eea30 100644 --- a/tests/protos.rs +++ b/tests/protos.rs @@ -1,5 +1,3 @@ -use std::collections::HashSet; - use tonic_build::Builder; fn timestamp(f: impl AsRef) -> std::time::SystemTime { @@ -22,7 +20,6 @@ fn protos() { tonic_build::configure() .configure_deprecations() - .configure_derive_builder() .out_dir("src/") // saves generated structures at this location .compile_protos( &["proto/qdrant.proto"], // proto entry point @@ -30,20 +27,13 @@ fn protos() { ) .unwrap(); - append_to_file(GRPC_OUTPUT_FILE, "use crate::grpc_macros::*;"); - - add_builder_macro_impls( - GRPC_OUTPUT_FILE, - builder_derive_options(), - additional_builder_derive_options(), - ); - // Re-export all custom builder here so they are all located in the same module in the end-user // API. let custom_reexports = [ "pub use crate::manual_builder::*;", "pub use crate::builder_types::*;", "pub use crate::qdrant_client::builders::*;", + "pub use crate::builders::*;", ]; append_to_file(GRPC_OUTPUT_FILE, &custom_reexports.join("\n")); @@ -54,31 +44,9 @@ fn protos() { eprintln!("proto definitions may be changed. Stubs recompiled. Please commit the changes.") } -/// Derive options for structs. (Path, build attributes, 'from' macro generation enabled) -type BuildDeriveOptions = (&'static str, &'static str, MacroConfig); - -/// Configures how/which macros should be implemented for each builder. -enum MacroConfig { - /// No macro call should be implemented - NoMacro, - - /// Default implementation including `From` and `build()`. - DefaultImpl, - - /// All implementations from `DefaultImpl` and additionally a `pub(super) empty()` function - /// that allows creating an empty builder from within this crate. This can be helpful for - /// builder that don't implement `Default` due to some required parameters. - WithDefaultFn, -} - /// Extension to [`Builder`] to configure builder attributes. trait BuilderExt { fn configure_deprecations(self) -> Self; - fn configure_derive_builder(self) -> Self; - fn derive_builders(self, paths: &[(&str, &str)], derive_options: &[BuildDeriveOptions]) - -> Self; - fn derive_builder(self, path: &str, derive_options: Option<&str>) -> Self; - fn field_build_attributes(self, paths: &[(&str, &str)]) -> Self; } impl BuilderExt for Builder { @@ -92,1110 +60,6 @@ impl BuilderExt for Builder { "#[deprecated(since = \"1.7.0\", note = \"use `ClearPayload` instead\")]", ) } - - fn configure_derive_builder(self) -> Self { - configure_builder(self) - } - - fn derive_builders( - self, - paths: &[(&str, &str)], - derive_options: &[BuildDeriveOptions], - ) -> Self { - let structs = unique_structs_from_paths(paths.iter().map(|i| i.0), &[]); - - // Check we don't specify the same filed twice. - let mut seen = HashSet::new(); - for (field, _) in paths.iter() { - if seen.contains(field) { - panic!("Field specified twice!"); - } - seen.insert(field); - } - - let derives = structs.into_iter().fold(self, |c, path| { - let derive_options = derive_options.iter().find(|i| i.0 == path).map(|i| i.1); - c.derive_builder(path, derive_options) - }); - - derives.field_build_attributes(paths) - } - - fn derive_builder(self, path: &str, derive_options: Option<&str>) -> Self { - let builder = self.type_attribute(path, "#[derive(derive_builder::Builder)]"); - - if let Some(derive_options) = derive_options { - builder.type_attribute(path, format!("#[builder({derive_options})]")) - } else { - builder - } - } - - fn field_build_attributes(self, paths: &[(&str, &str)]) -> Self { - paths.iter().fold(self, |c, (path, attribute)| { - c.field_attribute(path, format!("#[builder({attribute})]")) - }) - } -} - -/// Generates a str for field attributes required by some attributes for derive_builder. -/// This allows the builders fields being represented by different types than the actual built struct, if they can be converted. -/// This happens to be the case for quite some generated grpc types, so we use this to allow a simpler API for users. -/// -/// The generated str looks like this: -/// setter(into, strip_option), field(ty="Option<$ty>", build="convert_option(&$id)") -/// -/// For more infos of those atributes see the [dervie_builder's docs](https://docs.rs/derive_builder/latest/derive_builder/#completely-custom-fields-in-the-builder) -macro_rules! builder_custom_into { - ($ty:ty, $id:expr) => { - // Builds the following string as &'static str: - // setter(into, strip_option), field(ty="Option<$ty>", build="convert_option(&$id)") - concat!( - "setter(into, strip_option)", - ",", - concat!("field(ty=\"", "Option<", stringify!($ty), ">\""), - ",", - concat!("build=\"", "convert_option(&", stringify!($id), ")\""), - ")" - ) - }; -} - -fn configure_builder(builder: Builder) -> Builder { - const DEFAULT_OPTION: &str = "default, setter(strip_option), field(vis=\"pub(crate)\")"; - const DEFAULT_OPTION_INTO: &str = - "default, setter(into, strip_option), field(vis=\"pub(crate)\")"; - const DEFAULT: &str = "default, field(vis=\"pub(crate)\")"; - const DEFAULT_INTO: &str = "default, setter(into), field(vis=\"pub(crate)\")"; - const CUSTOM_SETTER: &str = "default, setter(custom), field(vis=\"pub(crate)\")"; - const PUBLIC_ONLY: &str = r#"field(vis = "pub(crate)")"#; - - builder.derive_builders( - &[ - // VectorParams - ("VectorParams.size", DEFAULT), - ("VectorParams.distance", DEFAULT_INTO), - ("VectorParams.hnsw_config", DEFAULT_OPTION_INTO), - // ("VectorParams.quantization_config", DEFAULT_OPTION_INTO), - ( - "VectorParams.quantization_config", - builder_custom_into!(quantization_config::Quantization, self.quantization_config), - ), - ("VectorParams.on_disk", DEFAULT_OPTION), - ("VectorParams.datatype", DEFAULT_OPTION_INTO), - ("VectorParams.multivector_config", DEFAULT_OPTION_INTO), - // Create collection - ("CreateCollection.collection_name", DEFAULT_INTO), - ("CreateCollection.hnsw_config", DEFAULT_OPTION_INTO), - ("CreateCollection.wal_config", DEFAULT_OPTION_INTO), - ("CreateCollection.optimizers_config", DEFAULT_OPTION_INTO), - ("CreateCollection.shard_number", DEFAULT_OPTION), - ("CreateCollection.on_disk_payload", DEFAULT_OPTION), - ("CreateCollection.timeout", DEFAULT_OPTION), - ("CreateCollection.vectors_config", DEFAULT_OPTION_INTO), - ("CreateCollection.replication_factor", DEFAULT_OPTION), - ("CreateCollection.write_consistency_factor", DEFAULT_OPTION), - ("CreateCollection.init_from_collection", DEFAULT_OPTION_INTO), - ( - "CreateCollection.quantization_config", - builder_custom_into!(quantization_config::Quantization, self.quantization_config), - ), - ("CreateCollection.sharding_method", DEFAULT_OPTION), - ( - "CreateCollection.sparse_vectors_config", - DEFAULT_OPTION_INTO, - ), - ("CreateCollection.strict_mode_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), - // ScalarQuantization - ("ScalarQuantization.type", PUBLIC_ONLY), - ("ScalarQuantization.quantile", DEFAULT_OPTION), - ("ScalarQuantization.always_ram", DEFAULT_OPTION), - // ProductQuantization - ("ProductQuantization.compression", PUBLIC_ONLY), - ("ProductQuantization.always_ram", DEFAULT_OPTION), - // BinaryQuantization - ("BinaryQuantization.always_ram", DEFAULT_OPTION), - // OptimizersConfigDiff - ("OptimizersConfigDiff.deleted_threshold", DEFAULT_OPTION), - ( - "OptimizersConfigDiff.vacuum_min_vector_number", - DEFAULT_OPTION, - ), - ( - "OptimizersConfigDiff.default_segment_number", - DEFAULT_OPTION, - ), - ("OptimizersConfigDiff.max_segment_size", DEFAULT_OPTION), - ("OptimizersConfigDiff.memmap_threshold", DEFAULT_OPTION), - ("OptimizersConfigDiff.indexing_threshold", DEFAULT_OPTION), - ("OptimizersConfigDiff.flush_interval_sec", DEFAULT_OPTION), - ( - "OptimizersConfigDiff.max_optimization_threads", - DEFAULT_OPTION, - ), - //WalConfigDiff - ("WalConfigDiff.wal_capacity_mb", DEFAULT_OPTION), - ("WalConfigDiff.wal_segments_ahead", DEFAULT_OPTION), - // SearchPoints - ("SearchPoints.collection_name", PUBLIC_ONLY), - ("SearchPoints.vector", PUBLIC_ONLY), - ("SearchPoints.limit", PUBLIC_ONLY), - ("SearchPoints.filter", DEFAULT_OPTION_INTO), - ( - "SearchPoints.with_payload", - builder_custom_into!(with_payload_selector::SelectorOptions, self.with_payload), - ), - ("SearchPoints.params", DEFAULT_OPTION_INTO), - ("SearchPoints.score_threshold", DEFAULT_OPTION), - ("SearchPoints.offset", DEFAULT_OPTION), - ("SearchPoints.vector_name", DEFAULT_OPTION_INTO), - ( - "SearchPoints.with_vectors", - builder_custom_into!(with_vectors_selector::SelectorOptions, self.with_vectors), - ), - ( - "SearchPoints.read_consistency", - builder_custom_into!(read_consistency::Value, self.read_consistency), - ), - ("SearchPoints.timeout", DEFAULT_OPTION), - ("SearchPoints.shard_key_selector", DEFAULT_OPTION_INTO), - ("SearchPoints.sparse_indices", DEFAULT_OPTION_INTO), - // SearchParams - ("SearchParams.hnsw_ef", DEFAULT_OPTION), - ("SearchParams.exact", DEFAULT_OPTION), - ("SearchParams.quantization", DEFAULT_OPTION_INTO), - ("SearchParams.indexed_only", DEFAULT_OPTION), - // QuantizationSearchParams - ("QuantizationSearchParams.ignore", DEFAULT_OPTION), - ("QuantizationSearchParams.rescore", DEFAULT_OPTION), - ("QuantizationSearchParams.oversampling", DEFAULT_OPTION), - // UpdateCollection - ("UpdateCollection.collection_name", PUBLIC_ONLY), - ("UpdateCollection.optimizers_config", DEFAULT_OPTION_INTO), - ("UpdateCollection.timeout", DEFAULT_OPTION), - ("UpdateCollection.params", DEFAULT_OPTION_INTO), - ("UpdateCollection.hnsw_config", DEFAULT_OPTION_INTO), - ("UpdateCollection.vectors_config", DEFAULT_OPTION_INTO), - ( - "UpdateCollection.quantization_config", - builder_custom_into!( - quantization_config_diff::Quantization, - self.quantization_config - ), - ), - ( - "UpdateCollection.sparse_vectors_config", - DEFAULT_OPTION_INTO, - ), - // SetPayloadPoints - ("SetPayloadPoints.collection_name", PUBLIC_ONLY), - ("SetPayloadPoints.payload", PUBLIC_ONLY), - ("SetPayloadPoints.wait", DEFAULT_OPTION), - ( - "SetPayloadPoints.points_selector", - builder_custom_into!(points_selector::PointsSelectorOneOf, self.points_selector), - ), - ("SetPayloadPoints.ordering", DEFAULT_OPTION_INTO), - ("SetPayloadPoints.shard_key_selector", DEFAULT_OPTION_INTO), - ("SetPayloadPoints.key", DEFAULT_OPTION_INTO), - // UpsertPoints - ("UpsertPoints.collection_name", PUBLIC_ONLY), - ("UpsertPoints.points", PUBLIC_ONLY), - ("UpsertPoints.wait", DEFAULT_OPTION), - ("UpsertPoints.ordering", DEFAULT_OPTION_INTO), - ("UpsertPoints.shard_key_selector", DEFAULT_OPTION_INTO), - // UpdateBatchPoints - ("UpdateBatchPoints.collection_name", PUBLIC_ONLY), - ("UpdateBatchPoints.operations", PUBLIC_ONLY), - ("UpdateBatchPoints.wait", DEFAULT_OPTION), - ("UpdateBatchPoints.ordering", DEFAULT_OPTION_INTO), - // DeletePayloadPoints - ("DeletePayloadPoints.collection_name", PUBLIC_ONLY), - ("DeletePayloadPoints.keys", PUBLIC_ONLY), - ("DeletePayloadPoints.wait", DEFAULT_OPTION), - ( - "DeletePayloadPoints.points_selector", - builder_custom_into!(points_selector::PointsSelectorOneOf, self.points_selector), - ), - ("DeletePayloadPoints.ordering", DEFAULT_OPTION_INTO), - ( - "DeletePayloadPoints.shard_key_selector", - DEFAULT_OPTION_INTO, - ), - // ClearPayloadPoints - ("ClearPayloadPoints.collection_name", PUBLIC_ONLY), - ("ClearPayloadPoints.wait", DEFAULT_OPTION), - ( - "ClearPayloadPoints.points", - builder_custom_into!(points_selector::PointsSelectorOneOf, self.points), - ), - ("ClearPayloadPoints.ordering", DEFAULT_OPTION_INTO), - ("ClearPayloadPoints.shard_key_selector", DEFAULT_OPTION_INTO), - // GetPoints - ("GetPoints.collection_name", PUBLIC_ONLY), - ("GetPoints.ids", PUBLIC_ONLY), - ( - "GetPoints.with_payload", - builder_custom_into!(with_payload_selector::SelectorOptions, self.with_payload), - ), - ( - "GetPoints.with_vectors", - builder_custom_into!(with_vectors_selector::SelectorOptions, self.with_vectors), - ), - ( - "GetPoints.read_consistency", - builder_custom_into!(read_consistency::Value, self.read_consistency), - ), - ("GetPoints.shard_key_selector", DEFAULT_OPTION_INTO), - ("GetPoints.timeout", DEFAULT_OPTION), - // SearchBatchPoints - ("SearchBatchPoints.collection_name", PUBLIC_ONLY), - ("SearchBatchPoints.search_points", PUBLIC_ONLY), - ( - "SearchBatchPoints.read_consistency", - builder_custom_into!(read_consistency::Value, self.read_consistency), - ), - ("SearchBatchPoints.timeout", DEFAULT_OPTION), - // SearchPointGroups - ("SearchPointGroups.collection_name", PUBLIC_ONLY), - ("SearchPointGroups.vector", PUBLIC_ONLY), - ("SearchPointGroups.limit", PUBLIC_ONLY), - ("SearchPointGroups.group_by", PUBLIC_ONLY), - ("SearchPointGroups.group_size", PUBLIC_ONLY), - ("SearchPointGroups.filter", DEFAULT_OPTION_INTO), - ( - "SearchPointGroups.with_payload", - builder_custom_into!(with_payload_selector::SelectorOptions, self.with_payload), - ), - ("SearchPointGroups.params", DEFAULT_OPTION_INTO), - ("SearchPointGroups.score_threshold", DEFAULT_OPTION_INTO), - ("SearchPointGroups.vector_name", DEFAULT_OPTION_INTO), - ( - "SearchPointGroups.with_vectors", - builder_custom_into!(with_vectors_selector::SelectorOptions, self.with_vectors), - ), - ( - "SearchPointGroups.read_consistency", - builder_custom_into!(read_consistency::Value, self.read_consistency), - ), - ("SearchPointGroups.with_lookup", DEFAULT_OPTION_INTO), - ("SearchPointGroups.timeout", DEFAULT_OPTION_INTO), - ("SearchPointGroups.shard_key_selector", DEFAULT_OPTION_INTO), - ("SearchPointGroups.sparse_indices", DEFAULT_OPTION_INTO), - // WithLookup - ("WithLookup.collection", PUBLIC_ONLY), - ( - "WithLookup.with_payload", - builder_custom_into!(with_payload_selector::SelectorOptions, self.with_payload), - ), - ( - "WithLookup.with_vectors", - builder_custom_into!(with_vectors_selector::SelectorOptions, self.with_vectors), - ), - // DeletePoints - ("qdrant.DeletePoints.collection_name", PUBLIC_ONLY), - ("qdrant.DeletePoints.wait", DEFAULT_OPTION), - ( - "qdrant.DeletePoints.points", - builder_custom_into!(points_selector::PointsSelectorOneOf, self.points), - ), - ("qdrant.DeletePoints.ordering", DEFAULT_OPTION_INTO), - ( - "qdrant.DeletePoints.shard_key_selector", - DEFAULT_OPTION_INTO, - ), - // DeletePointVectors - ("DeletePointVectors.collection_name", PUBLIC_ONLY), - ("DeletePointVectors.wait", DEFAULT_OPTION), - ( - "DeletePointVectors.points_selector", - builder_custom_into!(points_selector::PointsSelectorOneOf, self.points_selector), - ), - ("DeletePointVectors.vectors", DEFAULT_OPTION_INTO), - ("DeletePointVectors.ordering", DEFAULT_OPTION_INTO), - ("DeletePointVectors.shard_key_selector", DEFAULT_OPTION_INTO), - // UpdatePointVectors - ("UpdatePointVectors.collection_name", PUBLIC_ONLY), - ("UpdatePointVectors.points", PUBLIC_ONLY), - ("UpdatePointVectors.wait", DEFAULT_OPTION), - ("UpdatePointVectors.ordering", DEFAULT_OPTION_INTO), - ("UpdatePointVectors.shard_key_selector", DEFAULT_OPTION_INTO), - // ScrollPoints - ("ScrollPoints.collection_name", PUBLIC_ONLY), - ("ScrollPoints.filter", DEFAULT_OPTION_INTO), - ("ScrollPoints.offset", DEFAULT_OPTION_INTO), - ("ScrollPoints.limit", DEFAULT_OPTION), - ( - "ScrollPoints.with_payload", - builder_custom_into!(with_payload_selector::SelectorOptions, self.with_payload), - ), - ( - "ScrollPoints.with_vectors", - builder_custom_into!(with_vectors_selector::SelectorOptions, self.with_vectors), - ), - ( - "ScrollPoints.read_consistency", - builder_custom_into!(read_consistency::Value, self.read_consistency), - ), - ("ScrollPoints.shard_key_selector", DEFAULT_OPTION_INTO), - ("ScrollPoints.order_by", DEFAULT_OPTION_INTO), - ("ScrollPoints.timeout", DEFAULT_OPTION), - // OrderBy - ("OrderBy.key", PUBLIC_ONLY), - ("OrderBy.direction", DEFAULT_OPTION), - ( - "OrderBy.start_from", - builder_custom_into!(start_from::Value, self.start_from), - ), - // RecommendPoints - ("RecommendPoints.collection_name", PUBLIC_ONLY), - ("RecommendPoints.limit", PUBLIC_ONLY), - ("RecommendPoints.filter", DEFAULT_OPTION_INTO), - ( - "RecommendPoints.with_payload", - builder_custom_into!(with_payload_selector::SelectorOptions, self.with_payload), - ), - ("RecommendPoints.params", DEFAULT_OPTION_INTO), - ("RecommendPoints.score_threshold", DEFAULT_OPTION), - ("RecommendPoints.offset", DEFAULT_OPTION), - ("RecommendPoints.using", DEFAULT_OPTION_INTO), - ( - "RecommendPoints.with_vectors", - builder_custom_into!(with_vectors_selector::SelectorOptions, self.with_vectors), - ), - ("RecommendPoints.lookup_from", DEFAULT_OPTION_INTO), - ("RecommendPoints.positive", CUSTOM_SETTER), - ("RecommendPoints.negative", CUSTOM_SETTER), - ("RecommendPoints.positive_vectors", CUSTOM_SETTER), - ("RecommendPoints.negative_vectors", CUSTOM_SETTER), - ( - "RecommendPoints.read_consistency", - builder_custom_into!(read_consistency::Value, self.read_consistency), - ), - ("RecommendPoints.strategy", DEFAULT_OPTION_INTO), - ("RecommendPoints.timeout", DEFAULT_OPTION), - ("RecommendPoints.shard_key_selector", DEFAULT_OPTION_INTO), - // LookupLocation - ("LookupLocation.collection_name", PUBLIC_ONLY), - ("LookupLocation.vector_name", DEFAULT_OPTION_INTO), - ("LookupLocation.shard_key_selector", DEFAULT_OPTION_INTO), - // RecommendBatchPoints - ("RecommendBatchPoints.collection_name", PUBLIC_ONLY), - ("RecommendBatchPoints.recommend_points", PUBLIC_ONLY), - ( - "RecommendBatchPoints.read_consistency", - builder_custom_into!(read_consistency::Value, self.read_consistency), - ), - ("RecommendBatchPoints.timeout", DEFAULT_OPTION), - // RecommendPointGroups - ("RecommendPointGroups.collection_name", PUBLIC_ONLY), - ("RecommendPointGroups.group_by", PUBLIC_ONLY), - ("RecommendPointGroups.group_size", PUBLIC_ONLY), - ("RecommendPointGroups.limit", PUBLIC_ONLY), - ("RecommendPointGroups.filter", DEFAULT_OPTION_INTO), - ( - "RecommendPointGroups.with_payload", - builder_custom_into!(with_payload_selector::SelectorOptions, self.with_payload), - ), - ("RecommendPointGroups.params", DEFAULT_OPTION_INTO), - ("RecommendPointGroups.score_threshold", DEFAULT_OPTION), - ("RecommendPointGroups.using", DEFAULT_OPTION_INTO), - ( - "RecommendPointGroups.with_vectors", - builder_custom_into!(with_vectors_selector::SelectorOptions, self.with_vectors), - ), - ("RecommendPointGroups.positive", CUSTOM_SETTER), - ("RecommendPointGroups.negative", CUSTOM_SETTER), - ("RecommendPointGroups.positive_vectors", CUSTOM_SETTER), - ("RecommendPointGroups.negative_vectors", CUSTOM_SETTER), - ("RecommendPointGroups.lookup_from", DEFAULT_OPTION_INTO), - ( - "RecommendPointGroups.read_consistency", - builder_custom_into!(read_consistency::Value, self.read_consistency), - ), - ("RecommendPointGroups.with_lookup", DEFAULT_OPTION_INTO), - ("RecommendPointGroups.strategy", DEFAULT_OPTION_INTO), - ("RecommendPointGroups.timeout", DEFAULT_OPTION), - ( - "RecommendPointGroups.shard_key_selector", - DEFAULT_OPTION_INTO, - ), - // DiscoverPoints - ("DiscoverPoints.collection_name", PUBLIC_ONLY), - ("DiscoverPoints.context", PUBLIC_ONLY), - ("DiscoverPoints.limit", PUBLIC_ONLY), - ("DiscoverPoints.target", DEFAULT_OPTION_INTO), - ("DiscoverPoints.filter", DEFAULT_OPTION_INTO), - ( - "DiscoverPoints.with_payload", - builder_custom_into!(with_payload_selector::SelectorOptions, self.with_payload), - ), - ("DiscoverPoints.params", DEFAULT_OPTION_INTO), - ("DiscoverPoints.offset", DEFAULT_OPTION), - ("DiscoverPoints.using", DEFAULT_OPTION_INTO), - ( - "DiscoverPoints.with_vectors", - builder_custom_into!(with_vectors_selector::SelectorOptions, self.with_vectors), - ), - ("DiscoverPoints.lookup_from", DEFAULT_OPTION_INTO), - ( - "DiscoverPoints.read_consistency", - builder_custom_into!(read_consistency::Value, self.read_consistency), - ), - ("DiscoverPoints.timeout", DEFAULT_OPTION), - ("DiscoverPoints.shard_key_selector", DEFAULT_OPTION_INTO), - // DiscoverBatchPoints - ("DiscoverBatchPoints.collection_name", PUBLIC_ONLY), - ("DiscoverBatchPoints.discover_points", PUBLIC_ONLY), - ( - "DiscoverBatchPoints.read_consistency", - builder_custom_into!(read_consistency::Value, self.read_consistency), - ), - ("DiscoverBatchPoints.timeout", DEFAULT_OPTION), - // PrefetchQuery - ("PrefetchQuery.prefetch", DEFAULT_OPTION_INTO), - ("PrefetchQuery.query", DEFAULT_OPTION_INTO), - ("PrefetchQuery.using", DEFAULT_OPTION_INTO), - ("PrefetchQuery.filter", DEFAULT_OPTION_INTO), - ("PrefetchQuery.params", DEFAULT_OPTION_INTO), - ("PrefetchQuery.score_threshold", DEFAULT_OPTION_INTO), - ("PrefetchQuery.limit", DEFAULT_OPTION_INTO), - ("PrefetchQuery.lookup_from", DEFAULT_OPTION_INTO), - // Query - ("QueryPoints.collection_name", PUBLIC_ONLY), - ("QueryPoints.prefetch", DEFAULT_OPTION_INTO), - ("QueryPoints.query", DEFAULT_OPTION_INTO), - ("QueryPoints.using", DEFAULT_OPTION_INTO), - ("QueryPoints.filter", DEFAULT_OPTION_INTO), - ("QueryPoints.params", DEFAULT_OPTION_INTO), - ("QueryPoints.score_threshold", DEFAULT_OPTION_INTO), - ("QueryPoints.limit", DEFAULT_OPTION), - ("QueryPoints.offset", DEFAULT_OPTION), - ( - "QueryPoints.with_payload", - builder_custom_into!(with_payload_selector::SelectorOptions, self.with_payload), - ), - ( - "QueryPoints.with_vectors", - builder_custom_into!(with_vectors_selector::SelectorOptions, self.with_vectors), - ), - ( - "QueryPoints.read_consistency", - builder_custom_into!(read_consistency::Value, self.read_consistency), - ), - ("QueryPoints.shard_key_selector", DEFAULT_OPTION_INTO), - ("QueryPoints.lookup_from", DEFAULT_OPTION_INTO), - ("QueryPoints.timeout", DEFAULT_OPTION), - // QueryBatchPoints - ("QueryBatchPoints.collection_name", PUBLIC_ONLY), - ("QueryBatchPoints.query_points", PUBLIC_ONLY), - ( - "QueryBatchPoints.read_consistency", - builder_custom_into!(read_consistency::Value, self.read_consistency), - ), - ("QueryBatchPoints.timeout", DEFAULT_OPTION), - // CountPoints - ("CountPoints.collection_name", PUBLIC_ONLY), - ("CountPoints.filter", DEFAULT_OPTION_INTO), - ("CountPoints.exact", DEFAULT_OPTION), - ( - "CountPoints.read_consistency", - builder_custom_into!(read_consistency::Value, self.read_consistency), - ), - ("CountPoints.shard_key_selector", DEFAULT_OPTION_INTO), - ("CountPoints.timeout", DEFAULT_OPTION), - // CreateFieldIndexCollection - ("CreateFieldIndexCollection.collection_name", PUBLIC_ONLY), - ("CreateFieldIndexCollection.field_name", PUBLIC_ONLY), - ("CreateFieldIndexCollection.wait", DEFAULT_OPTION), - ("CreateFieldIndexCollection.field_type", DEFAULT_OPTION_INTO), - ( - "CreateFieldIndexCollection.field_index_params", - builder_custom_into!(payload_index_params::IndexParams, self.field_index_params), - ), - ("CreateFieldIndexCollection.ordering", DEFAULT_OPTION_INTO), - // DeleteFieldIndexCollection - ("DeleteFieldIndexCollection.collection_name", PUBLIC_ONLY), - ("DeleteFieldIndexCollection.field_name", PUBLIC_ONLY), - ("DeleteFieldIndexCollection.wait", DEFAULT_OPTION), - ("DeleteFieldIndexCollection.ordering", DEFAULT_OPTION), - // UpdateCollectionClusterSetupRequest - ( - "UpdateCollectionClusterSetupRequest.collection_name", - PUBLIC_ONLY, - ), - ( - "UpdateCollectionClusterSetupRequest.timeout", - DEFAULT_OPTION, - ), - ("UpdateCollectionClusterSetupRequest.operation", PUBLIC_ONLY), - // MoveShard - ("MoveShard.shard_id", PUBLIC_ONLY), - ("MoveShard.to_shard_id", DEFAULT_OPTION), - ("MoveShard.from_peer_id", PUBLIC_ONLY), - ("MoveShard.to_peer_id", PUBLIC_ONLY), - ("MoveShard.method", DEFAULT_OPTION_INTO), - // ReplicateShard - ("ReplicateShard.shard_id", PUBLIC_ONLY), - ("ReplicateShard.to_shard_id", DEFAULT_OPTION), - ("ReplicateShard.from_peer_id", PUBLIC_ONLY), - ("ReplicateShard.to_peer_id", PUBLIC_ONLY), - ("ReplicateShard.method", DEFAULT_OPTION_INTO), - // AbortShardTransfer - ("AbortShardTransfer.shard_id", PUBLIC_ONLY), - ("AbortShardTransfer.to_shard_id", DEFAULT_OPTION), - ("AbortShardTransfer.from_peer_id", PUBLIC_ONLY), - ("AbortShardTransfer.to_peer_id", PUBLIC_ONLY), - // Replica - ("Replica.shard_id", PUBLIC_ONLY), - ("Replica.peer_id", PUBLIC_ONLY), - // CreateShardKeyRequest - ("CreateShardKeyRequest.collection_name", PUBLIC_ONLY), - ("CreateShardKeyRequest.request", DEFAULT_OPTION_INTO), - ("CreateShardKeyRequest.timeout", DEFAULT_OPTION), - // DeleteShardKeyRequest - ("DeleteShardKeyRequest.collection_name", PUBLIC_ONLY), - ("DeleteShardKeyRequest.request", CUSTOM_SETTER), - ("DeleteShardKeyRequest.timeout", DEFAULT_OPTION), - // DeleteCollection - ("DeleteCollection.collection_name", PUBLIC_ONLY), - ("DeleteCollection.timeout", DEFAULT_OPTION), - // CollectionParamsDiff - ("CollectionParamsDiff.replication_factor", DEFAULT_OPTION), - ( - "CollectionParamsDiff.write_consistency_factor", - DEFAULT_OPTION, - ), - ("CollectionParamsDiff.on_disk_payload", DEFAULT_OPTION), - ("CollectionParamsDiff.read_fan_out_factor", DEFAULT_OPTION), - // VectorParamsDiff - ("VectorParamsDiff.hnsw_config", DEFAULT_OPTION_INTO), - ( - "VectorParamsDiff.quantization_config", - builder_custom_into!( - quantization_config_diff::Quantization, - self.quantization_config - ), - ), - ("VectorParamsDiff.on_disk", DEFAULT_OPTION), - // SparseVectorParams - ("SparseVectorParams.index", DEFAULT_OPTION_INTO), - ("SparseVectorParams.modifier", DEFAULT_OPTION_INTO), - // SparseIndexConfig - ("SparseIndexConfig.full_scan_threshold", DEFAULT_OPTION_INTO), - ("SparseIndexConfig.on_disk", DEFAULT_OPTION), - ("SparseIndexConfig.datatype", DEFAULT_OPTION_INTO), - // CreateShardKey - ("CreateShardKey.shard_key", DEFAULT_OPTION_INTO), - ("CreateShardKey.shards_number", DEFAULT_OPTION), - ("CreateShardKey.replication_factor", DEFAULT_OPTION), - ("CreateShardKey.placement", DEFAULT_OPTION), - // ContextExamplePair - ("ContextExamplePair.positive", DEFAULT_OPTION_INTO), - ("ContextExamplePair.negative", DEFAULT_OPTION_INTO), - // TextIndexParams - ("TextIndexParams.tokenizer", PUBLIC_ONLY), - ("TextIndexParams.lowercase", DEFAULT_OPTION), - ("TextIndexParams.min_token_len", DEFAULT_OPTION), - ("TextIndexParams.max_token_len", DEFAULT_OPTION), - ("TextIndexParams.on_disk", DEFAULT_OPTION), - // CreateAlias - ("CreateAlias.collection_name", PUBLIC_ONLY), - ("CreateAlias.alias_name", PUBLIC_ONLY), - // RenameAlias - ("RenameAlias.old_alias_name", PUBLIC_ONLY), - ("RenameAlias.new_alias_name", PUBLIC_ONLY), - // DeleteSnapshotRequest - ("DeleteSnapshotRequest.collection_name", PUBLIC_ONLY), - ("DeleteSnapshotRequest.snapshot_name", PUBLIC_ONLY), - // IntegerIndexParams - ("IntegerIndexParams.lookup", DEFAULT_OPTION_INTO), - ("IntegerIndexParams.range", DEFAULT_OPTION_INTO), - ("IntegerIndexParams.is_principal", DEFAULT_OPTION), - ("IntegerIndexParams.on_disk", DEFAULT_OPTION), - // KeywordIndexParams - ("KeywordIndexParams.is_tenant", DEFAULT_OPTION), - ("KeywordIndexParams.on_disk", DEFAULT_OPTION), - // FloatIndexParams - ("FloatIndexParams.is_principal", DEFAULT_OPTION), - ("FloatIndexParams.on_disk", DEFAULT_OPTION), - // GeoIndexParams - ("GeoIndexParams.on_disk", DEFAULT_OPTION), - // DatetimeIndexParams - ("DatetimeIndexParams.is_principal", DEFAULT_OPTION), - ("DatetimeIndexParams.on_disk", DEFAULT_OPTION), - // UuidIndexParams - ("UuidIndexParams.is_tenant", DEFAULT_OPTION), - ("UuidIndexParams.on_disk", DEFAULT_OPTION), - // RecommendInput - ("RecommendInput.positive", DEFAULT_OPTION_INTO), - ("RecommendInput.negative", DEFAULT_OPTION_INTO), - ("RecommendInput.strategy", DEFAULT_OPTION_INTO), - // DiscoverInput - ("DiscoverInput.target", DEFAULT_OPTION_INTO), - ("DiscoverInput.context", DEFAULT_OPTION_INTO), - // ContextInput - ("ContextInput.pairs", DEFAULT_OPTION_INTO), - // ContextInputPair - ("ContextInputPair.positive", DEFAULT_OPTION_INTO), - ("ContextInputPair.negative", DEFAULT_OPTION_INTO), - // MultiVectorConfig - ("MultiVectorConfig.comparator", DEFAULT_OPTION_INTO), - // QueryPointGroups - ("QueryPointGroups.collection_name", PUBLIC_ONLY), - ("QueryPointGroups.prefetch", DEFAULT_OPTION_INTO), - ("QueryPointGroups.group_by", PUBLIC_ONLY), - ("QueryPointGroups.query", DEFAULT_OPTION_INTO), - ("QueryPointGroups.using", DEFAULT_OPTION_INTO), - ("QueryPointGroups.filter", DEFAULT_OPTION_INTO), - ("QueryPointGroups.params", DEFAULT_OPTION_INTO), - ("QueryPointGroups.score_threshold", DEFAULT_OPTION_INTO), - ("QueryPointGroups.with_payload", DEFAULT_OPTION_INTO), - ("QueryPointGroups.with_vectors", DEFAULT_OPTION_INTO), - ("QueryPointGroups.lookup_from", DEFAULT_OPTION_INTO), - ("QueryPointGroups.limit", DEFAULT_OPTION_INTO), - ("QueryPointGroups.group_size", DEFAULT_OPTION_INTO), - ("QueryPointGroups.read_consistency", DEFAULT_OPTION_INTO), - ("QueryPointGroups.with_lookup", DEFAULT_OPTION_INTO), - ("QueryPointGroups.timeout", DEFAULT_OPTION_INTO), - ("QueryPointGroups.shard_key_selector", DEFAULT_OPTION_INTO), - // StrictModeConfig - ("StrictModeConfig.enabled", DEFAULT_OPTION), - ("StrictModeConfig.max_query_limit", DEFAULT_OPTION), - ("StrictModeConfig.max_timeout", DEFAULT_OPTION), - ( - "StrictModeConfig.unindexed_filtering_retrieve", - DEFAULT_OPTION, - ), - ( - "StrictModeConfig.unindexed_filtering_update", - DEFAULT_OPTION, - ), - ("StrictModeConfig.search_max_hnsw_ef", DEFAULT_OPTION), - ("StrictModeConfig.search_allow_exact", DEFAULT_OPTION), - ("StrictModeConfig.search_max_oversampling", DEFAULT_OPTION), - // FacetCounts - ("FacetCounts.collection_name", PUBLIC_ONLY), - ("FacetCounts.key", PUBLIC_ONLY), - ("FacetCounts.filter", DEFAULT_OPTION_INTO), - ("FacetCounts.limit", DEFAULT_OPTION), - ("FacetCounts.exact", DEFAULT_OPTION), - ("FacetCounts.timeout", DEFAULT_OPTION), - ("FacetCounts.read_consistency", DEFAULT_OPTION_INTO), - ("FacetCounts.shard_key_selector", DEFAULT_OPTION_INTO), - // SearchMatrixPoints - ("SearchMatrixPoints.collection_name", PUBLIC_ONLY), - ("SearchMatrixPoints.filter", DEFAULT_OPTION_INTO), - ("SearchMatrixPoints.sample", DEFAULT_OPTION), - ("SearchMatrixPoints.limit", DEFAULT_OPTION), - ("SearchMatrixPoints.using", DEFAULT_OPTION_INTO), - ("SearchMatrixPoints.timeout", DEFAULT_OPTION), - ("SearchMatrixPoints.read_consistency", DEFAULT_OPTION_INTO), - ("SearchMatrixPoints.shard_key_selector", DEFAULT_OPTION_INTO), - ], - builder_derive_options(), - ) -} - -/// Builder configurations for grpc structs. -fn builder_derive_options() -> &'static [BuildDeriveOptions] { - // We populate our own .build() function that doesn't return a Result but the built type directly. - // For this we rename and make the automatically generated build function private. - // Infallible allows secure unwrapping and compiler errors on missing fields. - const DEFAULT_BUILDER_DERIVE_OPTIONS: &str = - "build_fn(private, error = \"std::convert::Infallible\", name = \"build_inner\"), pattern = \"owned\""; - const NO_DEFAULT_BUILDER_DERIVE_OPTIONS: &str = - "build_fn(private, name = \"build_inner\"), pattern = \"owned\", custom_constructor"; - - // Tuple structure: (Path, build attributes, 'from' macro generation enabled) - &[ - ( - "CreateCollection", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "VectorParams", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "HnswConfigDiff", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "ScalarQuantization", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "ProductQuantization", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "BinaryQuantization", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "OptimizersConfigDiff", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "WalConfigDiff", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "SearchPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "SearchParams", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "QuantizationSearchParams", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "UpdateCollection", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "SetPayloadPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "UpsertPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "UpdateBatchPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "DeletePayloadPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "ClearPayloadPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "GetPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "SearchBatchPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "SearchPointGroups", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "WithLookup", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "DeletePointVectors", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "UpdatePointVectors", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "ScrollPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "OrderBy", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "RecommendPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "LookupLocation", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "RecommendBatchPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "RecommendPointGroups", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "DiscoverPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "DiscoverBatchPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "QueryPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "QueryBatchPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "CountPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "CreateFieldIndexCollection", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "DeleteFieldIndexCollection", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "qdrant.DeletePoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::NoMacro, - ), - ( - "UpdateCollectionClusterSetupRequest", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "MoveShard", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "ReplicateShard", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "AbortShardTransfer", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "Replica", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "CreateShardKeyRequest", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "DeleteShardKeyRequest", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "DeleteCollection", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "CollectionParamsDiff", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "VectorParamsDiff", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "SparseVectorParams", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "SparseIndexConfig", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "CreateShardKey", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "ContextExamplePair", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "TextIndexParams", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "IntegerIndexParams", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "KeywordIndexParams", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "DatetimeIndexParams", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "UuidIndexParams", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "FloatIndexParams", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "GeoIndexParams", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "CreateAlias", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "RenameAlias", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "DeleteSnapshotRequest", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "PrefetchQuery", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "RecommendInput", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "DiscoverInput", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "ContextInput", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "ContextInputPair", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "MultiVectorConfig", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "QueryPointGroups", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "StrictModeConfig", - DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::DefaultImpl, - ), - ( - "FacetCounts", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ( - "SearchMatrixPoints", - NO_DEFAULT_BUILDER_DERIVE_OPTIONS, - MacroConfig::WithDefaultFn, - ), - ] -} - -fn additional_builder_derive_options() -> &'static [BuildDeriveOptions] { - &[("DeletePoints", "", MacroConfig::WithDefaultFn)] -} - -/// Returns a list of all unique structs that appear in a list of paths. -fn unique_structs_from_paths<'a, I>(paths: I, extra: &[&'a str]) -> Vec<&'a str> -where - I: IntoIterator, -{ - let mut derives = paths - .into_iter() - .map(|field| { - // Types themselves can also be specified directly with a path, separated by '.'. - // The last element is the fields name. We want to only strip the fields name and preserve - // the whole path to also identify types specified using one. - field.rsplit_once('.').unwrap().0 - }) - .collect::>(); - derives.extend(extra); - derives.sort_unstable(); - derives.dedup(); - derives } fn append_to_file(path: &str, line: &str) { @@ -1207,34 +71,3 @@ fn append_to_file(path: &str, line: &str) { ) .unwrap() } - -/// Generates all necessary macro calls for builders who should have them. -fn add_builder_macro_impls( - file: &str, - derive_options: &[BuildDeriveOptions], - additional: &[BuildDeriveOptions], -) { - let to_append = derive_options - .iter() - .chain(additional) - .filter_map(|(type_name, _, macro_config)| { - let macro_call = match macro_config { - MacroConfig::NoMacro => { - return None; - } - MacroConfig::DefaultImpl => { - format!("builder_type_conversions!({type_name}, {type_name}Builder);\n") - } - MacroConfig::WithDefaultFn => { - format!("builder_type_conversions!({type_name}, {type_name}Builder, true);\n") - } - }; - - Some(macro_call) - }) - .fold(String::new(), |mut s, line| { - s.push_str(&line); - s - }); - append_to_file(file, &to_append); -}