Skip to content

Commit 082360e

Browse files
sjuddConvex, Inc.
authored andcommitted
Rename another round of things Search -> Text (#25862)
GitOrigin-RevId: 6e6c269e94927226d0bc1adfaf9667d1f5980d95
1 parent 8d101cf commit 082360e

29 files changed

+184
-184
lines changed

crates/common/src/bootstrap_model/index/developer_index_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use super::{
1111
DeveloperDatabaseIndexConfig,
1212
SerializedDeveloperDatabaseIndexConfig,
1313
},
14-
search_index::{
14+
text_index::{
1515
DeveloperSearchIndexConfig,
1616
SerializedDeveloperSearchIndexConfig,
1717
},

crates/common/src/bootstrap_model/index/index_config.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use super::{
1313
SerializedDatabaseIndexState,
1414
SerializedDeveloperDatabaseIndexConfig,
1515
},
16-
search_index::{
16+
text_index::{
1717
DeveloperSearchIndexConfig,
18-
SearchIndexState,
1918
SerializedDeveloperSearchIndexConfig,
20-
SerializedSearchIndexState,
19+
SerializedTextIndexState,
20+
TextIndexState,
2121
},
2222
vector_index::{
2323
DeveloperVectorIndexConfig,
@@ -45,7 +45,7 @@ pub enum IndexConfig {
4545
developer_config: DeveloperSearchIndexConfig,
4646

4747
/// Whether the index is fully backfilled or not on disk.
48-
on_disk_state: SearchIndexState,
48+
on_disk_state: TextIndexState,
4949
},
5050

5151
Vector {
@@ -61,7 +61,7 @@ impl IndexConfig {
6161
matches!(on_disk_state, DatabaseIndexState::Enabled)
6262
},
6363
IndexConfig::Search { on_disk_state, .. } => {
64-
matches!(on_disk_state, SearchIndexState::SnapshottedAt(_))
64+
matches!(on_disk_state, TextIndexState::SnapshottedAt(_))
6565
},
6666
IndexConfig::Vector { on_disk_state, .. } => {
6767
matches!(on_disk_state, VectorIndexState::SnapshottedAt(_))
@@ -75,7 +75,7 @@ impl IndexConfig {
7575
matches!(on_disk_state, DatabaseIndexState::Backfilling(_))
7676
},
7777
IndexConfig::Search { on_disk_state, .. } => {
78-
matches!(on_disk_state, SearchIndexState::Backfilling(_))
78+
matches!(on_disk_state, TextIndexState::Backfilling(_))
7979
},
8080
IndexConfig::Vector { on_disk_state, .. } => {
8181
matches!(on_disk_state, VectorIndexState::Backfilling(_))
@@ -166,7 +166,7 @@ pub enum SerializedIndexConfig {
166166
Search {
167167
#[serde(flatten)]
168168
developer_config: SerializedDeveloperSearchIndexConfig,
169-
on_disk_state: SerializedSearchIndexState,
169+
on_disk_state: SerializedTextIndexState,
170170
},
171171
#[serde(rename_all = "camelCase")]
172172
Vector {

crates/common/src/bootstrap_model/index/index_metadata.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ use super::{
2323
IndexedFields,
2424
},
2525
index_config::SerializedIndexConfig,
26-
search_index::{
27-
DeveloperSearchIndexConfig,
28-
SearchIndexState,
29-
},
3026
vector_index::{
3127
DeveloperVectorIndexConfig,
3228
VectorDimensions,
@@ -36,7 +32,11 @@ use super::{
3632
IndexConfig,
3733
};
3834
use crate::{
39-
bootstrap_model::index::search_index::TextIndexBackfillState,
35+
bootstrap_model::index::text_index::{
36+
DeveloperSearchIndexConfig,
37+
TextIndexBackfillState,
38+
TextIndexState,
39+
},
4040
document::{
4141
ParsedDocument,
4242
ResolvedDocument,
@@ -91,7 +91,7 @@ impl<T: TableIdentifier> IndexMetadata<T> {
9191
search_field,
9292
filter_fields,
9393
},
94-
SearchIndexState::Backfilling(TextIndexBackfillState::new()),
94+
TextIndexState::Backfilling(TextIndexBackfillState::new()),
9595
)
9696
}
9797

@@ -121,7 +121,7 @@ impl<T: TableIdentifier> IndexMetadata<T> {
121121
pub fn new_search_index(
122122
name: GenericIndexName<T>,
123123
developer_config: DeveloperSearchIndexConfig,
124-
on_disk_state: SearchIndexState,
124+
on_disk_state: TextIndexState,
125125
) -> Self {
126126
Self {
127127
name,

crates/common/src/bootstrap_model/index/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mod developer_index_config;
33
mod index_config;
44
mod index_metadata;
55
pub mod index_validation_error;
6-
pub mod search_index;
6+
pub mod text_index;
77
pub mod vector_index;
88

99
use std::sync::LazyLock;

crates/common/src/bootstrap_model/index/search_index/backfill_state.rs renamed to crates/common/src/bootstrap_model/index/text_index/backfill_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use value::{
1010
InternalId,
1111
};
1212

13-
use crate::bootstrap_model::index::search_index::{
13+
use crate::bootstrap_model::index::text_index::{
1414
index_snapshot::SerializedFragmentedTextSegment,
1515
FragmentedTextSegment,
1616
};

crates/common/src/bootstrap_model/index/search_index/index_snapshot.rs renamed to crates/common/src/bootstrap_model/index/text_index/index_snapshot.rs

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ use crate::types::{
1616
#[derive(Debug, Clone, PartialEq, Eq)]
1717
#[cfg_attr(any(test, feature = "testing"), derive(proptest_derive::Arbitrary))]
1818
pub struct TextIndexSnapshot {
19-
pub data: SearchIndexSnapshotData,
19+
pub data: TextIndexSnapshotData,
2020
pub ts: Timestamp,
2121
pub version: TextSnapshotVersion,
2222
}
2323

2424
#[derive(Debug, Clone, PartialEq, Eq)]
25-
pub enum SearchIndexSnapshotData {
25+
pub enum TextIndexSnapshotData {
2626
/// The "legacy" (aka current) single segment format that must be built by
2727
/// reading the entire table for each set of incremental updates.
2828
SingleSegment(ObjectKey),
@@ -51,24 +51,24 @@ mod proptest {
5151

5252
use super::{
5353
FragmentedTextSegment,
54-
SearchIndexSnapshotData,
54+
TextIndexSnapshotData,
5555
};
5656
use crate::types::ObjectKey;
5757

58-
impl Arbitrary for SearchIndexSnapshotData {
58+
impl Arbitrary for TextIndexSnapshotData {
5959
type Parameters = ();
6060
type Strategy = BoxedStrategy<Self>;
6161

6262
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
6363
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),
6666
any_with::<ConvexObject>((
6767
size_range(0..=4),
6868
FieldType::User,
6969
ExcludeSetsAndMaps(true)
7070
))
71-
.prop_map(SearchIndexSnapshotData::Unknown),
71+
.prop_map(TextIndexSnapshotData::Unknown),
7272
]
7373
.boxed()
7474
}
@@ -77,7 +77,7 @@ mod proptest {
7777

7878
#[derive(Serialize, Deserialize)]
7979
#[serde(tag = "data_type", rename_all = "PascalCase")]
80-
enum SerializedSearchIndexSnapshotData {
80+
enum SerializedTextIndexSnapshotData {
8181
SingleSegment {
8282
segment: String,
8383
},
@@ -86,55 +86,53 @@ enum SerializedSearchIndexSnapshotData {
8686
},
8787
}
8888

89-
impl TryFrom<WithUnknown<SerializedSearchIndexSnapshotData>> for SearchIndexSnapshotData {
89+
impl TryFrom<WithUnknown<SerializedTextIndexSnapshotData>> for TextIndexSnapshotData {
9090
type Error = anyhow::Error;
9191

92-
fn try_from(
93-
value: WithUnknown<SerializedSearchIndexSnapshotData>,
94-
) -> Result<Self, Self::Error> {
92+
fn try_from(value: WithUnknown<SerializedTextIndexSnapshotData>) -> Result<Self, Self::Error> {
9593
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)?),
9896
),
99-
WithUnknown::Known(SerializedSearchIndexSnapshotData::MultiSegment {
97+
WithUnknown::Known(SerializedTextIndexSnapshotData::MultiSegment {
10098
segments: serialized_segments,
10199
}) => {
102100
let segments: Vec<FragmentedTextSegment> = serialized_segments
103101
.into_iter()
104102
.map(FragmentedTextSegment::try_from)
105103
.collect::<anyhow::Result<Vec<_>>>()?;
106-
Ok(SearchIndexSnapshotData::MultiSegment(segments))
104+
Ok(TextIndexSnapshotData::MultiSegment(segments))
107105
},
108-
WithUnknown::Unknown(unknown) => Ok(SearchIndexSnapshotData::Unknown(unknown)),
106+
WithUnknown::Unknown(unknown) => Ok(TextIndexSnapshotData::Unknown(unknown)),
109107
}
110108
}
111109
}
112110

113-
impl TryFrom<SearchIndexSnapshotData> for WithUnknown<SerializedSearchIndexSnapshotData> {
111+
impl TryFrom<TextIndexSnapshotData> for WithUnknown<SerializedTextIndexSnapshotData> {
114112
type Error = anyhow::Error;
115113

116-
fn try_from(value: SearchIndexSnapshotData) -> Result<Self, Self::Error> {
114+
fn try_from(value: TextIndexSnapshotData) -> Result<Self, Self::Error> {
117115
match value {
118-
SearchIndexSnapshotData::SingleSegment(segment) => {
116+
TextIndexSnapshotData::SingleSegment(segment) => {
119117
let serialized_segment = segment.try_into()?;
120118
Ok(WithUnknown::Known(
121-
SerializedSearchIndexSnapshotData::SingleSegment {
119+
SerializedTextIndexSnapshotData::SingleSegment {
122120
segment: serialized_segment,
123121
},
124122
))
125123
},
126-
SearchIndexSnapshotData::MultiSegment(segments) => {
124+
TextIndexSnapshotData::MultiSegment(segments) => {
127125
let serialized_segments: Vec<SerializedFragmentedTextSegment> = segments
128126
.into_iter()
129127
.map(SerializedFragmentedTextSegment::try_from)
130128
.collect::<anyhow::Result<Vec<_>>>()?;
131129
Ok(WithUnknown::Known(
132-
SerializedSearchIndexSnapshotData::MultiSegment {
130+
SerializedTextIndexSnapshotData::MultiSegment {
133131
segments: serialized_segments,
134132
},
135133
))
136134
},
137-
SearchIndexSnapshotData::Unknown(unknown) => Ok(WithUnknown::Unknown(unknown)),
135+
TextIndexSnapshotData::Unknown(unknown) => Ok(WithUnknown::Unknown(unknown)),
138136
}
139137
}
140138
}
@@ -237,7 +235,7 @@ pub struct SerializedTextIndexSnapshot {
237235
#[serde(skip_serializing_if = "Option::is_none")]
238236
index: Option<String>,
239237
#[serde(skip_serializing_if = "Option::is_none")]
240-
data: Option<WithUnknown<SerializedSearchIndexSnapshotData>>,
238+
data: Option<WithUnknown<SerializedTextIndexSnapshotData>>,
241239
ts: i64,
242240
version: i64,
243241
}
@@ -246,7 +244,7 @@ impl TryFrom<TextIndexSnapshot> for SerializedTextIndexSnapshot {
246244
type Error = anyhow::Error;
247245

248246
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 {
250248
(Some(index.to_string()), None)
251249
} else {
252250
(None, Some(snapshot.data.try_into()?))
@@ -264,10 +262,10 @@ impl TryFrom<SerializedTextIndexSnapshot> for TextIndexSnapshot {
264262
type Error = anyhow::Error;
265263

266264
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()?)
269267
} else if let Some(serialized_data) = serialized.data {
270-
SearchIndexSnapshotData::try_from(serialized_data)?
268+
TextIndexSnapshotData::try_from(serialized_data)?
271269
} else {
272270
anyhow::bail!("Both data and index are missing!");
273271
};
@@ -298,10 +296,10 @@ pub mod test {
298296
use sync_types::Timestamp;
299297

300298
use crate::{
301-
bootstrap_model::index::search_index::{
299+
bootstrap_model::index::text_index::{
302300
index_snapshot::SerializedTextIndexSnapshot,
303-
SearchIndexSnapshotData,
304301
TextIndexSnapshot,
302+
TextIndexSnapshotData,
305303
TextSnapshotVersion,
306304
},
307305
types::ObjectKey,
@@ -348,7 +346,7 @@ pub mod test {
348346
serde_json::from_str(&serialized).unwrap();
349347
let deserialized_snapshot =
350348
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);
352350
assert_eq!(key, ObjectKey::try_from(snapshot.index).unwrap())
353351
}
354352

@@ -358,10 +356,10 @@ pub mod test {
358356
fn test_parse_old_snapshot_from_new(snapshot in any::<TextIndexSnapshot>()
359357
.prop_filter(
360358
"only single segment is backwards compatible",
361-
|snapshot| matches!(snapshot.data, SearchIndexSnapshotData::SingleSegment(_))
359+
|snapshot| matches!(snapshot.data, TextIndexSnapshotData::SingleSegment(_))
362360
)
363361
) {
364-
must_let!(let SearchIndexSnapshotData::SingleSegment(ref index) = &snapshot.data);
362+
must_let!(let TextIndexSnapshotData::SingleSegment(ref index) = &snapshot.data);
365363
let index = index.clone();
366364

367365
let serialized_data = SerializedTextIndexSnapshot::try_from(snapshot).unwrap();

0 commit comments

Comments
 (0)