Skip to main content

qdrant_client/builders/
collection_params_diff_builder.rs

1use crate::qdrant::*;
2
3#[must_use]
4#[derive(Clone)]
5pub struct CollectionParamsDiffBuilder {
6    /// Number of replicas of each shard that network tries to maintain
7    pub(crate) replication_factor: Option<Option<u32>>,
8    /// How many replicas should apply the operation for us to consider it successful
9    pub(crate) write_consistency_factor: Option<Option<u32>>,
10    /// If true - point's payload will not be stored in memory
11    pub(crate) on_disk_payload: Option<Option<bool>>,
12    /// Fan-out every read request to these many additional remote nodes (and return first available response)
13    pub(crate) read_fan_out_factor: Option<Option<u32>>,
14    /// Fan-out delay in milliseconds. If set, the fan-out request will be delayed by this amount.
15    pub(crate) read_fan_out_delay_ms: Option<Option<u64>>,
16    /// Update params of the payload storage
17    pub(crate) payload: Option<Option<PayloadStorageParams>>,
18    /// Update params of the point id tracker
19    pub(crate) id_tracker: Option<Option<IdTrackerParams>>,
20}
21#[allow(clippy::all)]
22#[allow(clippy::derive_partial_eq_without_eq)]
23impl CollectionParamsDiffBuilder {
24    /// Number of replicas of each shard that network tries to maintain
25    pub fn replication_factor(self, value: u32) -> Self {
26        let mut new = self;
27        new.replication_factor = Option::Some(Option::Some(value));
28        new
29    }
30    /// How many replicas should apply the operation for us to consider it successful
31    pub fn write_consistency_factor(self, value: u32) -> Self {
32        let mut new = self;
33        new.write_consistency_factor = Option::Some(Option::Some(value));
34        new
35    }
36    /// If true - point's payload will not be stored in memory
37    ///
38    /// Deprecated since 1.19.0, use [`payload`](Self::payload) instead.
39    pub fn on_disk_payload(self, value: bool) -> Self {
40        let mut new = self;
41        new.on_disk_payload = Option::Some(Option::Some(value));
42        new
43    }
44    /// Fan-out every read request to these many additional remote nodes (and return first available response)
45    pub fn read_fan_out_factor(self, value: u32) -> Self {
46        let mut new = self;
47        new.read_fan_out_factor = Option::Some(Option::Some(value));
48        new
49    }
50    /// Fan-out delay in milliseconds. If set, the fan-out request will be delayed by this amount.
51    pub fn read_fan_out_delay_ms(self, value: u64) -> Self {
52        let mut new = self;
53        new.read_fan_out_delay_ms = Option::Some(Option::Some(value));
54        new
55    }
56    /// Update params of the payload storage.
57    /// Overrides the deprecated `on_disk_payload` flag if both are set.
58    pub fn payload<VALUE: core::convert::Into<PayloadStorageParams>>(self, value: VALUE) -> Self {
59        let mut new = self;
60        new.payload = Option::Some(Option::Some(value.into()));
61        new
62    }
63    /// Update params of the point id tracker.
64    pub fn id_tracker<VALUE: core::convert::Into<IdTrackerParams>>(self, value: VALUE) -> Self {
65        let mut new = self;
66        new.id_tracker = Option::Some(Option::Some(value.into()));
67        new
68    }
69
70    #[allow(deprecated)]
71    fn build_inner(self) -> Result<CollectionParamsDiff, std::convert::Infallible> {
72        Ok(CollectionParamsDiff {
73            replication_factor: match self.replication_factor {
74                Some(value) => value,
75                None => core::default::Default::default(),
76            },
77            write_consistency_factor: match self.write_consistency_factor {
78                Some(value) => value,
79                None => core::default::Default::default(),
80            },
81            on_disk_payload: match self.on_disk_payload {
82                Some(value) => value,
83                None => core::default::Default::default(),
84            },
85            read_fan_out_factor: match self.read_fan_out_factor {
86                Some(value) => value,
87                None => core::default::Default::default(),
88            },
89            read_fan_out_delay_ms: match self.read_fan_out_delay_ms {
90                Some(value) => value,
91                None => core::default::Default::default(),
92            },
93            payload: match self.payload {
94                Some(value) => value,
95                None => core::default::Default::default(),
96            },
97            id_tracker: match self.id_tracker {
98                Some(value) => value,
99                None => core::default::Default::default(),
100            },
101        })
102    }
103    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
104    fn create_empty() -> Self {
105        Self {
106            replication_factor: core::default::Default::default(),
107            write_consistency_factor: core::default::Default::default(),
108            on_disk_payload: core::default::Default::default(),
109            read_fan_out_factor: core::default::Default::default(),
110            read_fan_out_delay_ms: core::default::Default::default(),
111            payload: core::default::Default::default(),
112            id_tracker: core::default::Default::default(),
113        }
114    }
115}
116
117impl From<CollectionParamsDiffBuilder> for CollectionParamsDiff {
118    fn from(value: CollectionParamsDiffBuilder) -> Self {
119        value.build_inner().unwrap_or_else(|_| {
120            panic!(
121                "Failed to convert {0} to {1}",
122                "CollectionParamsDiffBuilder", "CollectionParamsDiff"
123            )
124        })
125    }
126}
127
128impl CollectionParamsDiffBuilder {
129    /// Builds the desired type. Can often be omitted.
130    pub fn build(self) -> CollectionParamsDiff {
131        self.build_inner().unwrap_or_else(|_| {
132            panic!(
133                "Failed to build {0} into {1}",
134                "CollectionParamsDiffBuilder", "CollectionParamsDiff"
135            )
136        })
137    }
138}
139
140impl Default for CollectionParamsDiffBuilder {
141    fn default() -> Self {
142        Self::create_empty()
143    }
144}