Skip to content

Commit b428f20

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

File tree

4 files changed

+716
-51
lines changed

4 files changed

+716
-51
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: 45 additions & 16 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
@@ -449,9 +461,15 @@ impl ServiceBasedFrontend {
449461
.map_err(|err| Box::new(err) as Box<dyn ChromaError>)?;
450462

451463
if self.enable_schema {
452-
collection
453-
.reconcile_schema_with_config(self.default_knn_index)
454-
.map_err(GetCollectionByCrnError::InvalidSchema)?;
464+
if collection.schema.is_none() {
465+
collection.schema = Some(
466+
Schema::convert_collection_config_to_schema(
467+
&collection.config,
468+
self.default_knn_index,
469+
)
470+
.map_err(GetCollectionByCrnError::InvalidSchema)?,
471+
);
472+
}
455473
}
456474
Ok(collection)
457475
}
@@ -629,9 +647,15 @@ impl ServiceBasedFrontend {
629647
// this is done in the case that get_or_create was a get, in which case we should reconcile the schema and config
630648
// that was retrieved from sysdb, rather than the one that was passed in
631649
if self.enable_schema {
632-
collection
633-
.reconcile_schema_with_config(self.default_knn_index)
634-
.map_err(CreateCollectionError::InvalidSchema)?;
650+
if collection.schema.is_none() {
651+
collection.schema = Some(
652+
Schema::convert_collection_config_to_schema(
653+
&collection.config,
654+
self.default_knn_index,
655+
)
656+
.map_err(CreateCollectionError::InvalidSchema)?,
657+
);
658+
}
635659
}
636660
Ok(collection)
637661
}
@@ -733,10 +757,15 @@ impl ServiceBasedFrontend {
733757
target_collection_name,
734758
)
735759
.await?;
736-
collection_and_segments
737-
.collection
738-
.reconcile_schema_with_config(self.default_knn_index)
739-
.map_err(ForkCollectionError::InvalidSchema)?;
760+
if collection_and_segments.collection.schema.is_none() {
761+
collection_and_segments.collection.schema = Some(
762+
Schema::convert_collection_config_to_schema(
763+
&collection_and_segments.collection.config,
764+
self.default_knn_index,
765+
)
766+
.map_err(ForkCollectionError::InvalidSchema)?,
767+
);
768+
}
740769
let collection = collection_and_segments.collection.clone();
741770
let latest_collection_logical_size_bytes = collection_and_segments
742771
.collection

0 commit comments

Comments
 (0)