@@ -16,13 +16,13 @@ use crate::types::{
16
16
#[ derive( Debug , Clone , PartialEq , Eq ) ]
17
17
#[ cfg_attr( any( test, feature = "testing" ) , derive( proptest_derive:: Arbitrary ) ) ]
18
18
pub struct TextIndexSnapshot {
19
- pub data : SearchIndexSnapshotData ,
19
+ pub data : TextIndexSnapshotData ,
20
20
pub ts : Timestamp ,
21
21
pub version : TextSnapshotVersion ,
22
22
}
23
23
24
24
#[ derive( Debug , Clone , PartialEq , Eq ) ]
25
- pub enum SearchIndexSnapshotData {
25
+ pub enum TextIndexSnapshotData {
26
26
/// The "legacy" (aka current) single segment format that must be built by
27
27
/// reading the entire table for each set of incremental updates.
28
28
SingleSegment ( ObjectKey ) ,
@@ -51,24 +51,24 @@ mod proptest {
51
51
52
52
use super :: {
53
53
FragmentedTextSegment ,
54
- SearchIndexSnapshotData ,
54
+ TextIndexSnapshotData ,
55
55
} ;
56
56
use crate :: types:: ObjectKey ;
57
57
58
- impl Arbitrary for SearchIndexSnapshotData {
58
+ impl Arbitrary for TextIndexSnapshotData {
59
59
type Parameters = ( ) ;
60
60
type Strategy = BoxedStrategy < Self > ;
61
61
62
62
fn arbitrary_with ( _args : Self :: Parameters ) -> Self :: Strategy {
63
63
prop_oneof ! [
64
- any:: <ObjectKey >( ) . prop_map( SearchIndexSnapshotData :: SingleSegment ) ,
65
- any:: <Vec <FragmentedTextSegment >>( ) . prop_map( SearchIndexSnapshotData :: MultiSegment ) ,
64
+ any:: <ObjectKey >( ) . prop_map( TextIndexSnapshotData :: SingleSegment ) ,
65
+ any:: <Vec <FragmentedTextSegment >>( ) . prop_map( TextIndexSnapshotData :: MultiSegment ) ,
66
66
any_with:: <ConvexObject >( (
67
67
size_range( 0 ..=4 ) ,
68
68
FieldType :: User ,
69
69
ExcludeSetsAndMaps ( true )
70
70
) )
71
- . prop_map( SearchIndexSnapshotData :: Unknown ) ,
71
+ . prop_map( TextIndexSnapshotData :: Unknown ) ,
72
72
]
73
73
. boxed ( )
74
74
}
@@ -77,7 +77,7 @@ mod proptest {
77
77
78
78
#[ derive( Serialize , Deserialize ) ]
79
79
#[ serde( tag = "data_type" , rename_all = "PascalCase" ) ]
80
- enum SerializedSearchIndexSnapshotData {
80
+ enum SerializedTextIndexSnapshotData {
81
81
SingleSegment {
82
82
segment : String ,
83
83
} ,
@@ -86,55 +86,53 @@ enum SerializedSearchIndexSnapshotData {
86
86
} ,
87
87
}
88
88
89
- impl TryFrom < WithUnknown < SerializedSearchIndexSnapshotData > > for SearchIndexSnapshotData {
89
+ impl TryFrom < WithUnknown < SerializedTextIndexSnapshotData > > for TextIndexSnapshotData {
90
90
type Error = anyhow:: Error ;
91
91
92
- fn try_from (
93
- value : WithUnknown < SerializedSearchIndexSnapshotData > ,
94
- ) -> Result < Self , Self :: Error > {
92
+ fn try_from ( value : WithUnknown < SerializedTextIndexSnapshotData > ) -> Result < Self , Self :: Error > {
95
93
match value {
96
- WithUnknown :: Known ( SerializedSearchIndexSnapshotData :: SingleSegment { segment } ) => Ok (
97
- SearchIndexSnapshotData :: SingleSegment ( ObjectKey :: try_from ( segment) ?) ,
94
+ WithUnknown :: Known ( SerializedTextIndexSnapshotData :: SingleSegment { segment } ) => Ok (
95
+ TextIndexSnapshotData :: SingleSegment ( ObjectKey :: try_from ( segment) ?) ,
98
96
) ,
99
- WithUnknown :: Known ( SerializedSearchIndexSnapshotData :: MultiSegment {
97
+ WithUnknown :: Known ( SerializedTextIndexSnapshotData :: MultiSegment {
100
98
segments : serialized_segments,
101
99
} ) => {
102
100
let segments: Vec < FragmentedTextSegment > = serialized_segments
103
101
. into_iter ( )
104
102
. map ( FragmentedTextSegment :: try_from)
105
103
. collect :: < anyhow:: Result < Vec < _ > > > ( ) ?;
106
- Ok ( SearchIndexSnapshotData :: MultiSegment ( segments) )
104
+ Ok ( TextIndexSnapshotData :: MultiSegment ( segments) )
107
105
} ,
108
- WithUnknown :: Unknown ( unknown) => Ok ( SearchIndexSnapshotData :: Unknown ( unknown) ) ,
106
+ WithUnknown :: Unknown ( unknown) => Ok ( TextIndexSnapshotData :: Unknown ( unknown) ) ,
109
107
}
110
108
}
111
109
}
112
110
113
- impl TryFrom < SearchIndexSnapshotData > for WithUnknown < SerializedSearchIndexSnapshotData > {
111
+ impl TryFrom < TextIndexSnapshotData > for WithUnknown < SerializedTextIndexSnapshotData > {
114
112
type Error = anyhow:: Error ;
115
113
116
- fn try_from ( value : SearchIndexSnapshotData ) -> Result < Self , Self :: Error > {
114
+ fn try_from ( value : TextIndexSnapshotData ) -> Result < Self , Self :: Error > {
117
115
match value {
118
- SearchIndexSnapshotData :: SingleSegment ( segment) => {
116
+ TextIndexSnapshotData :: SingleSegment ( segment) => {
119
117
let serialized_segment = segment. try_into ( ) ?;
120
118
Ok ( WithUnknown :: Known (
121
- SerializedSearchIndexSnapshotData :: SingleSegment {
119
+ SerializedTextIndexSnapshotData :: SingleSegment {
122
120
segment : serialized_segment,
123
121
} ,
124
122
) )
125
123
} ,
126
- SearchIndexSnapshotData :: MultiSegment ( segments) => {
124
+ TextIndexSnapshotData :: MultiSegment ( segments) => {
127
125
let serialized_segments: Vec < SerializedFragmentedTextSegment > = segments
128
126
. into_iter ( )
129
127
. map ( SerializedFragmentedTextSegment :: try_from)
130
128
. collect :: < anyhow:: Result < Vec < _ > > > ( ) ?;
131
129
Ok ( WithUnknown :: Known (
132
- SerializedSearchIndexSnapshotData :: MultiSegment {
130
+ SerializedTextIndexSnapshotData :: MultiSegment {
133
131
segments : serialized_segments,
134
132
} ,
135
133
) )
136
134
} ,
137
- SearchIndexSnapshotData :: Unknown ( unknown) => Ok ( WithUnknown :: Unknown ( unknown) ) ,
135
+ TextIndexSnapshotData :: Unknown ( unknown) => Ok ( WithUnknown :: Unknown ( unknown) ) ,
138
136
}
139
137
}
140
138
}
@@ -237,7 +235,7 @@ pub struct SerializedTextIndexSnapshot {
237
235
#[ serde( skip_serializing_if = "Option::is_none" ) ]
238
236
index : Option < String > ,
239
237
#[ serde( skip_serializing_if = "Option::is_none" ) ]
240
- data : Option < WithUnknown < SerializedSearchIndexSnapshotData > > ,
238
+ data : Option < WithUnknown < SerializedTextIndexSnapshotData > > ,
241
239
ts : i64 ,
242
240
version : i64 ,
243
241
}
@@ -246,7 +244,7 @@ impl TryFrom<TextIndexSnapshot> for SerializedTextIndexSnapshot {
246
244
type Error = anyhow:: Error ;
247
245
248
246
fn try_from ( snapshot : TextIndexSnapshot ) -> Result < Self , Self :: Error > {
249
- let ( index, data) = if let SearchIndexSnapshotData :: SingleSegment ( index) = snapshot. data {
247
+ let ( index, data) = if let TextIndexSnapshotData :: SingleSegment ( index) = snapshot. data {
250
248
( Some ( index. to_string ( ) ) , None )
251
249
} else {
252
250
( None , Some ( snapshot. data . try_into ( ) ?) )
@@ -264,10 +262,10 @@ impl TryFrom<SerializedTextIndexSnapshot> for TextIndexSnapshot {
264
262
type Error = anyhow:: Error ;
265
263
266
264
fn try_from ( serialized : SerializedTextIndexSnapshot ) -> Result < Self , Self :: Error > {
267
- let data: SearchIndexSnapshotData = if let Some ( index) = serialized. index {
268
- SearchIndexSnapshotData :: SingleSegment ( index. try_into ( ) ?)
265
+ let data: TextIndexSnapshotData = if let Some ( index) = serialized. index {
266
+ TextIndexSnapshotData :: SingleSegment ( index. try_into ( ) ?)
269
267
} else if let Some ( serialized_data) = serialized. data {
270
- SearchIndexSnapshotData :: try_from ( serialized_data) ?
268
+ TextIndexSnapshotData :: try_from ( serialized_data) ?
271
269
} else {
272
270
anyhow:: bail!( "Both data and index are missing!" ) ;
273
271
} ;
@@ -298,10 +296,10 @@ pub mod test {
298
296
use sync_types:: Timestamp ;
299
297
300
298
use crate :: {
301
- bootstrap_model:: index:: search_index :: {
299
+ bootstrap_model:: index:: text_index :: {
302
300
index_snapshot:: SerializedTextIndexSnapshot ,
303
- SearchIndexSnapshotData ,
304
301
TextIndexSnapshot ,
302
+ TextIndexSnapshotData ,
305
303
TextSnapshotVersion ,
306
304
} ,
307
305
types:: ObjectKey ,
@@ -348,7 +346,7 @@ pub mod test {
348
346
serde_json:: from_str( & serialized) . unwrap( ) ;
349
347
let deserialized_snapshot =
350
348
TextIndexSnapshot :: try_from( deserialize) . unwrap( ) ;
351
- must_let!( let SearchIndexSnapshotData :: SingleSegment ( key) = deserialized_snapshot. data) ;
349
+ must_let!( let TextIndexSnapshotData :: SingleSegment ( key) = deserialized_snapshot. data) ;
352
350
assert_eq!( key, ObjectKey :: try_from( snapshot. index) . unwrap( ) )
353
351
}
354
352
@@ -358,10 +356,10 @@ pub mod test {
358
356
fn test_parse_old_snapshot_from_new( snapshot in any:: <TextIndexSnapshot >( )
359
357
. prop_filter(
360
358
"only single segment is backwards compatible" ,
361
- |snapshot| matches!( snapshot. data, SearchIndexSnapshotData :: SingleSegment ( _) )
359
+ |snapshot| matches!( snapshot. data, TextIndexSnapshotData :: SingleSegment ( _) )
362
360
)
363
361
) {
364
- must_let!( let SearchIndexSnapshotData :: SingleSegment ( ref index) = & snapshot. data) ;
362
+ must_let!( let TextIndexSnapshotData :: SingleSegment ( ref index) = & snapshot. data) ;
365
363
let index = index. clone( ) ;
366
364
367
365
let serialized_data = SerializedTextIndexSnapshot :: try_from( snapshot) . unwrap( ) ;
0 commit comments