Skip to content

Commit 8f2ee14

Browse files
committed
[BUG] schema: build default with config ef & knn_index, remove #document population in defaults
1 parent 47287c4 commit 8f2ee14

File tree

4 files changed

+714
-53
lines changed

4 files changed

+714
-53
lines changed

rust/cli/src/commands/vacuum.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use chroma_segment::local_segment_manager::LocalSegmentManager;
1111
use chroma_sqlite::db::SqliteDb;
1212
use chroma_sysdb::SysDb;
1313
use chroma_system::System;
14-
use chroma_types::{CollectionUuid, KnnIndex, ListCollectionsRequest};
14+
use chroma_types::{CollectionUuid, KnnIndex, ListCollectionsRequest, Schema};
1515
use clap::Parser;
1616
use colored::Colorize;
1717
use dialoguer::Confirm;
@@ -108,10 +108,15 @@ async fn trigger_vector_segments_max_seq_id_migration(
108108
for collection_id in collection_ids {
109109
let mut collection = sysdb.get_collection_with_segments(collection_id).await?;
110110

111-
collection
112-
.collection
113-
.reconcile_schema_with_config(default_knn_index)
114-
.map_err(|e| Box::new(e) as Box<dyn Error>)?;
111+
if collection.collection.schema.is_none() {
112+
collection.collection.schema = Some(
113+
Schema::convert_collection_config_to_schema(
114+
&collection.collection.config,
115+
default_knn_index,
116+
)
117+
.map_err(|e| Box::new(e) as Box<dyn Error>)?,
118+
);
119+
}
115120

116121
// If collection is uninitialized, that means nothing has been written yet.
117122
let dim = match collection.collection.dimension {

rust/frontend/src/get_collection_with_segments_provider.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,16 @@ impl CollectionsWithSegmentsProvider {
185185
.await?
186186
};
187187

188-
// reconcile schema and config
189-
let reconciled_schema = Schema::reconcile_schema_and_config(
190-
collection_and_segments_sysdb.collection.schema.as_ref(),
191-
Some(&collection_and_segments_sysdb.collection.config),
192-
knn_index,
193-
)
194-
.map_err(CollectionsWithSegmentsProviderError::InvalidSchema)?;
195-
collection_and_segments_sysdb.collection.schema = Some(reconciled_schema);
188+
if collection_and_segments_sysdb.collection.schema.is_none() {
189+
collection_and_segments_sysdb.collection.schema = Some(
190+
Schema::convert_collection_config_to_schema(
191+
&collection_and_segments_sysdb.collection.config,
192+
knn_index,
193+
)
194+
.map_err(CollectionsWithSegmentsProviderError::InvalidSchema)?,
195+
);
196+
}
197+
196198
self.set_collection_with_segments(collection_and_segments_sysdb.clone())
197199
.await;
198200
Ok(collection_and_segments_sysdb)

rust/frontend/src/impls/service_based_frontend.rs

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,15 @@ impl ServiceBasedFrontend {
380380
.map_err(|err| Box::new(err) as Box<dyn ChromaError>)?;
381381
if self.enable_schema {
382382
for collection in collections.iter_mut() {
383-
collection
384-
.reconcile_schema_with_config(self.default_knn_index)
385-
.map_err(GetCollectionsError::InvalidSchema)?;
383+
if collection.schema.is_none() {
384+
collection.schema = Some(
385+
Schema::convert_collection_config_to_schema(
386+
&collection.config,
387+
self.default_knn_index,
388+
)
389+
.map_err(GetCollectionsError::InvalidSchema)?,
390+
);
391+
}
386392
}
387393
}
388394
Ok(collections)
@@ -424,9 +430,15 @@ impl ServiceBasedFrontend {
424430
.map_err(|err| Box::new(err) as Box<dyn ChromaError>)?;
425431
if self.enable_schema {
426432
for collection in &mut collections {
427-
collection
428-
.reconcile_schema_with_config(self.default_knn_index)
429-
.map_err(GetCollectionError::InvalidSchema)?;
433+
if collection.schema.is_none() {
434+
collection.schema = Some(
435+
Schema::convert_collection_config_to_schema(
436+
&collection.config,
437+
self.default_knn_index,
438+
)
439+
.map_err(GetCollectionError::InvalidSchema)?,
440+
);
441+
}
430442
}
431443
}
432444
collections
@@ -448,10 +460,14 @@ impl ServiceBasedFrontend {
448460
.await
449461
.map_err(|err| Box::new(err) as Box<dyn ChromaError>)?;
450462

451-
if self.enable_schema {
452-
collection
453-
.reconcile_schema_with_config(self.default_knn_index)
454-
.map_err(GetCollectionByCrnError::InvalidSchema)?;
463+
if self.enable_schema && collection.schema.is_none() {
464+
collection.schema = Some(
465+
Schema::convert_collection_config_to_schema(
466+
&collection.config,
467+
self.default_knn_index,
468+
)
469+
.map_err(GetCollectionByCrnError::InvalidSchema)?,
470+
);
455471
}
456472
Ok(collection)
457473
}
@@ -628,10 +644,14 @@ impl ServiceBasedFrontend {
628644
.await;
629645
// this is done in the case that get_or_create was a get, in which case we should reconcile the schema and config
630646
// that was retrieved from sysdb, rather than the one that was passed in
631-
if self.enable_schema {
632-
collection
633-
.reconcile_schema_with_config(self.default_knn_index)
634-
.map_err(CreateCollectionError::InvalidSchema)?;
647+
if self.enable_schema && collection.schema.is_none() {
648+
collection.schema = Some(
649+
Schema::convert_collection_config_to_schema(
650+
&collection.config,
651+
self.default_knn_index,
652+
)
653+
.map_err(CreateCollectionError::InvalidSchema)?,
654+
);
635655
}
636656
Ok(collection)
637657
}
@@ -733,10 +753,15 @@ impl ServiceBasedFrontend {
733753
target_collection_name,
734754
)
735755
.await?;
736-
collection_and_segments
737-
.collection
738-
.reconcile_schema_with_config(self.default_knn_index)
739-
.map_err(ForkCollectionError::InvalidSchema)?;
756+
if collection_and_segments.collection.schema.is_none() {
757+
collection_and_segments.collection.schema = Some(
758+
Schema::convert_collection_config_to_schema(
759+
&collection_and_segments.collection.config,
760+
self.default_knn_index,
761+
)
762+
.map_err(ForkCollectionError::InvalidSchema)?,
763+
);
764+
}
740765
let collection = collection_and_segments.collection.clone();
741766
let latest_collection_logical_size_bytes = collection_and_segments
742767
.collection

0 commit comments

Comments
 (0)