qdrant_edge/edge/builders/
prefetch.rs1use crate::common::types::ScoreType;
7use crate::segment::types::{Filter, SearchParams};
8use crate::shard::query::ScoringQuery;
9
10use crate::edge::requests::query::Prefetch;
11
12#[derive(Clone, Debug)]
17pub struct PrefetchBuilder {
18 prefetches: Vec<Prefetch>,
19 query: Option<ScoringQuery>,
20 limit: usize,
21 params: Option<SearchParams>,
22 filter: Option<Filter>,
23 score_threshold: Option<ScoreType>,
24}
25
26impl PrefetchBuilder {
27 pub fn new(limit: usize) -> Self {
28 let Prefetch {
29 prefetches,
30 query,
31 limit,
32 params,
33 filter,
34 score_threshold,
35 } = Prefetch::new(limit);
36 Self {
37 prefetches,
38 query,
39 limit,
40 params,
41 filter,
42 score_threshold,
43 }
44 }
45
46 pub fn prefetches(mut self, prefetches: Vec<Prefetch>) -> Self {
48 self.prefetches = prefetches;
49 self
50 }
51
52 pub fn add_prefetch(mut self, prefetch: Prefetch) -> Self {
53 self.prefetches.push(prefetch);
54 self
55 }
56
57 pub fn query(mut self, query: ScoringQuery) -> Self {
58 self.query = Some(query);
59 self
60 }
61
62 pub fn params(mut self, params: SearchParams) -> Self {
63 self.params = Some(params);
64 self
65 }
66
67 pub fn filter(mut self, filter: Filter) -> Self {
68 self.filter = Some(filter);
69 self
70 }
71
72 pub fn score_threshold(mut self, score_threshold: ScoreType) -> Self {
73 self.score_threshold = Some(score_threshold);
74 self
75 }
76
77 pub fn build(self) -> Prefetch {
78 let Self {
81 prefetches,
82 query,
83 limit,
84 params,
85 filter,
86 score_threshold,
87 } = self;
88 Prefetch {
89 prefetches,
90 query,
91 limit,
92 params,
93 filter,
94 score_threshold,
95 }
96 }
97}